[clang] Fix greatergreater (PR #122282)
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/122282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix greatergreater (PR #122282)
https://github.com/owenca commented: With `ColumnLimit: 60`, this patch doesn't seem to format the following correctly: `std::cout << longOperand_1 << longOperand_2 << longOperand_3;` https://github.com/llvm/llvm-project/pull/122282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix greatergreater (PR #122282)
@@ -28188,6 +28188,16 @@ TEST_F(FormatTest, BreakBinaryOperations) { " | byte_buffer[2] << 16\n" " | byte_buffer[3] << 24;", Style); + + Style.BreakBinaryOperations = FormatStyle::BBO_OnePerLine; + // Check operator >> special case + verifyFormat("std::cout\n" + "<< longOperand1\n" + "<< longOperand2\n" + "<< longOperand3\n" + "<< longOperand4\n" + "<< longOperand5;", owenca wrote: This test case passes without this patch. https://github.com/llvm/llvm-project/pull/122282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)
@@ -952,6 +952,12 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state, const MemSpaceRegion *RightMS = RightBase->getMemorySpace(); const MemSpaceRegion *UnknownMS = MemMgr.getUnknownRegion(); +if (LeftMS != RightMS && +((isa(LeftMS) && isa(RightMS)) || + (isa(LeftMS) && isa(RightMS { + return UnknownVal(); +} + mzyKi wrote: Thanks for your suggestions! https://github.com/llvm/llvm-project/pull/122404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)
mzyKi wrote: @Flandini Hi, I am willing to work together with you to solve this problem. Maybe you can assign some work to me. https://github.com/llvm/llvm-project/pull/122404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/2] Reapply "[Clang] Implement CWG2369 "Ordering between constraints and substitution"" (#122130) This reverts commit 3972ed57088f6515b787d7d38dec03dc74e51827. --- clang/include/clang/Sema/Sema.h | 22 +++- clang/include/clang/Sema/Template.h | 6 + clang/lib/Sema/SemaConcept.cpp| 47 ++- clang/lib/Sema/SemaTemplateDeduction.cpp | 49 +--- clang/lib/Sema/SemaTemplateDeductionGuide.cpp | 8 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 -- clang/lib/Sema/TreeTransform.h| 2 +- clang/test/CXX/drs/cwg23xx.cpp| 29 + clang/test/CXX/drs/cwg26xx.cpp| 2 +- clang/test/CXX/drs/cwg27xx.cpp| 20 +++ .../expr.prim.req/nested-requirement.cpp | 2 +- .../constrant-satisfaction-conversions.cpp| 6 +- .../SemaCXX/concept-crash-on-diagnostic.cpp | 2 +- clang/test/SemaCXX/cxx20-ctad-type-alias.cpp | 2 +- clang/test/SemaCXX/cxx23-assume.cpp | 6 +- clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 2 +- clang/test/SemaCXX/lambda-unevaluated.cpp | 4 +- .../SemaTemplate/concepts-recursive-inst.cpp | 4 +- .../SemaTemplate/cxx2a-constraint-exprs.cpp | 2 +- clang/test/SemaTemplate/deduction-guide.cpp | 5 - .../nested-implicit-deduction-guides.cpp | 8 +- clang/www/cxx_dr_status.html | 8 +- 22 files changed, 289 insertions(+), 62 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index a41f16f6dc8c9b..18fd95f77ec227 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13062,6 +13062,7 @@ class Sema final : public SemaBase { /// /// \param SkipForSpecialization when specified, any template specializations /// in a traversal would be ignored. + /// /// \param ForDefaultArgumentSubstitution indicates we should continue looking /// when encountering a specialized member function template, rather than /// returning immediately. @@ -13073,6 +13074,17 @@ class Sema final : public SemaBase { bool SkipForSpecialization = false, bool ForDefaultArgumentSubstitution = false); + /// Apart from storing the result to \p Result, this behaves the same as + /// another overload. + void getTemplateInstantiationArgs( + MultiLevelTemplateArgumentList &Result, const NamedDecl *D, + const DeclContext *DC = nullptr, bool Final = false, + std::optional> Innermost = std::nullopt, + bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr, + bool ForConstraintInstantiation = false, + bool SkipForSpecialization = false, + bool ForDefaultArgumentSubstitution = false); + /// RAII object to handle the state changes required to synthesize /// a function body. class SynthesizedFunctionScope { @@ -13342,7 +13354,7 @@ class Sema final : public SemaBase { ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); - // Unlike the above, this does not evaluates constraints. + // Unlike the above, this does not evaluate constraints. ExprResult SubstConstraintExprWithoutSatisfaction( Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); @@ -14463,10 +14475,10 @@ class Sema final : public SemaBase { const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange); - bool CheckInstantiatedFunctionTemplateConstraints( - SourceLocation PointOfInstantiation, FunctionDecl *Decl, - ArrayRef TemplateArgs, - ConstraintSatisfaction &Satisfaction); + bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation, +FunctionDecl *Decl, +ArrayRef TemplateArgs, +ConstraintSatisfaction &Satisfaction); /// \brief Emit diagnostics explaining why a constraint expression was deemed /// unsatisfied. diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 9800f75f676aaf..59a0575ca98036 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char { llvm::PointerUnion * findInstantiationOf(const Decl *D); +/// Similar to \p findInstantiationOf(), but it wouldn't assert if the +/// instantiation was not found within the current instantiation scope. This +/// is helpful for on-demand declaration instantiation. +llvm::PointerUnion * +findInstantiationUnsafe(const Decl *D); + void InstantiatedLocal(const Decl *D, Decl *Inst
[clang-tools-extra] cfe2635 - Reapply "[clang] Avoid re-evaluating field bitwidth" (#122289)
Author: Timm Baeder Date: 2025-01-11T07:12:37+01:00 New Revision: cfe26358e3051755961fb1f3b46328dc2c326895 URL: https://github.com/llvm/llvm-project/commit/cfe26358e3051755961fb1f3b46328dc2c326895 DIFF: https://github.com/llvm/llvm-project/commit/cfe26358e3051755961fb1f3b46328dc2c326895.diff LOG: Reapply "[clang] Avoid re-evaluating field bitwidth" (#122289) Added: Modified: clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp clang-tools-extra/clangd/Hover.cpp clang/include/clang/AST/Decl.h clang/include/clang/ASTMatchers/ASTMatchers.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ByteCode/Interp.h clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp clang/lib/AST/Decl.cpp clang/lib/AST/DeclCXX.cpp clang/lib/AST/Expr.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/Randstruct.cpp clang/lib/AST/RecordLayoutBuilder.cpp clang/lib/CodeGen/ABIInfo.cpp clang/lib/CodeGen/ABIInfoImpl.cpp clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGClass.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGNonTrivialStruct.cpp clang/lib/CodeGen/CGObjCMac.cpp clang/lib/CodeGen/CGObjCRuntime.cpp clang/lib/CodeGen/CGRecordLayoutBuilder.cpp clang/lib/CodeGen/SwiftCallingConv.cpp clang/lib/CodeGen/Targets/LoongArch.cpp clang/lib/CodeGen/Targets/RISCV.cpp clang/lib/CodeGen/Targets/X86.cpp clang/lib/CodeGen/Targets/XCore.cpp clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaDeclObjC.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/StaticAnalyzer/Core/RegionStore.cpp clang/tools/libclang/CXType.cpp clang/unittests/AST/ASTImporterTest.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-with-bitfields.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp index a950704208c73b..408390ebc70b64 100644 --- a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp @@ -38,7 +38,7 @@ AST_MATCHER(FieldDecl, hasIntBitwidth) { assert(Node.isBitField()); const ASTContext &Ctx = Node.getASTContext(); unsigned IntBitWidth = Ctx.getIntWidth(Ctx.IntTy); - unsigned CurrentBitWidth = Node.getBitWidthValue(Ctx); + unsigned CurrentBitWidth = Node.getBitWidthValue(); return IntBitWidth == CurrentBitWidth; } diff --git a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp index a73d46f01d9b2d..4ceeefb78ee824 100644 --- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp @@ -124,7 +124,7 @@ static MagnitudeBits calcMagnitudeBits(const ASTContext &Context, unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U; if (const auto *BitField = IntExpr->getSourceBitField()) { -unsigned BitFieldWidth = BitField->getBitWidthValue(Context); +unsigned BitFieldWidth = BitField->getBitWidthValue(); return {BitFieldWidth - SignedBits, BitFieldWidth}; } diff --git a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp index 47dafca2d03ff0..7028c3958f103e 100644 --- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp @@ -160,7 +160,7 @@ void MultiwayPathsCoveredCheck::handleSwitchWithoutDefault( } if (const auto *BitfieldDecl = Result.Nodes.getNodeAs("bitfield")) { - return twoPow(BitfieldDecl->getBitWidthValue(*Result.Context)); + return twoPow(BitfieldDecl->getBitWidthValue()); } return static_cast(0); diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 298fa79e3fd0ba..5e136d0e76ece7 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -1018,7 +1018,7 @@ void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) { const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(Record); HI.Offset = Layout.getFieldOffset(FD->getFieldIndex()); if (FD->isBitField()) -HI.Size = FD->getBitWidthValue(Ctx); +HI.Size = FD->getBitWidthValue(); else if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) HI.Size = FD->isZeroSize(Ctx) ? 0 : Size->getQua
[clang] [clang-tools-extra] [lldb] Reapply "[clang] Avoid re-evaluating field bitwidth" (PR #122289)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/122289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fb1d6f0 - [Driver][OpenBSD] Remove riscv32 bit (#122525)
Author: Brad Smith Date: 2025-01-10T16:53:17-05:00 New Revision: fb1d6f0d7d834067d36959ec4b54550cee72da95 URL: https://github.com/llvm/llvm-project/commit/fb1d6f0d7d834067d36959ec4b54550cee72da95 DIFF: https://github.com/llvm/llvm-project/commit/fb1d6f0d7d834067d36959ec4b54550cee72da95.diff LOG: [Driver][OpenBSD] Remove riscv32 bit (#122525) Someone added riscv32 here. OpenBSD does not support riscv32. Added: Modified: clang/lib/Basic/Targets/OSTargets.h Removed: diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 53dd23c3129636..b8d9a5725d0127 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -447,7 +447,6 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public OSTargetInfo { case llvm::Triple::sparcv9: this->MCountName = "_mcount"; break; -case llvm::Triple::riscv32: case llvm::Triple::riscv64: break; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] arm64-apple-none-macho is missing the Apple macros from arm-apple-none-macho (PR #122427)
@@ -243,6 +247,8 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, case llvm::Triple::thumbeb: jroelofs wrote: oh, I missed that we're already lumping `arm-none-macho` & friends under `DarwinARMTargetInfo`. https://github.com/llvm/llvm-project/pull/122427 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CMake] Add a cache file for building a highly-optimized LLVM toolchain (PR #117802)
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/117802 >From 3bddb3c6d25efbfcc901a42a8367be85599d1f7e Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 23 Sep 2024 13:34:46 + Subject: [PATCH 1/8] [CMake] Add a cache file for building a highly-optimized LLVM toolchain The goal of these cache files is to provide a toolchain that: 1. Relies on only LLVM components (as much as possible). 2. Is highly optimized. These cache files will produce a full toolchain (clang/compiler-rt/libcxx/lld) where clang is built with LTO, PGO, and BOLT optimizations, and is statically linked with an LTO optimized libc++ and compiler-rt. I would eventually like to use these as the basis for the release builds. --- .../cmake/caches/llvm-toolchain/stage1.cmake | 13 .../cmake/caches/llvm-toolchain/stage2.cmake | 20 +++ .../llvm-toolchain/stage3-instrumented.cmake | 10 ++ .../cmake/caches/llvm-toolchain/stage3.cmake | 16 +++ clang/cmake/caches/llvm-toolchain/usage.rst | 20 +++ 5 files changed, 79 insertions(+) create mode 100644 clang/cmake/caches/llvm-toolchain/stage1.cmake create mode 100644 clang/cmake/caches/llvm-toolchain/stage2.cmake create mode 100644 clang/cmake/caches/llvm-toolchain/stage3-instrumented.cmake create mode 100644 clang/cmake/caches/llvm-toolchain/stage3.cmake create mode 100644 clang/cmake/caches/llvm-toolchain/usage.rst diff --git a/clang/cmake/caches/llvm-toolchain/stage1.cmake b/clang/cmake/caches/llvm-toolchain/stage1.cmake new file mode 100644 index 00..13a0a7871dcd26 --- /dev/null +++ b/clang/cmake/caches/llvm-toolchain/stage1.cmake @@ -0,0 +1,13 @@ +# Stage 1: +# * Build the prerequisites for stage 2. +# * We will be building an LTO optimized libcxx in stage 2, so we need to +# build clang and lld. + + +set(CMAKE_BUILD_TYPE Release CACHE STRING "") +set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") +set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "") + +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage2.cmake CACHE BOOL "") +set(CLANG_BOOTSTRAP_TARGETS stage3-check-all stage3-distribution stage3-install-distribution stage3-clang stage3-clang-bolt CACHE BOOL "") diff --git a/clang/cmake/caches/llvm-toolchain/stage2.cmake b/clang/cmake/caches/llvm-toolchain/stage2.cmake new file mode 100644 index 00..87ac7899b205ef --- /dev/null +++ b/clang/cmake/caches/llvm-toolchain/stage2.cmake @@ -0,0 +1,20 @@ +# Stage 2: +# * Build an LTO optimized libcxx, so we can staticially link it into stage 3 +# clang. +# * Stage 3 will be PGO optimized, so we need to build clang, lld, and +# compiler-rt in stage 2. + + +set(CMAKE_BUILD_TYPE Release CACHE STRING "") +set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") +set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "" FORCE) +set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "" FORCE) + +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage3-instrumented.cmake CACHE BOOL "") +set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE BOOL "") +set(CLANG_BOOTSTRAP_TARGETS stage3-check-all stage3-distribution stage3-install-distribution stage3-clang stage3-clang-bolt CACHE BOOL "") +set(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY ON CACHE STRING "") +set(RUNTIMES_CMAKE_ARGS "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON" CACHE STRING "") +set(LLVM_ENABLE_LLD ON CACHE STRING "") +#set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") diff --git a/clang/cmake/caches/llvm-toolchain/stage3-instrumented.cmake b/clang/cmake/caches/llvm-toolchain/stage3-instrumented.cmake new file mode 100644 index 00..4570a6c758ccda --- /dev/null +++ b/clang/cmake/caches/llvm-toolchain/stage3-instrumented.cmake @@ -0,0 +1,10 @@ +# Stage 3 instrumented: +# * Build an instrumented clang, so we can generate profile data for stage 3. + + +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage3.cmake CACHE BOOL "") +set(CLANG_BOOTSTRAP_TARGETS clang check-all distribution install-distribution clang-bolt CACHE BOOL "") +set(CLANG_BOLT OFF CACHE STRING "") + +include(${CMAKE_CURRENT_LIST_DIR}/stage3.cmake) diff --git a/clang/cmake/caches/llvm-toolchain/stage3.cmake b/clang/cmake/caches/llvm-toolchain/stage3.cmake new file mode 100644 index 00..a9050a64d8f633 --- /dev/null +++ b/clang/cmake/caches/llvm-toolchain/stage3.cmake @@ -0,0 +1,16 @@ +# Stage 3: +# * This is the final stage. +# * The goals is to have a clang that is LTO, PGO, and bolt optimized and also +# statically linked to libcxx and compiler-rt. + +set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") +set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "" FORCE) +set(LLVM_ENABLE_PROJECTS "clang;lld;bolt;" CACHE STRING "" FORCE) +set(LLVM_ENAB
[clang] [llvm] [mlir] [IR][ModRef] Introduce `errno` memory location (PR #120783)
@@ -82,7 +82,7 @@ define void @test_store(ptr %p) { @G = external global ptr define i8 @test_store_capture(ptr %p) { -; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: read, inaccessiblemem: none) +; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: read, inaccessiblemem: none, errnomem: none) efriedma-quic wrote: How are we inferring `errnomem: none` here? https://github.com/llvm/llvm-project/pull/120783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [IR][ModRef] Introduce `errno` memory location (PR #120783)
https://github.com/efriedma-quic commented: This seems like roughly what I expected from the proposal. https://github.com/llvm/llvm-project/pull/120783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [IR][ModRef] Introduce `errno` memory location (PR #120783)
https://github.com/efriedma-quic edited https://github.com/llvm/llvm-project/pull/120783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [nfc][ubsan] Use O1 in test to remove more unrelated stuff (PR #122408)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/122408 >From 5da780d61aaa329ec66c5a874caeb1de50969342 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Thu, 9 Jan 2025 18:16:37 -0800 Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- clang/test/CodeGen/allow-ubsan-check.c | 275 ++--- 1 file changed, 114 insertions(+), 161 deletions(-) diff --git a/clang/test/CodeGen/allow-ubsan-check.c b/clang/test/CodeGen/allow-ubsan-check.c index 5232d240854666..39fbdea88cd759 100644 --- a/clang/test/CodeGen/allow-ubsan-check.c +++ b/clang/test/CodeGen/allow-ubsan-check.c @@ -1,86 +1,65 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=TRAP -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=RECOVER +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=TRAP +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=RECOVER -// CHECK-LABEL: define dso_local i32 @div( -// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-LABEL: define dso_local noundef i32 @div( +// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: -// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4 -// CHECK-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4 -// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4 -// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[Y_ADDR]], align 4 -// CHECK-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0, !nosanitize [[META2:![0-9]+]] -// CHECK-NEXT:[[TMP3:%.*]] = icmp ne i32 [[TMP0]], -2147483648, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP4:%.*]] = icmp ne i32 [[TMP1]], -1, !nosanitize [[META2]] -// CHECK-NEXT:[[OR:%.*]] = or i1 [[TMP3]], [[TMP4]], !nosanitize [[META2]] -// CHECK-NEXT:[[TMP5:%.*]] = and i1 [[TMP2]], [[OR]], !nosanitize [[META2]] -// CHECK-NEXT:[[TMP6:%.*]] = call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]] -// CHECK-NEXT:[[TMP7:%.*]] = xor i1 [[TMP6]], true, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP8:%.*]] = or i1 [[TMP5]], [[TMP7]], !nosanitize [[META2]] -// CHECK-NEXT:br i1 [[TMP8]], label [[CONT:%.*]], label [[HANDLER_DIVREM_OVERFLOW:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]] +// CHECK-NEXT:[[TMP0:%.*]] = icmp eq i32 [[Y]], 0, !nosanitize [[META2:![0-9]+]] +// CHECK-NEXT:[[TMP1:%.*]] = icmp eq i32 [[X]], -2147483648, !nosanitize [[META2]] +// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i32 [[Y]], -1, !nosanitize [[META2]] +// CHECK-NEXT:[[OR_NOT5:%.*]] = and i1 [[TMP1]], [[TMP2]] +// CHECK-NEXT:[[DOTNOT3:%.*]] = or i1 [[TMP0]], [[OR_NOT5]] +// CHECK-NEXT:[[TMP3:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]] +// CHECK-NEXT:[[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]] +// CHECK-NEXT:br i1 [[DOTNOT1]], label [[HANDLER_DIVREM_OVERFLOW:%.*]], label [[CONT:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]] // CHECK: handler.divrem_overflow: -// CHECK-NEXT:[[TMP9:%.*]] = zext i32 [[TMP0]] to i64, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP10:%.*]] = zext i32 [[TMP1]] to i64, !nosanitize [[META2]] -// CHECK-NEXT:call void @__ubsan_handle_divrem_overflow_abort(ptr @[[GLOB1:[0-9]+]], i64 [[TMP9]], i64 [[TMP10]]) #[[ATTR4:[0-9]+]], !nosanitize [[META2]] +// CHECK-NEXT:[[TMP4:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]
[clang] [Darwin][Driver][clang] arm64-apple-none-macho is missing the Apple macros from arm-apple-none-macho (PR #122427)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-offload-libc-amdgpu-runtime` running on `omp-vega20-1` while building `clang` at step 7 "Add check check-offload". Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/11512 Here is the relevant piece of the build log for the reference ``` Step 7 (Add check check-offload) failure: test (failure) TEST 'libomptarget :: amdgcn-amd-amdhsa :: offloading/pgo1.c' FAILED Exit Code: 1 Command Output (stdout): -- # RUN: at line 1 /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang -fopenmp-I /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test -I /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -fopenmp-targets=amdgcn-amd-amdhsa /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c -o /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp -Xoffload-linker -lc -Xoffload-linker -lm /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a -fprofile-instr-generate -Xclang "-fprofile-instrument=clang" # executed command: /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang -fopenmp -I /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test -I /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -fopenmp-targets=amdgcn-amd-amdhsa /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c -o /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp -Xoffload-linker -lc -Xoffload-linker -lm /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a -fprofile-instr-generate -Xclang -fprofile-instrument=clang # RUN: at line 3 /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp 2>&1 | /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c --check-prefix="CLANG-PGO" # executed command: /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp # executed command: /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c --check-prefix=CLANG-PGO # .---command stderr # | /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c:32:20: error: CLANG-PGO-NEXT: expected string not found in input # | // CLANG-PGO-NEXT: [ 0 11 20 ] # |^ # | :3:28: note: scanning from here # | Counters = # |^ # | :4:1: note: possible intended match here # | [ 0 14 20 ] # | ^ # | # | Input file: # | Check file: /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c # | # | -dump-input=help explains the following input dump. # | # | Input was: # | << # |1: === GPU Profile === # |2: Target: amdgcn-amd-amdhsa # |3: Counters = # | ne
[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)
owenca wrote: > > Maybe we should make it a sub-option for `BlockIndent`. I'm seeing a > > possible need for having control over other kinds of block indented > > structures such as Lambdas. I suspect the way this option has been > > implemented it interacts with the alignment options anyway. This would be a > > question probably for @owenca > > I thought about it some more and I don't think it would be a good idea. > Having a separate option seems a bit easier to handle, and allows mixing and > matching by users. I think this should be covered by [`BlockIndent`](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#alignafteropenbracket), which already covers both parentheses and braces. Let's hear what @mydeveloperday has to say. https://github.com/llvm/llvm-project/pull/118046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] -ftime-report: reorganize timers (PR #122225)
https://github.com/MaskRay closed https://github.com/llvm/llvm-project/pull/15 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] -ftime-report: reorganize timers (PR #122225)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/15 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] -ftime-report: reorganize timers (PR #122225)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/15 >From 586f1fa8fb02431a962ca606fd546c2310427c80 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 8 Jan 2025 23:19:56 -0800 Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- clang/include/clang/CodeGen/BackendUtil.h | 10 ++ .../include/clang/Frontend/CompilerInstance.h | 4 +++ clang/lib/CodeGen/BackendConsumer.h | 4 +-- clang/lib/CodeGen/BackendUtil.cpp | 34 +++ clang/lib/CodeGen/CodeGenAction.cpp | 34 ++- .../CodeGen/ObjectFilePCHContainerWriter.cpp | 15 .../Frontend/ftime-report-template-decl.cpp | 14 7 files changed, 59 insertions(+), 56 deletions(-) diff --git a/clang/include/clang/CodeGen/BackendUtil.h b/clang/include/clang/CodeGen/BackendUtil.h index 7aa4f9db6c2e42..78d1e5ee8e6d59 100644 --- a/clang/include/clang/CodeGen/BackendUtil.h +++ b/clang/include/clang/CodeGen/BackendUtil.h @@ -25,11 +25,9 @@ class FileSystem; } // namespace llvm namespace clang { +class CompilerInstance; class DiagnosticsEngine; -class HeaderSearchOptions; class CodeGenOptions; -class TargetOptions; -class LangOptions; class BackendConsumer; enum BackendAction { @@ -41,10 +39,8 @@ enum BackendAction { Backend_EmitObj ///< Emit native object files }; -void EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &, - const CodeGenOptions &CGOpts, const TargetOptions &TOpts, - const LangOptions &LOpts, StringRef TDesc, - llvm::Module *M, BackendAction Action, +void emitBackendOutput(CompilerInstance &CI, StringRef TDesc, llvm::Module *M, + BackendAction Action, llvm::IntrusiveRefCntPtr VFS, std::unique_ptr OS, BackendConsumer *BC = nullptr); diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 1220a4e29471d1..3cec57abae4445 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -630,6 +630,10 @@ class CompilerInstance : public ModuleLoader { /// @name Frontend timer /// @{ + llvm::TimerGroup &getFrontendTimerGroup() const { +return *FrontendTimerGroup; + } + bool hasFrontendTimer() const { return (bool)FrontendTimer; } llvm::Timer &getFrontendTimer() const { diff --git a/clang/lib/CodeGen/BackendConsumer.h b/clang/lib/CodeGen/BackendConsumer.h index d932a78f469b95..ad3adfca367858 100644 --- a/clang/lib/CodeGen/BackendConsumer.h +++ b/clang/lib/CodeGen/BackendConsumer.h @@ -28,8 +28,8 @@ class BackendConsumer : public ASTConsumer { using LinkModule = CodeGenAction::LinkModule; virtual void anchor(); + CompilerInstance &CI; DiagnosticsEngine &Diags; - const HeaderSearchOptions &HeaderSearchOpts; const CodeGenOptions &CodeGenOpts; const TargetOptions &TargetOpts; const LangOptions &LangOpts; @@ -70,7 +70,7 @@ class BackendConsumer : public ASTConsumer { llvm::Module *CurLinkModule = nullptr; public: - BackendConsumer(const CompilerInstance &CI, BackendAction Action, + BackendConsumer(CompilerInstance &CI, BackendAction Action, IntrusiveRefCntPtr VFS, llvm::LLVMContext &C, SmallVector LinkModules, StringRef InFile, std::unique_ptr OS, diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 2dbab785658aa4..bcb14a9a166077 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -137,8 +137,6 @@ class EmitAssemblyHelper { llvm::Module *TheModule; IntrusiveRefCntPtr VFS; - Timer CodeGenerationTime; - std::unique_ptr OS; Triple TargetTriple; @@ -211,7 +209,6 @@ class EmitAssemblyHelper { IntrusiveRefCntPtr VFS) : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts), TheModule(M), VFS(std::move(VFS)), -CodeGenerationTime("codegen", "Code Generation Time"), TargetTriple(TheModule->getTargetTriple()) {} ~EmitAssemblyHelper() { @@ -222,8 +219,8 @@ class EmitAssemblyHelper { std::unique_ptr TM; // Emit output using the new pass manager for the optimization pipeline. - void EmitAssembly(BackendAction Action, std::unique_ptr OS, -BackendConsumer *BC); + void emitAssembly(const CompilerInstance &CI, BackendAction Action, +std::unique_ptr OS, BackendConsumer *BC); }; } // namespace @@ -1212,10 +1209,14 @@ void EmitAssemblyHelper::RunCodegenPipeline( } } -void EmitAssemblyHelper::EmitAssembly(BackendAct
[clang] 0de18e7 - -ftime-report: reorganize timers
Author: Fangrui Song Date: 2025-01-10T19:25:18-08:00 New Revision: 0de18e72c607c1b52be2c60d45cf2f9fc3af4542 URL: https://github.com/llvm/llvm-project/commit/0de18e72c607c1b52be2c60d45cf2f9fc3af4542 DIFF: https://github.com/llvm/llvm-project/commit/0de18e72c607c1b52be2c60d45cf2f9fc3af4542.diff LOG: -ftime-report: reorganize timers The code generation time is unclear in the -ftime-report output: * The two clang timers "Code Generation Time" and "LLVM IR Generation Time" are in the default group "Miscellaneous Ungrouped Timers". * There is also a "Clang front-end time" group, which actually includes code generation time. ``` ===-=== Miscellaneous Ungrouped Timers ===-=== ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 0.0611 ( 1.7%) 0.0099 ( 4.4%) 0.0710 ( 1.9%) 0.0713 ( 1.9%) LLVM IR Generation Time 3.5140 ( 98.3%) 0.2165 ( 95.6%) 3.7306 ( 98.1%) 3.7342 ( 98.1%) Code Generation Time 3.5751 (100.0%) 0.2265 (100.0%) 3.8016 (100.0%) 3.8055 (100.0%) Total ... ===-=== Clang front-end time report ===-=== Total Execution Time: 3.9108 seconds (3.9146 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 3.6802 (100.0%) 0.2306 (100.0%) 3.9108 (100.0%) 3.9146 (100.0%) Clang front-end timer 3.6802 (100.0%) 0.2306 (100.0%) 3.9108 (100.0%) 3.9146 (100.0%) Total ``` This patch * renames "Clang front-end time report" (FrontendAction time) to "Clang time report", * renames "Clang front-end" to "Front end", * moves "LLVM IR Generation" into the group, * replaces "Code Generation time" with "Optimizer" (middle end) and "Machine code generation" (back end). ``` % clang -c sqlite3.i -w -ftime-report -mllvm -sort-timers=0 ... ===-=== Clang time report ===-=== Total Execution Time: 1.5922 seconds (1.5972 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 0.5107 ( 35.9%) 0.0105 ( 6.2%) 0.5211 ( 32.7%) 0.5222 ( 32.7%) Front end 0.2464 ( 17.3%) 0.0340 ( 20.0%) 0.2804 ( 17.6%) 0.2814 ( 17.6%) LLVM IR generation 0.6240 ( 43.9%) 0.1235 ( 72.7%) 0.7475 ( 47.0%) 0.7503 ( 47.0%) Machine code generation 0.0413 ( 2.9%) 0.0018 ( 1.0%) 0.0431 ( 2.7%) 0.0433 ( 2.7%) Optimizer 1.4224 (100.0%) 0.1698 (100.0%) 1.5922 (100.0%) 1.5972 (100.0%) Total ``` Pull Request: https://github.com/llvm/llvm-project/pull/15 Added: Modified: clang/docs/ReleaseNotes.rst clang/include/clang/Frontend/CompilerInstance.h clang/lib/CodeGen/BackendUtil.cpp clang/lib/CodeGen/CodeGenAction.cpp clang/lib/Frontend/CompilerInstance.cpp clang/test/Frontend/ftime-report-template-decl.cpp llvm/include/llvm/Support/Timer.h llvm/lib/Support/Timer.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 190843f2aa6c96..197b3692b8a181 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -445,6 +445,10 @@ Non-comprehensive list of changes in this release - Matrix types (a Clang extension) can now be used in pseudo-destructor expressions, which allows them to be stored in STL containers. +- In the ``-ftime-report`` output, the new "Clang time report" group replaces + the old "Clang front-end time report" and includes "Front end", "LLVM IR + generation", "Optimizer", and "Machine code generation". + New Compiler Flags -- diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 1220a4e29471d1..4a79b8d107171a 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -118,7 +118,7 @@ class CompilerInstance : public ModuleLoader { std::unique_ptr TheSema; /// The frontend timer group. - std::unique_ptr FrontendTimerGroup; + std::unique_ptr timerGroup; /// The frontend timer. std::unique_ptr FrontendTimer; @@ -630,6 +630,8 @@ class CompilerInstance : public ModuleLoader { /// @name Frontend timer /// @{ + llvm::TimerGroup &getTimerGroup() const { return *timerGroup; } + bool hasFrontendTimer() const { return (bool)FrontendTimer; } llvm::Timer &getFrontendTimer() const { diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen
[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)
https://github.com/owenca commented: About the test cases: - Call `verifyFormat` instead of `verifyNoChange` whenever possible. - Don't end a test case with a newline. (Search for `\n",` and `\n")`.) - Capitalize the first word of a comment and end the comment with a `.` (or `:` if appropriate). https://github.com/llvm/llvm-project/pull/118046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] Reapply "[clang] Avoid re-evaluating field bitwidth" (PR #122289)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/122289 >From 59abbcc54700d5a8ba31ecd3b37431ffe86f7d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 9 Jan 2025 16:01:59 +0100 Subject: [PATCH 1/2] Reapply "[clang] Avoid re-evaluating field bitwidth (#117732)" This reverts commit 59bdea24b09bca9332a7092b583ebf377efb0d50. --- .../bugprone/NarrowingConversionsCheck.cpp| 2 +- .../bugprone/TooSmallLoopVariableCheck.cpp| 2 +- .../hicpp/MultiwayPathsCoveredCheck.cpp | 2 +- clang-tools-extra/clangd/Hover.cpp| 2 +- clang/include/clang/AST/Decl.h| 6 -- clang/include/clang/ASTMatchers/ASTMatchers.h | 3 +-- clang/lib/AST/ASTContext.cpp | 10 - clang/lib/AST/ByteCode/Interp.h | 10 - .../lib/AST/ByteCode/InterpBuiltinBitCast.cpp | 8 +++ clang/lib/AST/Decl.cpp| 16 +- clang/lib/AST/DeclCXX.cpp | 2 +- clang/lib/AST/Expr.cpp| 3 +-- clang/lib/AST/ExprConstant.cpp| 2 +- clang/lib/AST/Randstruct.cpp | 2 +- clang/lib/AST/RecordLayoutBuilder.cpp | 6 +++--- clang/lib/CodeGen/ABIInfo.cpp | 2 +- clang/lib/CodeGen/ABIInfoImpl.cpp | 2 +- clang/lib/CodeGen/CGCall.cpp | 6 +++--- clang/lib/CodeGen/CGClass.cpp | 2 +- clang/lib/CodeGen/CGDebugInfo.cpp | 8 +++ clang/lib/CodeGen/CGNonTrivialStruct.cpp | 6 +++--- clang/lib/CodeGen/CGObjCMac.cpp | 3 +-- clang/lib/CodeGen/CGObjCRuntime.cpp | 2 +- clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | 20 +- clang/lib/CodeGen/SwiftCallingConv.cpp| 2 +- clang/lib/CodeGen/Targets/LoongArch.cpp | 2 +- clang/lib/CodeGen/Targets/RISCV.cpp | 2 +- clang/lib/CodeGen/Targets/X86.cpp | 2 +- clang/lib/CodeGen/Targets/XCore.cpp | 2 +- .../Frontend/Rewrite/RewriteModernObjC.cpp| 3 ++- clang/lib/Sema/SemaChecking.cpp | 10 - clang/lib/Sema/SemaDecl.cpp | 21 ++- clang/lib/Sema/SemaDeclCXX.cpp| 6 +++--- clang/lib/Sema/SemaDeclObjC.cpp | 3 +-- clang/lib/Sema/SemaOverload.cpp | 2 +- clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 2 +- clang/tools/libclang/CXType.cpp | 2 +- clang/unittests/AST/ASTImporterTest.cpp | 4 ++-- 38 files changed, 96 insertions(+), 94 deletions(-) diff --git a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp index a950704208c73b..408390ebc70b64 100644 --- a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp @@ -38,7 +38,7 @@ AST_MATCHER(FieldDecl, hasIntBitwidth) { assert(Node.isBitField()); const ASTContext &Ctx = Node.getASTContext(); unsigned IntBitWidth = Ctx.getIntWidth(Ctx.IntTy); - unsigned CurrentBitWidth = Node.getBitWidthValue(Ctx); + unsigned CurrentBitWidth = Node.getBitWidthValue(); return IntBitWidth == CurrentBitWidth; } diff --git a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp index a73d46f01d9b2d..4ceeefb78ee824 100644 --- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp @@ -124,7 +124,7 @@ static MagnitudeBits calcMagnitudeBits(const ASTContext &Context, unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U; if (const auto *BitField = IntExpr->getSourceBitField()) { -unsigned BitFieldWidth = BitField->getBitWidthValue(Context); +unsigned BitFieldWidth = BitField->getBitWidthValue(); return {BitFieldWidth - SignedBits, BitFieldWidth}; } diff --git a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp index 47dafca2d03ff0..7028c3958f103e 100644 --- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp @@ -160,7 +160,7 @@ void MultiwayPathsCoveredCheck::handleSwitchWithoutDefault( } if (const auto *BitfieldDecl = Result.Nodes.getNodeAs("bitfield")) { - return twoPow(BitfieldDecl->getBitWidthValue(*Result.Context)); + return twoPow(BitfieldDecl->getBitWidthValue()); } return static_cast(0); diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 298fa79e3fd0ba..5e136d0e76ece7 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools
[clang-tools-extra] [clang-tidy] remove never used IgnoreCase in option (PR #122573)
https://github.com/HerrCai0907 created https://github.com/llvm/llvm-project/pull/122573 None >From d11ec4f698952dffba13856939774ec3fef6a137 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Sat, 11 Jan 2025 09:10:43 +0800 Subject: [PATCH] [clang-tidy] remove never used IgnoreCase in option --- .../clang-tidy/ClangTidyCheck.cpp | 15 ++-- clang-tools-extra/clang-tidy/ClangTidyCheck.h | 23 +-- .../clang-tidy/ClangTidyOptionsTest.cpp | 7 -- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index 4aa9fe228ee793..341343e90822b8 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -163,9 +163,10 @@ void ClangTidyCheck::OptionsView::store( store(Options, LocalName, Value ? StringRef("true") : StringRef("false")); } -std::optional ClangTidyCheck::OptionsView::getEnumInt( -StringRef LocalName, ArrayRef Mapping, bool CheckGlobal, -bool IgnoreCase) const { +std::optional +ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName, +ArrayRef Mapping, +bool CheckGlobal) const { if (!CheckGlobal && Context->getOptionsCollector()) Context->getOptionsCollector()->insert((NamePrefix + LocalName).str()); auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix, @@ -178,12 +179,10 @@ std::optional ClangTidyCheck::OptionsView::getEnumInt( StringRef Closest; unsigned EditDistance = 3; for (const auto &NameAndEnum : Mapping) { -if (IgnoreCase) { - if (Value.equals_insensitive(NameAndEnum.second)) -return NameAndEnum.first; -} else if (Value == NameAndEnum.second) { +if (Value == NameAndEnum.second) { return NameAndEnum.first; -} else if (Value.equals_insensitive(NameAndEnum.second)) { +} +if (Value.equals_insensitive(NameAndEnum.second)) { Closest = NameAndEnum.second; EditDistance = 0; continue; diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h index 7427aa9bf48f89..037526a0bd9af7 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -333,9 +333,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t, std::optional> -get(StringRef LocalName, bool IgnoreCase = false) const { +get(StringRef LocalName) const { if (std::optional ValueOr = - getEnumInt(LocalName, typeEraseMapping(), false, IgnoreCase)) + getEnumInt(LocalName, typeEraseMapping(), false)) return static_cast(*ValueOr); return std::nullopt; } @@ -353,9 +353,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. template -std::enable_if_t, T> get(StringRef LocalName, T Default, - bool IgnoreCase = false) const { - return get(LocalName, IgnoreCase).value_or(Default); +std::enable_if_t, T> get(StringRef LocalName, + T Default) const { + return get(LocalName).value_or(Default); } /// Read a named option from the ``Context`` and parse it as an @@ -373,9 +373,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t, std::optional> -getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const { +getLocalOrGlobal(StringRef LocalName) const { if (std::optional ValueOr = - getEnumInt(LocalName, typeEraseMapping(), true, IgnoreCase)) + getEnumInt(LocalName, typeEraseMapping(), true)) return static_cast(*ValueOr); return std::nullopt; } @@ -394,10 +394,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. template -std::enable_if_t, T> -getLocalOrGlobal(StringRef LocalName, T Default, - bool IgnoreCase = false) const { - return getLocalOrGlobal(LocalName, IgnoreCase).value_or(Default); +std::enable_if_t, T> getLocalOrGlobal(StringRef LocalName, +T Default) const { + return getLocalOrGlobal(LocalName).value_or(Default); } /// Stores an option with the chec
[clang-tools-extra] [clang-tidy] remove never used IgnoreCase in option (PR #122573)
llvmbot wrote: @llvm/pr-subscribers-clang-tidy @llvm/pr-subscribers-clang-tools-extra Author: Congcong Cai (HerrCai0907) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/122573.diff 3 Files Affected: - (modified) clang-tools-extra/clang-tidy/ClangTidyCheck.cpp (+7-8) - (modified) clang-tools-extra/clang-tidy/ClangTidyCheck.h (+11-12) - (modified) clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp (-7) ``diff diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index 4aa9fe228ee793..341343e90822b8 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -163,9 +163,10 @@ void ClangTidyCheck::OptionsView::store( store(Options, LocalName, Value ? StringRef("true") : StringRef("false")); } -std::optional ClangTidyCheck::OptionsView::getEnumInt( -StringRef LocalName, ArrayRef Mapping, bool CheckGlobal, -bool IgnoreCase) const { +std::optional +ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName, +ArrayRef Mapping, +bool CheckGlobal) const { if (!CheckGlobal && Context->getOptionsCollector()) Context->getOptionsCollector()->insert((NamePrefix + LocalName).str()); auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix, @@ -178,12 +179,10 @@ std::optional ClangTidyCheck::OptionsView::getEnumInt( StringRef Closest; unsigned EditDistance = 3; for (const auto &NameAndEnum : Mapping) { -if (IgnoreCase) { - if (Value.equals_insensitive(NameAndEnum.second)) -return NameAndEnum.first; -} else if (Value == NameAndEnum.second) { +if (Value == NameAndEnum.second) { return NameAndEnum.first; -} else if (Value.equals_insensitive(NameAndEnum.second)) { +} +if (Value.equals_insensitive(NameAndEnum.second)) { Closest = NameAndEnum.second; EditDistance = 0; continue; diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h index 7427aa9bf48f89..037526a0bd9af7 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -333,9 +333,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t, std::optional> -get(StringRef LocalName, bool IgnoreCase = false) const { +get(StringRef LocalName) const { if (std::optional ValueOr = - getEnumInt(LocalName, typeEraseMapping(), false, IgnoreCase)) + getEnumInt(LocalName, typeEraseMapping(), false)) return static_cast(*ValueOr); return std::nullopt; } @@ -353,9 +353,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. template -std::enable_if_t, T> get(StringRef LocalName, T Default, - bool IgnoreCase = false) const { - return get(LocalName, IgnoreCase).value_or(Default); +std::enable_if_t, T> get(StringRef LocalName, + T Default) const { + return get(LocalName).value_or(Default); } /// Read a named option from the ``Context`` and parse it as an @@ -373,9 +373,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t, std::optional> -getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const { +getLocalOrGlobal(StringRef LocalName) const { if (std::optional ValueOr = - getEnumInt(LocalName, typeEraseMapping(), true, IgnoreCase)) + getEnumInt(LocalName, typeEraseMapping(), true)) return static_cast(*ValueOr); return std::nullopt; } @@ -394,10 +394,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. template -std::enable_if_t, T> -getLocalOrGlobal(StringRef LocalName, T Default, - bool IgnoreCase = false) const { - return getLocalOrGlobal(LocalName, IgnoreCase).value_or(Default); +std::enable_if_t, T> getLocalOrGlobal(StringRef LocalName, +T Default) const { + return getLocalOrGlobal(LocalName).value_or(Default); } /// Stores an option with the check-local name \p LocalName with @@ -454,7 +453,7 @@ class ClangTidyCheck : public
[clang] [clang-tools-extra] [lldb] Reapply "[clang] Avoid re-evaluating field bitwidth" (PR #122289)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/122289 >From 59abbcc54700d5a8ba31ecd3b37431ffe86f7d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 9 Jan 2025 16:01:59 +0100 Subject: [PATCH 1/2] Reapply "[clang] Avoid re-evaluating field bitwidth (#117732)" This reverts commit 59bdea24b09bca9332a7092b583ebf377efb0d50. --- .../bugprone/NarrowingConversionsCheck.cpp| 2 +- .../bugprone/TooSmallLoopVariableCheck.cpp| 2 +- .../hicpp/MultiwayPathsCoveredCheck.cpp | 2 +- clang-tools-extra/clangd/Hover.cpp| 2 +- clang/include/clang/AST/Decl.h| 6 -- clang/include/clang/ASTMatchers/ASTMatchers.h | 3 +-- clang/lib/AST/ASTContext.cpp | 10 - clang/lib/AST/ByteCode/Interp.h | 10 - .../lib/AST/ByteCode/InterpBuiltinBitCast.cpp | 8 +++ clang/lib/AST/Decl.cpp| 16 +- clang/lib/AST/DeclCXX.cpp | 2 +- clang/lib/AST/Expr.cpp| 3 +-- clang/lib/AST/ExprConstant.cpp| 2 +- clang/lib/AST/Randstruct.cpp | 2 +- clang/lib/AST/RecordLayoutBuilder.cpp | 6 +++--- clang/lib/CodeGen/ABIInfo.cpp | 2 +- clang/lib/CodeGen/ABIInfoImpl.cpp | 2 +- clang/lib/CodeGen/CGCall.cpp | 6 +++--- clang/lib/CodeGen/CGClass.cpp | 2 +- clang/lib/CodeGen/CGDebugInfo.cpp | 8 +++ clang/lib/CodeGen/CGNonTrivialStruct.cpp | 6 +++--- clang/lib/CodeGen/CGObjCMac.cpp | 3 +-- clang/lib/CodeGen/CGObjCRuntime.cpp | 2 +- clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | 20 +- clang/lib/CodeGen/SwiftCallingConv.cpp| 2 +- clang/lib/CodeGen/Targets/LoongArch.cpp | 2 +- clang/lib/CodeGen/Targets/RISCV.cpp | 2 +- clang/lib/CodeGen/Targets/X86.cpp | 2 +- clang/lib/CodeGen/Targets/XCore.cpp | 2 +- .../Frontend/Rewrite/RewriteModernObjC.cpp| 3 ++- clang/lib/Sema/SemaChecking.cpp | 10 - clang/lib/Sema/SemaDecl.cpp | 21 ++- clang/lib/Sema/SemaDeclCXX.cpp| 6 +++--- clang/lib/Sema/SemaDeclObjC.cpp | 3 +-- clang/lib/Sema/SemaOverload.cpp | 2 +- clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 2 +- clang/tools/libclang/CXType.cpp | 2 +- clang/unittests/AST/ASTImporterTest.cpp | 4 ++-- 38 files changed, 96 insertions(+), 94 deletions(-) diff --git a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp index a950704208c73b..408390ebc70b64 100644 --- a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp @@ -38,7 +38,7 @@ AST_MATCHER(FieldDecl, hasIntBitwidth) { assert(Node.isBitField()); const ASTContext &Ctx = Node.getASTContext(); unsigned IntBitWidth = Ctx.getIntWidth(Ctx.IntTy); - unsigned CurrentBitWidth = Node.getBitWidthValue(Ctx); + unsigned CurrentBitWidth = Node.getBitWidthValue(); return IntBitWidth == CurrentBitWidth; } diff --git a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp index a73d46f01d9b2d..4ceeefb78ee824 100644 --- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp @@ -124,7 +124,7 @@ static MagnitudeBits calcMagnitudeBits(const ASTContext &Context, unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U; if (const auto *BitField = IntExpr->getSourceBitField()) { -unsigned BitFieldWidth = BitField->getBitWidthValue(Context); +unsigned BitFieldWidth = BitField->getBitWidthValue(); return {BitFieldWidth - SignedBits, BitFieldWidth}; } diff --git a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp index 47dafca2d03ff0..7028c3958f103e 100644 --- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp @@ -160,7 +160,7 @@ void MultiwayPathsCoveredCheck::handleSwitchWithoutDefault( } if (const auto *BitfieldDecl = Result.Nodes.getNodeAs("bitfield")) { - return twoPow(BitfieldDecl->getBitWidthValue(*Result.Context)); + return twoPow(BitfieldDecl->getBitWidthValue()); } return static_cast(0); diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 298fa79e3fd0ba..5e136d0e76ece7 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools
[clang] [Driver][SPIR-V] Use consistent tools to convert between text and binary form (PR #120266)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` running on `premerge-linux-1` while building `clang` at step 7 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/19236 Here is the relevant piece of the build log for the reference ``` Step 7 (test-build-unified-tree-check-all) failure: test (failure) TEST 'Clang :: Driver/spirv-openmp-toolchain.c' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 1: /build/buildbot/premerge-monolithic-linux/build/bin/clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=spirv64-intel --libomptarget-spirv-bc-path=/build/buildbot/premerge-monolithic-linux/build/tools/clang/test/Driver/Output/spirv-openmp-toolchain.c.tmp/ -nogpulib /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c 2>&1 | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c + /build/buildbot/premerge-monolithic-linux/build/bin/clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=spirv64-intel --libomptarget-spirv-bc-path=/build/buildbot/premerge-monolithic-linux/build/tools/clang/test/Driver/Output/spirv-openmp-toolchain.c.tmp/ -nogpulib /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c + /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c RUN: at line 12: /build/buildbot/premerge-monolithic-linux/build/bin/clang -ccc-print-phases --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=spirv64-intel /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c 2>&1 | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck --check-prefix=CHECK-PHASES /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c + /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck --check-prefix=CHECK-PHASES /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c + /build/buildbot/premerge-monolithic-linux/build/bin/clang -ccc-print-phases --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=spirv64-intel /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c RUN: at line 31: /build/buildbot/premerge-monolithic-linux/build/bin/clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=spirv64-intel -nogpulib /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c 2>&1 | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c --check-prefix=CHECK-BINDINGS + /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c --check-prefix=CHECK-BINDINGS + /build/buildbot/premerge-monolithic-linux/build/bin/clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=spirv64-intel -nogpulib /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c RUN: at line 32: /build/buildbot/premerge-monolithic-linux/build/bin/clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=spirv64-intel -nogpulib /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c 2>&1 | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c --check-prefix=CHECK-BINDINGS + /build/buildbot/premerge-monolithic-linux/build/bin/clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=spirv64-intel -nogpulib /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c + /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c --check-prefix=CHECK-BINDINGS RUN: at line 41: /build/buildbot/premerge-monolithic-linux/build/bin/clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -save-temps -fopenmp=libomp -fopenmp-targets=spirv64-intel -nogpulib /build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Driver/spirv-openmp-toolchain.c 2>&1 | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/cl
[clang] [libclang] Add API to query more information about base classes. (PR #120300)
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/120300 >From 0d4bcf69c57457ba79af9069ae60c6de8ee45498 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 10 Dec 2024 15:23:55 -0800 Subject: [PATCH] [cindex] Add API to query more information about base classes. The first API is clang_visitCXXBaseClasses: this allows visiting the base classes without going through the generic child visitor (which is awkward, and doesn't work for template instantiations). The second API is clang_getOffsetOfBase; this allows computing the offset of a base in the class layout, the same way clang_Cursor_getOffsetOfField compues the offset of a field. Also, add a Python binding for the existing function clang_isVirtualBase. --- clang/bindings/python/clang/cindex.py | 25 ++ .../bindings/python/tests/cindex/test_type.py | 25 ++ clang/docs/ReleaseNotes.rst | 10 ++ clang/include/clang-c/Index.h | 29 clang/tools/libclang/CIndexCXX.cpp| 27 +++ clang/tools/libclang/CXType.cpp | 34 +++ clang/tools/libclang/libclang.map | 2 ++ 7 files changed, 152 insertions(+) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 710259de855f9b..806e1b40f3c9e1 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2133,6 +2133,14 @@ def get_field_offsetof(self): """Returns the offsetof the FIELD_DECL pointed by this Cursor.""" return conf.lib.clang_Cursor_getOffsetOfField(self) # type: ignore [no-any-return] +def get_base_offsetof(self, parent): +"""Returns the offsetof the CXX_BASE_SPECIFIER pointed by this Cursor.""" +return conf.lib.clang_getOffsetOfBase(parent, self) # type: ignore [no-any-return] + +def is_virtual_base(self): +"""Returns whether the CXX_BASE_SPECIFIER pointed by this Cursor is virtual.""" +return conf.lib.clang_isVirtualBase(self) # type: ignore [no-any-return] + def is_anonymous(self): """ Check whether this is a record type without a name, or a field where @@ -2687,6 +2695,21 @@ def visitor(field, children): conf.lib.clang_Type_visitFields(self, fields_visit_callback(visitor), fields) return iter(fields) +def get_bases(self): +"""Return an iterator for accessing the base classes of this type.""" + +def visitor(base, children): +assert base != conf.lib.clang_getNullCursor() + +# Create reference to TU so it isn't GC'd before Cursor. +base._tu = self._tu +bases.append(base) +return 1 # continue + +bases: list[Cursor] = [] +conf.lib.clang_visitCXXBaseClasses(self, fields_visit_callback(visitor), bases) +return iter(bases) + def get_exception_specification_kind(self): """ Return the kind of the exception specification; a value from @@ -3940,6 +3963,7 @@ def set_property(self, property, value): ("clang_getNumDiagnosticsInSet", [c_object_p], c_uint), ("clang_getNumElements", [Type], c_longlong), ("clang_getNumOverloadedDecls", [Cursor], c_uint), +("clang_getOffsetOfBase", [Cursor, Cursor], c_longlong), ("clang_getOverloadedDecl", [Cursor, c_uint], Cursor), ("clang_getPointeeType", [Type], Type), ("clang_getRange", [SourceLocation, SourceLocation], SourceRange), @@ -3992,6 +4016,7 @@ def set_property(self, property, value): [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint)], ), ("clang_visitChildren", [Cursor, cursor_visit_callback, py_object], c_uint), +("clang_visitCXXBaseClasses", [Type, fields_visit_callback, py_object], c_uint), ("clang_Cursor_getNumArguments", [Cursor], c_int), ("clang_Cursor_getArgument", [Cursor, c_uint], Cursor), ("clang_Cursor_getNumTemplateArguments", [Cursor], c_int), diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py index f39da8b5faf297..db7dc6458581e6 100644 --- a/clang/bindings/python/tests/cindex/test_type.py +++ b/clang/bindings/python/tests/cindex/test_type.py @@ -534,3 +534,28 @@ def test_pretty(self): self.assertEqual(f.type.get_canonical().pretty_printed(pp), "X") pp.set_property(PrintingPolicyProperty.SuppressTagKeyword, False) self.assertEqual(f.type.get_canonical().pretty_printed(pp), "struct X") + +def test_base_classes(self): +source = """ +class A { int a; }; +class B { int b; }; +class C { int c; }; +template +class Template : public A, public B, virtual C { +}; +Template instance; +int bar; +""" +tu = get_tu(source, lang="cpp") +cursor = get_cursor(tu, "instance") +cursor_typ
[clang] [libclang] Add API to query more information about base classes. (PR #120300)
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/120300 >From ff0f4b551de077ee07331ed30410b102abb06c09 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 10 Dec 2024 15:23:55 -0800 Subject: [PATCH] [cindex] Add API to query more information about base classes. The first API is clang_visitCXXBaseClasses: this allows visiting the base classes without going through the generic child visitor (which is awkward, and doesn't work for template instantiations). The second API is clang_getOffsetOfBase; this allows computing the offset of a base in the class layout, the same way clang_Cursor_getOffsetOfField compues the offset of a field. Also, add a Python binding for the existing function clang_isVirtualBase. --- clang/bindings/python/clang/cindex.py | 25 + .../bindings/python/tests/cindex/test_type.py | 25 + clang/docs/ReleaseNotes.rst | 10 ++ clang/include/clang-c/Index.h | 36 +-- clang/tools/libclang/CIndexCXX.cpp| 27 ++ clang/tools/libclang/CXType.cpp | 34 ++ clang/tools/libclang/libclang.map | 2 ++ 7 files changed, 157 insertions(+), 2 deletions(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 710259de855f9b..806e1b40f3c9e1 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2133,6 +2133,14 @@ def get_field_offsetof(self): """Returns the offsetof the FIELD_DECL pointed by this Cursor.""" return conf.lib.clang_Cursor_getOffsetOfField(self) # type: ignore [no-any-return] +def get_base_offsetof(self, parent): +"""Returns the offsetof the CXX_BASE_SPECIFIER pointed by this Cursor.""" +return conf.lib.clang_getOffsetOfBase(parent, self) # type: ignore [no-any-return] + +def is_virtual_base(self): +"""Returns whether the CXX_BASE_SPECIFIER pointed by this Cursor is virtual.""" +return conf.lib.clang_isVirtualBase(self) # type: ignore [no-any-return] + def is_anonymous(self): """ Check whether this is a record type without a name, or a field where @@ -2687,6 +2695,21 @@ def visitor(field, children): conf.lib.clang_Type_visitFields(self, fields_visit_callback(visitor), fields) return iter(fields) +def get_bases(self): +"""Return an iterator for accessing the base classes of this type.""" + +def visitor(base, children): +assert base != conf.lib.clang_getNullCursor() + +# Create reference to TU so it isn't GC'd before Cursor. +base._tu = self._tu +bases.append(base) +return 1 # continue + +bases: list[Cursor] = [] +conf.lib.clang_visitCXXBaseClasses(self, fields_visit_callback(visitor), bases) +return iter(bases) + def get_exception_specification_kind(self): """ Return the kind of the exception specification; a value from @@ -3940,6 +3963,7 @@ def set_property(self, property, value): ("clang_getNumDiagnosticsInSet", [c_object_p], c_uint), ("clang_getNumElements", [Type], c_longlong), ("clang_getNumOverloadedDecls", [Cursor], c_uint), +("clang_getOffsetOfBase", [Cursor, Cursor], c_longlong), ("clang_getOverloadedDecl", [Cursor, c_uint], Cursor), ("clang_getPointeeType", [Type], Type), ("clang_getRange", [SourceLocation, SourceLocation], SourceRange), @@ -3992,6 +4016,7 @@ def set_property(self, property, value): [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint)], ), ("clang_visitChildren", [Cursor, cursor_visit_callback, py_object], c_uint), +("clang_visitCXXBaseClasses", [Type, fields_visit_callback, py_object], c_uint), ("clang_Cursor_getNumArguments", [Cursor], c_int), ("clang_Cursor_getArgument", [Cursor, c_uint], Cursor), ("clang_Cursor_getNumTemplateArguments", [Cursor], c_int), diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py index f39da8b5faf297..db7dc6458581e6 100644 --- a/clang/bindings/python/tests/cindex/test_type.py +++ b/clang/bindings/python/tests/cindex/test_type.py @@ -534,3 +534,28 @@ def test_pretty(self): self.assertEqual(f.type.get_canonical().pretty_printed(pp), "X") pp.set_property(PrintingPolicyProperty.SuppressTagKeyword, False) self.assertEqual(f.type.get_canonical().pretty_printed(pp), "struct X") + +def test_base_classes(self): +source = """ +class A { int a; }; +class B { int b; }; +class C { int c; }; +template +class Template : public A, public B, virtual C { +}; +Template instance; +int bar; +""" +tu = get_tu(source, lang="cpp") +cursor = get_cursor(tu, "instance") +
[clang] [clang-tools-extra] [lldb] Reapply "[clang] Avoid re-evaluating field bitwidth" (PR #122289)
Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: https://github.com/Michael137 commented: LLDB changes LGTM https://github.com/llvm/llvm-project/pull/122289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang] Add API to query more information about base classes. (PR #120300)
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/120300 >From 12ad982b984a4e533db4220332f6edbf4b4903a2 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 10 Dec 2024 15:23:55 -0800 Subject: [PATCH] [cindex] Add API to query more information about base classes. The first API is clang_visitCXXBaseClasses: this allows visiting the base classes without going through the generic child visitor (which is awkward, and doesn't work for template instantiations). The second API is clang_getOffsetOfBase; this allows computing the offset of a base in the class layout, the same way clang_Cursor_getOffsetOfField compues the offset of a field. Also, add a Python binding for the existing function clang_isVirtualBase. --- clang/bindings/python/clang/cindex.py | 25 + .../bindings/python/tests/cindex/test_type.py | 25 + clang/docs/ReleaseNotes.rst | 10 ++ clang/include/clang-c/Index.h | 36 +-- clang/tools/libclang/CIndexCXX.cpp| 27 ++ clang/tools/libclang/CXType.cpp | 34 ++ clang/tools/libclang/libclang.map | 2 ++ 7 files changed, 157 insertions(+), 2 deletions(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 710259de855f9b..806e1b40f3c9e1 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2133,6 +2133,14 @@ def get_field_offsetof(self): """Returns the offsetof the FIELD_DECL pointed by this Cursor.""" return conf.lib.clang_Cursor_getOffsetOfField(self) # type: ignore [no-any-return] +def get_base_offsetof(self, parent): +"""Returns the offsetof the CXX_BASE_SPECIFIER pointed by this Cursor.""" +return conf.lib.clang_getOffsetOfBase(parent, self) # type: ignore [no-any-return] + +def is_virtual_base(self): +"""Returns whether the CXX_BASE_SPECIFIER pointed by this Cursor is virtual.""" +return conf.lib.clang_isVirtualBase(self) # type: ignore [no-any-return] + def is_anonymous(self): """ Check whether this is a record type without a name, or a field where @@ -2687,6 +2695,21 @@ def visitor(field, children): conf.lib.clang_Type_visitFields(self, fields_visit_callback(visitor), fields) return iter(fields) +def get_bases(self): +"""Return an iterator for accessing the base classes of this type.""" + +def visitor(base, children): +assert base != conf.lib.clang_getNullCursor() + +# Create reference to TU so it isn't GC'd before Cursor. +base._tu = self._tu +bases.append(base) +return 1 # continue + +bases: list[Cursor] = [] +conf.lib.clang_visitCXXBaseClasses(self, fields_visit_callback(visitor), bases) +return iter(bases) + def get_exception_specification_kind(self): """ Return the kind of the exception specification; a value from @@ -3940,6 +3963,7 @@ def set_property(self, property, value): ("clang_getNumDiagnosticsInSet", [c_object_p], c_uint), ("clang_getNumElements", [Type], c_longlong), ("clang_getNumOverloadedDecls", [Cursor], c_uint), +("clang_getOffsetOfBase", [Cursor, Cursor], c_longlong), ("clang_getOverloadedDecl", [Cursor, c_uint], Cursor), ("clang_getPointeeType", [Type], Type), ("clang_getRange", [SourceLocation, SourceLocation], SourceRange), @@ -3992,6 +4016,7 @@ def set_property(self, property, value): [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint)], ), ("clang_visitChildren", [Cursor, cursor_visit_callback, py_object], c_uint), +("clang_visitCXXBaseClasses", [Type, fields_visit_callback, py_object], c_uint), ("clang_Cursor_getNumArguments", [Cursor], c_int), ("clang_Cursor_getArgument", [Cursor, c_uint], Cursor), ("clang_Cursor_getNumTemplateArguments", [Cursor], c_int), diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py index f39da8b5faf297..db7dc6458581e6 100644 --- a/clang/bindings/python/tests/cindex/test_type.py +++ b/clang/bindings/python/tests/cindex/test_type.py @@ -534,3 +534,28 @@ def test_pretty(self): self.assertEqual(f.type.get_canonical().pretty_printed(pp), "X") pp.set_property(PrintingPolicyProperty.SuppressTagKeyword, False) self.assertEqual(f.type.get_canonical().pretty_printed(pp), "struct X") + +def test_base_classes(self): +source = """ +class A { int a; }; +class B { int b; }; +class C { int c; }; +template +class Template : public A, public B, virtual C { +}; +Template instance; +int bar; +""" +tu = get_tu(source, lang="cpp") +cursor = get_cursor(tu, "instance") +
[clang] [llvm] [X86] Extend kCFI with a 3-bit arity indicator (PR #121070)
@@ -254,6 +254,7 @@ FEATURE(is_trivially_constructible, LangOpts.CPlusPlus) FEATURE(is_trivially_copyable, LangOpts.CPlusPlus) FEATURE(is_union, LangOpts.CPlusPlus) FEATURE(kcfi, LangOpts.Sanitize.has(SanitizerKind::KCFI)) +FEATURE(kcfi_x86_arity, LangOpts.Sanitize.has(SanitizerKind::KCFI)) samitolvanen wrote: Encoding arity information in the register argument solves the hash compatibility issue, so I definitely prefer this approach over https://github.com/llvm/llvm-project/pull/117121. As you noted, the FineIBT patching code still needs to know whether both compilers emit arity information, and while using `__has_feature` in C should be sufficient, how would the rustc feature test look like? A quick search didn't find any Kconfig examples for this. I assume we would need a Kconfig variable to pass this information to C code, but perhaps there are better options? https://github.com/llvm/llvm-project/pull/121070 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang] Add API to query more information about base classes. (PR #120300)
efriedma-quic wrote: Addressed review comments https://github.com/llvm/llvm-project/pull/120300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add -fwrapv-pointer flag (PR #122486)
efriedma-quic wrote: I'm tempted to say we should just treat -fwrapv/-fwrapv-pointer/-fno-strict-overflow as aliases for each other. I don't think anyone using -fwrapv is going to be happy that we're turning on overflow optimizations. https://github.com/llvm/llvm-project/pull/122486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Warn when using msan on Android (PR #122540)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/122540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= Message-ID: In-Reply-To: https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/118466 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CMake] Add a cache file for building a highly-optimized LLVM toolchain (PR #117802)
@@ -0,0 +1,17 @@ +# Stage 1 +# * Build an LTO optimized libcxx, so we can staticially link it into stage 2 +# clang. + + +set(CMAKE_BUILD_TYPE Release CACHE STRING "") +set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") +set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "" FORCE) +set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "" FORCE) + +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage2-instrumented.cmake CACHE BOOL "") +set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE BOOL "") tstellar wrote: No, it's not. This needs to be set in the stage1 config: https://github.com/llvm/llvm-project/blob/main/clang/CMakeLists.txt#L597 https://github.com/llvm/llvm-project/pull/117802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b302633 - [libclang] Allow using PrintingPolicy with types (#122386)
Author: Eli Friedman Date: 2025-01-10T15:11:19-08:00 New Revision: b302633bc5b93118b8a0bcaabfe0957294b9e894 URL: https://github.com/llvm/llvm-project/commit/b302633bc5b93118b8a0bcaabfe0957294b9e894 DIFF: https://github.com/llvm/llvm-project/commit/b302633bc5b93118b8a0bcaabfe0957294b9e894.diff LOG: [libclang] Allow using PrintingPolicy with types (#122386) This allows controlling pretty-printing of types the same way it works with cursors. Added: Modified: clang/bindings/python/clang/cindex.py clang/bindings/python/tests/cindex/test_type.py clang/docs/ReleaseNotes.rst clang/include/clang-c/Index.h clang/tools/libclang/CXType.cpp clang/tools/libclang/libclang.map Removed: diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 7caf0bbfd722af..710259de855f9b 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2701,6 +2701,10 @@ def spelling(self): """Retrieve the spelling of this Type.""" return _CXString.from_result(conf.lib.clang_getTypeSpelling(self)) +def pretty_printed(self, policy): +"""Pretty-prints this Type with the given PrintingPolicy""" +return _CXString.from_result(conf.lib.clang_getTypePrettyPrinted(self, policy)) + def __eq__(self, other): if type(other) != type(self): return False @@ -3955,6 +3959,7 @@ def set_property(self, property, value): ("clang_getTypedefDeclUnderlyingType", [Cursor], Type), ("clang_getTypedefName", [Type], _CXString), ("clang_getTypeKindSpelling", [c_uint], _CXString), +("clang_getTypePrettyPrinted", [Type, PrintingPolicy], _CXString), ("clang_getTypeSpelling", [Type], _CXString), ("clang_hashCursor", [Cursor], c_uint), ("clang_isAttribute", [CursorKind], bool), diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py index e1d8c2aad1c3a4..f39da8b5faf297 100644 --- a/clang/bindings/python/tests/cindex/test_type.py +++ b/clang/bindings/python/tests/cindex/test_type.py @@ -1,6 +1,14 @@ import os -from clang.cindex import Config, CursorKind, RefQualifierKind, TranslationUnit, TypeKind +from clang.cindex import ( +Config, +CursorKind, +PrintingPolicy, +PrintingPolicyProperty, +RefQualifierKind, +TranslationUnit, +TypeKind, +) if "CLANG_LIBRARY_PATH" in os.environ: Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"]) @@ -517,3 +525,12 @@ class Template { # Variable without a template argument. cursor = get_cursor(tu, "bar") self.assertEqual(cursor.get_num_template_arguments(), -1) + +def test_pretty(self): +tu = get_tu("struct X {}; X x;", lang="cpp") +f = get_cursor(tu, "x") + +pp = PrintingPolicy.create(f) +self.assertEqual(f.type.get_canonical().pretty_printed(pp), "X") +pp.set_property(PrintingPolicyProperty.SuppressTagKeyword, False) +self.assertEqual(f.type.get_canonical().pretty_printed(pp), "struct X") diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 5a48d6fbc01fa3..190843f2aa6c96 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -1182,6 +1182,8 @@ libclang - Add ``clang_isBeforeInTranslationUnit``. Given two source locations, it determines whether the first one comes strictly before the second in the source code. +- Add ``clang_getTypePrettyPrinted``. It allows controlling the PrintingPolicy used + to pretty-print a type. Static Analyzer --- @@ -1322,10 +1324,13 @@ Sanitizers Python Binding Changes -- - Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``. -- Added bindings for ``clang_getCursorPrettyPrinted`` and related functions, - which allow changing the formatting of pretty-printed code. -- Added binding for ``clang_Cursor_isAnonymousRecordDecl``, which allows checking if - a declaration is an anonymous union or anonymous struct. +- Added ``Cursor.pretty_printed``, a binding for ``clang_getCursorPrettyPrinted``, + and related functions, which allow changing the formatting of pretty-printed code. +- Added ``Cursor.is_anonymous_record_decl``, a binding for + ``clang_Cursor_isAnonymousRecordDecl``, which allows checking if a + declaration is an anonymous union or anonymous struct. +- Added ``Type.pretty_printed`, a binding for ``clang_getTypePrettyPrinted``, + which allows changing the formatting of pretty-printed types. OpenMP Support -- diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 63d266dc60ec73..ad64497ceb8025 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -4182,6 +4182,14 @@ CINDEX_LINKAGE void clang_PrintingPolicy_disp
[clang] [libclang] Allow using PrintingPolicy with types (PR #122386)
https://github.com/efriedma-quic closed https://github.com/llvm/llvm-project/pull/122386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix uefi target for aarch64 & x86_64 (PR #120632)
@@ -713,8 +713,8 @@ class LLVM_LIBRARY_VISIBILITY X86_64TargetInfo : public X86TargetInfo { X86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : X86TargetInfo(Triple, Opts) { const bool IsX32 = getTriple().isX32(); -bool IsWinCOFF = -getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); +bool IsWinCOFF = (getTriple().isOSWindows() || getTriple().isUEFI()) && + getTriple().isOSBinFormatCOFF(); LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 32 : 64; frobtech wrote: Note that some of these are things we'll eventually want command-line switch flexibility for. Matching Windows all around is the right default. But structurally, keep in mind that these are no things intrinsic to the UEFI target per se but to a particular set of C/C++ API expectations that future users (i.e. me) will want to have the option of configuring to be consistent with other norms rather than Windows norms. https://github.com/llvm/llvm-project/pull/120632 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add release note for pointer overflow optimization change (PR #122462)
https://github.com/hstk30-hw approved this pull request. https://github.com/llvm/llvm-project/pull/122462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [APINotes] Avoid duplicated attributes for class template instantiations (PR #122516)
https://github.com/fahadnayyar approved this pull request. https://github.com/llvm/llvm-project/pull/122516 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [nfc][ubsan] Add local-bounds test (PR #122415)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/122415 >From 0021fbc549fcc8c27b184af163ba963c31acc0c1 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Thu, 9 Jan 2025 20:26:03 -0800 Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 [skip ci] --- clang/test/CodeGen/allow-ubsan-check.c | 337 +++-- 1 file changed, 145 insertions(+), 192 deletions(-) diff --git a/clang/test/CodeGen/allow-ubsan-check.c b/clang/test/CodeGen/allow-ubsan-check.c index 5232d240854666..76dd9f653309cb 100644 --- a/clang/test/CodeGen/allow-ubsan-check.c +++ b/clang/test/CodeGen/allow-ubsan-check.c @@ -1,86 +1,65 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=TRAP -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=RECOVER +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=TRAP +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=RECOVER -// CHECK-LABEL: define dso_local i32 @div( -// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] { -// CHECK-NEXT: entry: -// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4 -// CHECK-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4 -// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4 -// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[Y_ADDR]], align 4 -// CHECK-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0, !nosanitize [[META2:![0-9]+]] -// CHECK-NEXT:[[TMP3:%.*]] = icmp ne i32 [[TMP0]], -2147483648, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP4:%.*]] = icmp ne i32 [[TMP1]], -1, !nosanitize [[META2]] -// CHECK-NEXT:[[OR:%.*]] = or i1 [[TMP3]], [[TMP4]], !nosanitize [[META2]] -// CHECK-NEXT:[[TMP5:%.*]] = and i1 [[TMP2]], [[OR]], !nosanitize [[META2]] -// CHECK-NEXT:[[TMP6:%.*]] = call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]] -// CHECK-NEXT:[[TMP7:%.*]] = xor i1 [[TMP6]], true, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP8:%.*]] = or i1 [[TMP5]], [[TMP7]], !nosanitize [[META2]] -// CHECK-NEXT:br i1 [[TMP8]], label [[CONT:%.*]], label [[HANDLER_DIVREM_OVERFLOW:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]] -// CHECK: handler.divrem_overflow: -// CHECK-NEXT:[[TMP9:%.*]] = zext i32 [[TMP0]] to i64, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP10:%.*]] = zext i32 [[TMP1]] to i64, !nosanitize [[META2]] -// CHECK-NEXT:call void @__ubsan_handle_divrem_overflow_abort(ptr @[[GLOB1:[0-9]+]], i64 [[TMP9]], i64 [[TMP10]]) #[[ATTR4:[0-9]+]], !nosanitize [[META2]] +// CHECK-LABEL: define dso_local noundef i32 @div( +// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT:[[TMP0:%.*]] = icmp eq i32 [[Y]], 0, !nosanitize [[META2:![0-9]+]] +// CHECK-NEXT:[[TMP1:%.*]] = icmp eq i32 [[X]], -2147483648, !nosanitize [[META2]] +// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i32 [[Y]], -1, !nosanitize [[META2]] +// CHECK-NEXT:[[OR_NOT5:%.*]] = and i1 [[TMP1]], [[TMP2]] +// CHECK-NEXT:[[DOTNOT3:%.*]] = or i1 [[TMP0]], [[OR_NOT5]] +// CHECK-NEXT:[[TMP3:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]] +// CHECK-NEXT:[[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]] +// CHECK-NEXT:br i1 [[DOTNOT1]], labe
[clang] [nfc][ubsan] Add local-bounds test (PR #122415)
https://github.com/vitalybuka closed https://github.com/llvm/llvm-project/pull/122415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFCI][BoundsChecking] Apply nosanitize on local-bounds instrumentation (PR #122416)
https://github.com/vitalybuka edited https://github.com/llvm/llvm-project/pull/122416 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 99d0780 - [nfc][ubsan] Add local-bounds test (#122415)
Author: Vitaly Buka Date: 2025-01-10T17:47:35-08:00 New Revision: 99d0780f050c830c046c6f8790821880ab7c71f5 URL: https://github.com/llvm/llvm-project/commit/99d0780f050c830c046c6f8790821880ab7c71f5 DIFF: https://github.com/llvm/llvm-project/commit/99d0780f050c830c046c6f8790821880ab7c71f5.diff LOG: [nfc][ubsan] Add local-bounds test (#122415) Show that @llvm.allow.ubsan.check is not used yet. Added: Modified: clang/test/CodeGen/allow-ubsan-check.c Removed: diff --git a/clang/test/CodeGen/allow-ubsan-check.c b/clang/test/CodeGen/allow-ubsan-check.c index 3981efe10a5bcc..a994e700115ff7 100644 --- a/clang/test/CodeGen/allow-ubsan-check.c +++ b/clang/test/CodeGen/allow-ubsan-check.c @@ -1,7 +1,7 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=TR -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=REC +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null,local-bounds -mllvm -ubsan-guard-checks | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null,local-bounds -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null,local-bounds | FileCheck %s --check-prefixes=TR +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null,local-bounds -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null,local-bounds | FileCheck %s --check-prefixes=REC // CHECK-LABEL: define dso_local noundef i32 @div( @@ -18,7 +18,7 @@ // CHECK: [[HANDLER_DIVREM_OVERFLOW]]: // CHECK-NEXT:[[TMP4:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]] // CHECK-NEXT:[[TMP5:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]] -// CHECK-NEXT:tail call void @__ubsan_handle_divrem_overflow_abort(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR4:[0-9]+]], !nosanitize [[META2]] +// CHECK-NEXT:tail call void @__ubsan_handle_divrem_overflow_abort(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR6:[0-9]+]], !nosanitize [[META2]] // CHECK-NEXT:unreachable, !nosanitize [[META2]] // CHECK: [[CONT]]: // CHECK-NEXT:[[DIV:%.*]] = sdiv i32 [[X]], [[Y]] @@ -36,7 +36,7 @@ // TR-NEXT:[[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]] // TR-NEXT:br i1 [[DOTNOT1]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]] // TR: [[TRAP]]: -// TR-NEXT:tail call void @llvm.ubsantrap(i8 3) #[[ATTR4:[0-9]+]], !nosanitize [[META2]] +// TR-NEXT:tail call void @llvm.ubsantrap(i8 3) #[[ATTR5:[0-9]+]], !nosanitize [[META2]] // TR-NEXT:unreachable, !nosanitize [[META2]] // TR: [[CONT]]: // TR-NEXT:[[DIV:%.*]] = sdiv i32 [[X]], [[Y]] @@ -56,7 +56,7 @@ // REC: [[HANDLER_DIVREM_OVERFLOW]]: // REC-NEXT:[[TMP4:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]] // REC-NEXT:[[TMP5:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]] -// REC-NEXT:tail call void @__ubsan_handle_divrem_overflow(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR4:[0-9]+]], !nosanitize [[META2]] +// REC-NEXT:tail call void @__ubsan_handle_divrem_overflow(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR6:[0-9]+]], !nosanitize [[META2]] // REC-NEXT:br label %[[CONT]], !nosanitize [[META2]] // REC: [[CONT]]: // REC-NEXT:[[DIV:%.*]] = sdiv i32 [[X]], [[Y]] @@ -74,7 +74,7 @@ int div(int x, int y) { // CHECK-NEXT:[[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]] // CHECK-NEXT:br i1 [[DOTNOT1]], label %[[HANDLER_TYPE_MISMATCH:.*]], label %[[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]] // CHECK: [[HANDLER_TYPE_MISMATCH]]: -// CHECK-NEXT:tail call void @__ubsan_handle_type_mismatch_v1_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR4]], !nosanitize [[META2]] +// CHECK-NEXT:tail call void @__ubsan_handle_type_mismatch_v1_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR6]], !nosanitize [[META2]] // CHECK-NEXT:unreachable, !nosanit
[clang] [Darwin][Driver][clang] arm64-apple-none-macho is missing the Apple macros from arm-apple-none-macho (PR #122427)
@@ -243,6 +247,8 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, case llvm::Triple::thumbeb: ian-twilightcoder wrote: Yeah, that's why I was asking if we should just always use Darwin for MachO instead of inconsistently using Darwin for some archs and was-AArch64leTargetInfo-now-AppleMachO for others. Keeping it inconsistent is probably the smaller/safer change, but the inconsistency does bother me. https://github.com/llvm/llvm-project/pull/122427 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver][OpenBSD] Remove riscv32 bit (PR #122525)
https://github.com/devnexen approved this pull request. https://github.com/llvm/llvm-project/pull/122525 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Warn when using msan on Android (PR #122540)
https://github.com/Sharjeel-Khan created https://github.com/llvm/llvm-project/pull/122540 Msan is not supported on Android as mentioned in google/sanitizers#1381. We proactively give the warning saying it is unsupported to fix android/ndk#1958. >From 4a1f619925d0b2e1003ffb69c5bcc2a28aba63c3 Mon Sep 17 00:00:00 2001 From: Sharjeel Khan Date: Fri, 10 Jan 2025 20:07:52 + Subject: [PATCH] Error when using msan on Android Msan is not supported on Android as mentioned in google/sanitizers#1381. We proactively give the warning saying it is unsupported to fix android/ndk#1958. --- clang/lib/Driver/SanitizerArgs.cpp | 10 ++ clang/test/Driver/fsanitize.c | 5 + 2 files changed, 15 insertions(+) diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index a0d6919c6dc8d0..04b39d29e7342f 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -530,6 +530,16 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, } Add &= Supported; + // Msan is not supported on Android + if ((Add & SanitizerKind::Memory) && TC.getTriple().isAndroid()) { +if (DiagnoseErrors) { + D.Diag(diag::warn_drv_unsupported_option_for_target) + << "-fsanitize=memory" << Triple.str(); +} +DiagnosedKinds |= SanitizerKind::Memory; +Add &= ~SanitizerKind::Memory; + } + // Test for -fno-rtti + explicit -fsanitizer=vptr before expanding groups // so we don't error out if -fno-rtti and -fsanitize=undefined were // passed. diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index 1d3caec748d77a..55b51ed29b0e65 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -399,6 +399,11 @@ // RUN: %clang --target=arm-linux-androideabi %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-NO-ASAN // CHECK-ANDROID-NO-ASAN: "-mrelocation-model" "pic" +// RUN: %clang --target=aarch64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=i386-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=x86_64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// CHECK-MSAN-ANDROID: ignoring '-fsanitize=memory' option as it is not currently supported for target + // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover=all -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Warn when using msan on Android (PR #122540)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: Sharjeel Khan (Sharjeel-Khan) Changes Msan is not supported on Android as mentioned in google/sanitizers#1381. We proactively give the warning saying it is unsupported to fix android/ndk#1958. --- Full diff: https://github.com/llvm/llvm-project/pull/122540.diff 2 Files Affected: - (modified) clang/lib/Driver/SanitizerArgs.cpp (+10) - (modified) clang/test/Driver/fsanitize.c (+5) ``diff diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index a0d6919c6dc8d0..04b39d29e7342f 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -530,6 +530,16 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, } Add &= Supported; + // Msan is not supported on Android + if ((Add & SanitizerKind::Memory) && TC.getTriple().isAndroid()) { +if (DiagnoseErrors) { + D.Diag(diag::warn_drv_unsupported_option_for_target) + << "-fsanitize=memory" << Triple.str(); +} +DiagnosedKinds |= SanitizerKind::Memory; +Add &= ~SanitizerKind::Memory; + } + // Test for -fno-rtti + explicit -fsanitizer=vptr before expanding groups // so we don't error out if -fno-rtti and -fsanitize=undefined were // passed. diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index 1d3caec748d77a..55b51ed29b0e65 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -399,6 +399,11 @@ // RUN: %clang --target=arm-linux-androideabi %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-NO-ASAN // CHECK-ANDROID-NO-ASAN: "-mrelocation-model" "pic" +// RUN: %clang --target=aarch64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=i386-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=x86_64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// CHECK-MSAN-ANDROID: ignoring '-fsanitize=memory' option as it is not currently supported for target + // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover=all -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN `` https://github.com/llvm/llvm-project/pull/122540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Warn when using msan on Android (PR #122540)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Sharjeel Khan (Sharjeel-Khan) Changes Msan is not supported on Android as mentioned in google/sanitizers#1381. We proactively give the warning saying it is unsupported to fix android/ndk#1958. --- Full diff: https://github.com/llvm/llvm-project/pull/122540.diff 2 Files Affected: - (modified) clang/lib/Driver/SanitizerArgs.cpp (+10) - (modified) clang/test/Driver/fsanitize.c (+5) ``diff diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index a0d6919c6dc8d0..04b39d29e7342f 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -530,6 +530,16 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, } Add &= Supported; + // Msan is not supported on Android + if ((Add & SanitizerKind::Memory) && TC.getTriple().isAndroid()) { +if (DiagnoseErrors) { + D.Diag(diag::warn_drv_unsupported_option_for_target) + << "-fsanitize=memory" << Triple.str(); +} +DiagnosedKinds |= SanitizerKind::Memory; +Add &= ~SanitizerKind::Memory; + } + // Test for -fno-rtti + explicit -fsanitizer=vptr before expanding groups // so we don't error out if -fno-rtti and -fsanitize=undefined were // passed. diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index 1d3caec748d77a..55b51ed29b0e65 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -399,6 +399,11 @@ // RUN: %clang --target=arm-linux-androideabi %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-NO-ASAN // CHECK-ANDROID-NO-ASAN: "-mrelocation-model" "pic" +// RUN: %clang --target=aarch64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=i386-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=x86_64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// CHECK-MSAN-ANDROID: ignoring '-fsanitize=memory' option as it is not currently supported for target + // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover=all -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN `` https://github.com/llvm/llvm-project/pull/122540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Widen loops: Augment assignment note when values invalidated at the start of a loop (PR #122398)
dgg5503 wrote: > I agree that it's important to augment the bug reports with information about > the source of the symbols. Especially for conjured and derived symbols that > are produced widely because of invalidations. Loop widening is just one > source of invalidation, and we could generalize it slightly. > > Read this post of mine: > https://discourse.llvm.org/t/memory-region-invalidation-tracking-improvements/62432 > Unfortunately, I never got to implement it, but I'd be very happy as a > reviewer to guide you through. Hi @steakhal , I'm happy to hear others share a similar concern! I agree that it would make more sense to generalize this beyond loop widening. However, I'm having a hard time understanding how your proposal would fit in to the augmentation of the assignment message like I do in this PR. The part I'm most confused about is how would `SymbolInvalidationArtifact` be set/retrieved after invalidation occurs? Would this somehow be tied to symbols created as part of invalidation (like created conjured symbols in `InvalidateRegionsWorker::VisitCluster`) which could then be retrieved via `SI.Value.getAsSymbol()` and casting (speaking from the PoV of `showBRDiagnostics`)? I think I would better understand if you could please provide a small example in the context of diagnostic output. I'm fairly certain I'm lacking understanding of some static analysis design concept that's not making this click in my head... Regardless, once I have a better understanding of how your proposal fits in, I'd be happy to give your approach a try with your guidance :). Thank you https://github.com/llvm/llvm-project/pull/122398 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8a1174f - [Darwin][Driver][clang] arm64-apple-none-macho is missing the Apple macros from arm-apple-none-macho (#122427)
Author: Ian Anderson Date: 2025-01-10T15:50:54-08:00 New Revision: 8a1174f06cb69c92290a2231ede0e2a8e8460e0c URL: https://github.com/llvm/llvm-project/commit/8a1174f06cb69c92290a2231ede0e2a8e8460e0c DIFF: https://github.com/llvm/llvm-project/commit/8a1174f06cb69c92290a2231ede0e2a8e8460e0c.diff LOG: [Darwin][Driver][clang] arm64-apple-none-macho is missing the Apple macros from arm-apple-none-macho (#122427) arm-apple-none-macho uses DarwinTargetInfo which provides several Apple specific macros. arm64-apple-none-macho however just uses the generic AArch64leTargetInfo and doesn't get any of those macros. It's not clear if everything from DarwinTargetInfo is desirable for arm64-apple-none-macho, so make an AppleMachOTargetInfo to hold the generic Apple macros and a few other basic things. Added: clang/test/Preprocessor/darwin-predefines.c Modified: clang/lib/Basic/Targets.cpp clang/lib/Basic/Targets/AArch64.cpp clang/lib/Basic/Targets/AArch64.h clang/lib/Basic/Targets/ARM.cpp clang/lib/Basic/Targets/ARM.h clang/lib/Basic/Targets/OSTargets.cpp clang/lib/Basic/Targets/OSTargets.h clang/lib/Basic/Targets/X86.h clang/lib/Frontend/InitPreprocessor.cpp clang/test/Preprocessor/macho-embedded-predefines.c Removed: diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index f40b81c02eb7ec..fad3de217d81b0 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -135,11 +135,15 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, case llvm::Triple::aarch64_32: if (Triple.isOSDarwin()) return std::make_unique(Triple, Opts); +else if (Triple.isAppleMachO()) + return std::make_unique(Triple, Opts); return nullptr; case llvm::Triple::aarch64: if (Triple.isOSDarwin()) return std::make_unique(Triple, Opts); +else if (Triple.isAppleMachO()) + return std::make_unique(Triple, Opts); switch (os) { case llvm::Triple::FreeBSD: @@ -243,6 +247,8 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, case llvm::Triple::thumbeb: if (Triple.isOSDarwin()) return std::make_unique(Triple, Opts); +else if (Triple.isAppleMachO()) + return std::make_unique(Triple, Opts); switch (os) { case llvm::Triple::Linux: @@ -531,6 +537,8 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, case llvm::Triple::x86: if (Triple.isOSDarwin()) return std::make_unique(Triple, Opts); +else if (Triple.isAppleMachO()) + return std::make_unique(Triple, Opts); switch (os) { case llvm::Triple::Linux: { diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 2b4b954d0c27ad..1bf58661d0efcd 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -1671,6 +1671,10 @@ MinGWARM64TargetInfo::MinGWARM64TargetInfo(const llvm::Triple &Triple, TheCXXABI.set(TargetCXXABI::GenericAArch64); } +AppleMachOAArch64TargetInfo::AppleMachOAArch64TargetInfo( +const llvm::Triple &Triple, const TargetOptions &Opts) +: AppleMachOTargetInfo(Triple, Opts) {} + DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : DarwinTargetInfo(Triple, Opts) { @@ -1695,9 +1699,9 @@ DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple &Triple, TheCXXABI.set(TargetCXXABI::AppleARM64); } -void DarwinAArch64TargetInfo::getOSDefines(const LangOptions &Opts, - const llvm::Triple &Triple, - MacroBuilder &Builder) const { +void clang::targets::getAppleMachOAArch64Defines(MacroBuilder &Builder, + const LangOptions &Opts, + const llvm::Triple &Triple) { Builder.defineMacro("__AARCH64_SIMD__"); if (Triple.isArch32Bit()) Builder.defineMacro("__ARM64_ARCH_8_32__"); @@ -1710,7 +1714,20 @@ void DarwinAArch64TargetInfo::getOSDefines(const LangOptions &Opts, if (Triple.isArm64e()) Builder.defineMacro("__arm64e__", "1"); +} +void AppleMachOAArch64TargetInfo::getOSDefines(const LangOptions &Opts, + const llvm::Triple &Triple, + MacroBuilder &Builder) const { + getAppleMachOAArch64Defines(Builder, Opts, Triple); + AppleMachOTargetInfo::getOSDefines(Opts, Triple, + Builder); +} + +void DarwinAArch64TargetInfo::getOSDefines(const LangOptions &Opts, + const llvm::Triple &Triple, + MacroBuilder &Builder) const { + getAppleMachOAArch64De
[clang] [Darwin][Driver][clang] arm64-apple-none-macho is missing the Apple macros from arm-apple-none-macho (PR #122427)
https://github.com/ian-twilightcoder closed https://github.com/llvm/llvm-project/pull/122427 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)
@@ -137,6 +137,10 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, Alloca = new llvm::AllocaInst(Ty, CGM.getDataLayout().getAllocaAddrSpace(), ArraySize, Name, AllocaInsertPt->getIterator()); + if (Alloca->getName() != Name.str() && vitalybuka wrote: @efriedma-quic To clarify we do: 1. set metadata always 2. remove DiscardValueNames hack (in a different future patch please, as this may cause regressions if we loose metdata more often than name) LGTM if https://llvm-compile-time-tracker.com/ fail to notice a difference https://github.com/llvm/llvm-project/pull/119387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/106036 >From d4b07c7ff65ca64a5a434818ce09ecd289401340 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Tue, 10 Sep 2024 02:35:43 +0300 Subject: [PATCH 1/6] [Clang] restrict use of attribute names reserved by the C++ standard --- clang/docs/ReleaseNotes.rst | 2 ++ .../include/clang/Basic/AttributeCommonInfo.h | 2 +- clang/include/clang/Basic/CMakeLists.txt | 5 +++ clang/include/clang/Basic/DiagnosticGroups.td | 1 + .../include/clang/Basic/DiagnosticLexKinds.td | 2 ++ clang/include/clang/Lex/Preprocessor.h| 10 +++--- clang/include/clang/Sema/CMakeLists.txt | 5 --- clang/lib/Lex/PPDirectives.cpp| 26 +- .../Preprocessor/macro-reserved-attrs1.cpp| 34 +++ .../Preprocessor/macro-reserved-attrs2.cpp| 34 +++ .../gn/secondary/clang/lib/Basic/BUILD.gn | 5 +-- .../gn/secondary/clang/lib/Sema/BUILD.gn | 2 +- .../llvm-project-overlay/clang/BUILD.bazel| 9 +++-- 13 files changed, 115 insertions(+), 22 deletions(-) create mode 100644 clang/test/Preprocessor/macro-reserved-attrs1.cpp create mode 100644 clang/test/Preprocessor/macro-reserved-attrs2.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 250821a9f9c45c..eecf5de3775f21 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -298,6 +298,8 @@ Improvements to Clang's diagnostics - Clang now warns for u8 character literals used in C23 with ``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``. +- Clang now diagnoses the use of attribute names reserved by the C++ standard. (#GH92196). + Improvements to Clang's time-trace -- diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h b/clang/include/clang/Basic/AttributeCommonInfo.h index 5f024b4b5fd782..15e2685e049d9c 100644 --- a/clang/include/clang/Basic/AttributeCommonInfo.h +++ b/clang/include/clang/Basic/AttributeCommonInfo.h @@ -61,7 +61,7 @@ class AttributeCommonInfo { }; enum Kind { #define PARSED_ATTR(NAME) AT_##NAME, -#include "clang/Sema/AttrParsedAttrList.inc" +#include "clang/Basic/AttrParsedAttrList.inc" #undef PARSED_ATTR NoSemaHandlerAttribute, IgnoredAttribute, diff --git a/clang/include/clang/Basic/CMakeLists.txt b/clang/include/clang/Basic/CMakeLists.txt index f069f4fc118f27..bcc34e86385926 100644 --- a/clang/include/clang/Basic/CMakeLists.txt +++ b/clang/include/clang/Basic/CMakeLists.txt @@ -31,6 +31,11 @@ clang_tablegen(AttrList.inc -gen-clang-attr-list SOURCE Attr.td TARGET ClangAttrList) +clang_tablegen(AttrParsedAttrList.inc -gen-clang-attr-parsed-attr-list + -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ + SOURCE Attr.td + TARGET ClangAttrParsedAttrList) + clang_tablegen(AttrSubMatchRulesList.inc -gen-clang-attr-subject-match-rule-list -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ SOURCE Attr.td diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 116ce7a04f66f7..f04afce2da5a8c 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -751,6 +751,7 @@ def AmbiguousMacro : DiagGroup<"ambiguous-macro">; def KeywordAsMacro : DiagGroup<"keyword-macro">; def ReservedIdAsMacro : DiagGroup<"reserved-macro-identifier">; def ReservedIdAsMacroAlias : DiagGroup<"reserved-id-macro", [ReservedIdAsMacro]>; +def ReservedAttributeIdentifier : DiagGroup<"reserved-attribute-identifier">; def RestrictExpansionMacro : DiagGroup<"restrict-expansion">; def FinalMacro : DiagGroup<"final-macro">; diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index fc14bb6aa21651..7e1964b6284c83 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -407,6 +407,8 @@ def warn_pp_macro_hides_keyword : Extension< def warn_pp_macro_is_reserved_id : Warning< "macro name is a reserved identifier">, DefaultIgnore, InGroup; +def warn_pp_macro_is_reserved_attribute_id : Warning< + "%0 is a reserved attribute identifier">, InGroup; def warn_pp_objc_macro_redef_ignored : Warning< "ignoring redefinition of Objective-C qualifier macro">, InGroup>; diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 1307659e27d137..1e1d5ce0de48dc 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -2286,6 +2286,11 @@ class Preprocessor { } } + /// Determine whether the next preprocessor token to be + /// lexed is a '('. If so, consume the token and return true, if not, this + /// method should have no observable side-effect on the lexed tokens. + bool isNextPPTokenLParen(); + private: /// Identifiers used for SEH handling in Borland. These are on
[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)
@@ -3391,6 +3391,29 @@ static void findStoresToUninstrumentedArgAllocas( } } +StringRef getAllocaName(AllocaInst *AI) { + StringRef Name = AI->getName(); + + // Alloca could have been renamed for uniqueness. Its true name will have been + // recorded as an annotation. + if (AI->hasMetadata(LLVMContext::MD_annotation)) { +MDTuple *Annotation = +(MDTuple *)AI->getMetadata(LLVMContext::MD_annotation); +for (int i = 0; i < Annotation->getNumOperands(); i++) { + if (auto Tuple = dyn_cast(Annotation->getOperand(i))) { +for (int i = 0; i < Tuple->getNumOperands(); i++) { + if (auto stringMetadata = dyn_cast(Tuple->getOperand(i))) { +if (stringMetadata->getString() == "alloca_name_altered") { + Name = ((MDString *)Tuple->getOperand(i + 1).get())->getString(); vitalybuka wrote: break or better return here https://github.com/llvm/llvm-project/pull/119387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [nfc][ubsan] Add local-bounds test (PR #122415)
vitalybuka wrote: > Would it be useful to keep -fsanitize=...null and add local-bounds instead of > replacing null with local-bounds? It would make the test more rigorous and > also make the diff smaller. > > **edit:** or is it not possible to make a test case that is local-bounds > sanitized where null sanitization does not apply? Thanks, looks like I failed merge conflict resolution. Removing null was not an intention. https://github.com/llvm/llvm-project/pull/122415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Support] Reduce globaal variable overhead after #121663 (PR #122429)
https://github.com/MaskRay closed https://github.com/llvm/llvm-project/pull/122429 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] af4d76d - [Support] Reduce globaal variable overhead after #121663
Author: Fangrui Song Date: 2025-01-10T17:59:28-08:00 New Revision: af4d76d909b0df79494ca19b7c289c2a5b18c816 URL: https://github.com/llvm/llvm-project/commit/af4d76d909b0df79494ca19b7c289c2a5b18c816 DIFF: https://github.com/llvm/llvm-project/commit/af4d76d909b0df79494ca19b7c289c2a5b18c816.diff LOG: [Support] Reduce globaal variable overhead after #121663 * Construct frequently-accessed TimerLock/DefaultTimerGroup early to reduce overhead. * Rename `aquireDefaultGroup` to `acquireTimerGlobals` and restore ManagedStatic::claim. https://reviews.llvm.org/D76099 * Drop mtg::. We use internal linkage, so mtg:: is unneeded and might mislead users. In addition, llvm/ code almost never introduces a named namespace not in llvm::. Drop mtg::. * Replace some unique_ptr with optional to reduce overhead. * Switch to `functionName()`. * Simplify `llvm::initTimerOptions` and `TimerGroup::constructForStatistics()` Pull Request: https://github.com/llvm/llvm-project/pull/122429 Added: Modified: clang/tools/driver/driver.cpp llvm/include/llvm/Support/Timer.h llvm/lib/Support/Timer.cpp Removed: diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index ffd157e60997cd..74923247b7ee16 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -439,7 +439,7 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) { if (!UseNewCC1Process && IsCrash) { // When crashing in -fintegrated-cc1 mode, bury the timer pointers, because // the internal linked list might point to already released stack frames. -llvm::BuryPointer(llvm::TimerGroup::aquireDefaultGroup()); +llvm::BuryPointer(llvm::TimerGroup::acquireTimerGlobals()); } else { // If any timers were active but haven't been destroyed yet, print their // results now. This happens in -disable-free mode. diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h index c05389332b8045..d21859905d4a7b 100644 --- a/llvm/include/llvm/Support/Timer.h +++ b/llvm/include/llvm/Support/Timer.h @@ -240,9 +240,9 @@ class TimerGroup { /// global constructors and destructors. static void constructForStatistics(); - /// This makes the default group unmanaged, and lets the user manage the - /// group's lifetime. - static std::unique_ptr aquireDefaultGroup(); + /// This makes the timer globals unmanaged, and lets the user manage the + /// lifetime. + static void *acquireTimerGlobals(); private: friend class Timer; diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index 3f0926ae0f3cbe..1fa2cdf297aae6 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/lib/Support/Timer.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" #include +#include #if HAVE_UNISTD_H #include @@ -39,7 +40,7 @@ using namespace llvm; //===--===// -// Forward declarations for Managed Timer Globals (mtg) getters. +// Forward declarations for Managed Timer Globals getters. // // Globals have been placed at the end of the file to restrict direct // access. Use of getters also has the benefit of making it a bit more explicit @@ -49,29 +50,20 @@ namespace { class Name2PairMap; } -namespace mtg { -static std::string &LibSupportInfoOutputFilename(); -static const std::string &InfoOutputFilename(); -static bool TrackSpace(); -static bool SortTimers(); -static SignpostEmitter &Signposts(); -static sys::SmartMutex &TimerLock(); -static TimerGroup &DefaultTimerGroup(); -static TimerGroup *claimDefaultTimerGroup(); -static Name2PairMap &NamedGroupedTimers(); -} // namespace mtg +static std::string &libSupportInfoOutputFilename(); +static bool trackSpace(); +static bool sortTimers(); +static SignpostEmitter &signposts(); +static sys::SmartMutex &timerLock(); +static TimerGroup &defaultTimerGroup(); +static Name2PairMap &namedGroupedTimers(); //===--===// // //===--===// -void llvm::initTimerOptions() { - mtg::TrackSpace(); - mtg::InfoOutputFilename(); - mtg::SortTimers(); -} std::unique_ptr llvm::CreateInfoOutputFile() { - const std::string &OutputFilename = mtg::LibSupportInfoOutputFilename(); + const std::string &OutputFilename = libSupportInfoOutputFilename(); if (OutputFilename.empty()) return std::make_unique(2, false); // stderr. if (OutputFilename == "-") @@ -97,7 +89,7 @@ std::unique_ptr llvm::CreateInfoOutputFile() { //===--===// void Timer::init(StringRef TimerName, StringRef TimerDescription) { - init(TimerName, TimerDescription, mtg::DefaultTimerGroup()); + init(TimerName, TimerD
[clang] 8af4d20 - [NFCI][BoundsChecking] Apply nosanitize on local-bounds instrumentation (#122416)
Author: Vitaly Buka Date: 2025-01-10T18:11:19-08:00 New Revision: 8af4d206e0f979f68925a08f9dffd60a98ce97e2 URL: https://github.com/llvm/llvm-project/commit/8af4d206e0f979f68925a08f9dffd60a98ce97e2 DIFF: https://github.com/llvm/llvm-project/commit/8af4d206e0f979f68925a08f9dffd60a98ce97e2.diff LOG: [NFCI][BoundsChecking] Apply nosanitize on local-bounds instrumentation (#122416) Should be NFCI as we run sanitizer, like msan, before local-bounds. Added: Modified: clang/test/CodeGen/allow-ubsan-check.c llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp llvm/test/Instrumentation/BoundsChecking/runtimes.ll Removed: diff --git a/clang/test/CodeGen/allow-ubsan-check.c b/clang/test/CodeGen/allow-ubsan-check.c index a994e700115ff7..fb264ce32ab996 100644 --- a/clang/test/CodeGen/allow-ubsan-check.c +++ b/clang/test/CodeGen/allow-ubsan-check.c @@ -181,8 +181,8 @@ void use(double*); // CHECK-NEXT:[[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8:![0-9]+]] // CHECK-NEXT:ret double [[TMP2]] // CHECK: [[TRAP]]: -// CHECK-NEXT:call void @__ubsan_handle_local_out_of_bounds_abort() #[[ATTR6]] -// CHECK-NEXT:unreachable +// CHECK-NEXT:call void @__ubsan_handle_local_out_of_bounds_abort() #[[ATTR6]], !nosanitize [[META2]] +// CHECK-NEXT:unreachable, !nosanitize [[META2]] // // TR-LABEL: define dso_local double @lbounds( // TR-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0]] { @@ -198,8 +198,8 @@ void use(double*); // TR-NEXT:[[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA7:![0-9]+]] // TR-NEXT:ret double [[TMP2]] // TR: [[TRAP]]: -// TR-NEXT:call void @llvm.ubsantrap(i8 3) #[[ATTR5]] -// TR-NEXT:unreachable +// TR-NEXT:call void @llvm.ubsantrap(i8 3) #[[ATTR5]], !nosanitize [[META2]] +// TR-NEXT:unreachable, !nosanitize [[META2]] // // REC-LABEL: define dso_local double @lbounds( // REC-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0]] { @@ -215,8 +215,8 @@ void use(double*); // REC-NEXT:[[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8:![0-9]+]] // REC-NEXT:ret double [[TMP2]] // REC: [[TRAP]]: -// REC-NEXT:call void @__ubsan_handle_local_out_of_bounds() #[[ATTR6]] -// REC-NEXT:br label %[[BB1]] +// REC-NEXT:call void @__ubsan_handle_local_out_of_bounds() #[[ATTR6]], !nosanitize [[META2]] +// REC-NEXT:br label %[[BB1]], !nosanitize [[META2]] // double lbounds(int b, int i) { double a[b]; diff --git a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp index 10596f87fbcaba..8004552250b471 100644 --- a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp +++ b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp @@ -41,7 +41,13 @@ STATISTIC(ChecksAdded, "Bounds checks added"); STATISTIC(ChecksSkipped, "Bounds checks skipped"); STATISTIC(ChecksUnable, "Bounds checks unable to add"); -using BuilderTy = IRBuilder; +class BuilderTy : public IRBuilder { +public: + BuilderTy(BasicBlock *TheBB, BasicBlock::iterator IP, TargetFolder Folder) + : IRBuilder(TheBB, IP, Folder) { +SetNoSanitizeMetadata(); + } +}; /// Gets the conditions under which memory accessing instructions will overflow. /// diff --git a/llvm/test/Instrumentation/BoundsChecking/runtimes.ll b/llvm/test/Instrumentation/BoundsChecking/runtimes.ll index 6695e0fa549fa7..ccc7e93615fed2 100644 --- a/llvm/test/Instrumentation/BoundsChecking/runtimes.ll +++ b/llvm/test/Instrumentation/BoundsChecking/runtimes.ll @@ -16,113 +16,113 @@ define void @f1(i64 %x) nounwind { ; TR-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] { ; TR-NEXT:[[TMP1:%.*]] = mul i64 16, [[X]] ; TR-NEXT:[[TMP2:%.*]] = alloca i128, i64 [[X]], align 8 -; TR-NEXT:[[TMP3:%.*]] = sub i64 [[TMP1]], 0 -; TR-NEXT:[[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16 -; TR-NEXT:[[TMP5:%.*]] = or i1 false, [[TMP4]] -; TR-NEXT:[[TMP6:%.*]] = or i1 false, [[TMP5]] +; TR-NEXT:[[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]] +; TR-NEXT:[[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]] +; TR-NEXT:[[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]] +; TR-NEXT:[[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]] ; TR-NEXT:br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]] ; TR: [[BB7]]: ; TR-NEXT:[[TMP8:%.*]] = load i128, ptr [[TMP2]], align 4 ; TR-NEXT:ret void ; TR: [[TRAP]]: -; TR-NEXT:call void @llvm.trap() #[[ATTR2:[0-9]+]] -; TR-NEXT:unreachable +; TR-NEXT:call void @llvm.trap() #[[ATTR2:[0-9]+]], !nosanitize [[META0]] +; TR-NEXT:unreachable, !nosanitize [[META0]] ; ; RT-LABEL: define void @f1( ; RT-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] { ; RT-NEXT:[
[clang] [NFCI][BoundsChecking] Apply nosanitize on local-bounds instrumentation (PR #122416)
https://github.com/vitalybuka closed https://github.com/llvm/llvm-project/pull/122416 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver][OpenBSD] Remove riscv32 bit (PR #122525)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/122525 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Warn when using msan on Android (PR #122540)
https://github.com/Sharjeel-Khan updated https://github.com/llvm/llvm-project/pull/122540 >From c8d2c210a98fe0c96d758d538d50fcc0ca61a9ff Mon Sep 17 00:00:00 2001 From: Sharjeel Khan Date: Fri, 10 Jan 2025 20:07:52 + Subject: [PATCH 1/2] Warn when using msan on Android Msan is not supported on Android as mentioned in google/sanitizers#1381. We proactively give the warning saying it is unsupported to fix android/ndk#1958. --- clang/lib/Driver/SanitizerArgs.cpp | 10 ++ clang/test/Driver/fsanitize.c | 5 + 2 files changed, 15 insertions(+) diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index a0d6919c6dc8d0..04b39d29e7342f 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -530,6 +530,16 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, } Add &= Supported; + // Msan is not supported on Android + if ((Add & SanitizerKind::Memory) && TC.getTriple().isAndroid()) { +if (DiagnoseErrors) { + D.Diag(diag::warn_drv_unsupported_option_for_target) + << "-fsanitize=memory" << Triple.str(); +} +DiagnosedKinds |= SanitizerKind::Memory; +Add &= ~SanitizerKind::Memory; + } + // Test for -fno-rtti + explicit -fsanitizer=vptr before expanding groups // so we don't error out if -fno-rtti and -fsanitize=undefined were // passed. diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index 1d3caec748d77a..55b51ed29b0e65 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -399,6 +399,11 @@ // RUN: %clang --target=arm-linux-androideabi %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-NO-ASAN // CHECK-ANDROID-NO-ASAN: "-mrelocation-model" "pic" +// RUN: %clang --target=aarch64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=i386-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// RUN: %clang --target=x86_64-linux-android -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID +// CHECK-MSAN-ANDROID: ignoring '-fsanitize=memory' option as it is not currently supported for target + // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover=all -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN >From 035c7d9936a33926ccca10d9670879d3b913496e Mon Sep 17 00:00:00 2001 From: Sharjeel Khan Date: Fri, 10 Jan 2025 22:31:33 + Subject: [PATCH 2/2] Fixed format for SanitizerArgs --- clang/lib/Driver/SanitizerArgs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index 04b39d29e7342f..25bfd5eadae8c9 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -534,7 +534,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, if ((Add & SanitizerKind::Memory) && TC.getTriple().isAndroid()) { if (DiagnoseErrors) { D.Diag(diag::warn_drv_unsupported_option_for_target) - << "-fsanitize=memory" << Triple.str(); + << "-fsanitize=memory" << Triple.str(); } DiagnosedKinds |= SanitizerKind::Memory; Add &= ~SanitizerKind::Memory; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Reapply Move length support out of the DirectX Backend (#121611) (PR #122337)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-x86_64-expensive-checks-debian` running on `gribozavr4` while building `clang,llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/11794 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: tools/llvm-gsymutil/ARM_AArch64/macho-merged-funcs-dwarf.yaml' FAILED Exit Code: 1 Command Output (stdout): -- Input file: /b/1/llvm-clang-x86_64-expensive-checks-debian/build/test/tools/llvm-gsymutil/ARM_AArch64/Output/macho-merged-funcs-dwarf.yaml.tmp.dSYM Output file (aarch64): /b/1/llvm-clang-x86_64-expensive-checks-debian/build/test/tools/llvm-gsymutil/ARM_AArch64/Output/macho-merged-funcs-dwarf.yaml.tmp.default.gSYM Loaded 3 functions from DWARF. Loaded 3 functions from symbol table. warning: same address range contains different debug info. Removing: [0x0248 - 0x0270): Name=0x0047 addr=0x0248, file= 3, line= 5 addr=0x0254, file= 3, line= 7 addr=0x0258, file= 3, line= 9 addr=0x025c, file= 3, line= 8 addr=0x0260, file= 3, line= 11 addr=0x0264, file= 3, line= 10 addr=0x0268, file= 3, line= 6 In favor of this one: [0x0248 - 0x0270): Name=0x0030 addr=0x0248, file= 2, line= 5 addr=0x0254, file= 2, line= 7 addr=0x0258, file= 2, line= 9 addr=0x025c, file= 2, line= 8 addr=0x0260, file= 2, line= 11 addr=0x0264, file= 2, line= 10 addr=0x0268, file= 2, line= 6 warning: same address range contains different debug info. Removing: [0x0248 - 0x0270): Name=0x0030 addr=0x0248, file= 2, line= 5 addr=0x0254, file= 2, line= 7 addr=0x0258, file= 2, line= 9 addr=0x025c, file= 2, line= 8 addr=0x0260, file= 2, line= 11 addr=0x0264, file= 2, line= 10 addr=0x0268, file= 2, line= 6 In favor of this one: [0x0248 - 0x0270): Name=0x0001 addr=0x0248, file= 1, line= 5 addr=0x0254, file= 1, line= 7 addr=0x0258, file= 1, line= 9 addr=0x025c, file= 1, line= 8 addr=0x0260, file= 1, line= 11 addr=0x0264, file= 1, line= 10 ... ``` https://github.com/llvm/llvm-project/pull/122337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Separate parsing of modulemaps (PR #119740)
@@ -0,0 +1,141 @@ +//===- ModuleMapFile.h - Parsing and representation -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_LEX_MODULEMAPFILE_H +#define LLVM_CLANG_LEX_MODULEMAPFILE_H + +#include "clang/Basic/LLVM.h" +// TODO: Consider moving ModuleId to another header, parsing a modulemap file is +// intended to not depend on anything about the clang::Module class. +#include "clang/Basic/Module.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/StringRef.h" + +#include +#include + +namespace clang { + +class DiagnosticsEngine; +class SourceManager; + +namespace modulemap { + +using Decl = +std::variant; + +struct RequiresFeature { + SourceLocation Location; + StringRef Feature; + bool RequiredState = true; +}; + +struct RequiresDecl { + SourceLocation Location; + std::vector Features; +}; + +struct HeaderDecl { + SourceLocation Location; + StringRef Path; + SourceLocation PathLoc; + std::optional Size; + std::optional MTime; + LLVM_PREFERRED_TYPE(bool) + unsigned Private : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned Textual : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned Umbrella : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned Excluded : 1; +}; + +struct UmbrellaDirDecl { + SourceLocation Location; + StringRef Path; +}; + +struct ModuleDecl { + SourceLocation Location; /// Points to the first keyword in the decl. + ModuleId Id; + ModuleAttributes Attrs; + std::vector Decls; + + LLVM_PREFERRED_TYPE(bool) + unsigned Explicit : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned Framework : 1; +}; + +struct ExcludeDecl { + SourceLocation Location; + StringRef Module; +}; + +struct ExportDecl { + SourceLocation Location; + ModuleId Id; + bool Wildcard; +}; + +struct ExportAsDecl { + SourceLocation Location; + ModuleId Id; +}; + +struct ExternModuleDecl { + SourceLocation Location; + ModuleId Id; + StringRef Path; +}; + +struct UseDecl { + SourceLocation Location; + ModuleId Id; +}; + +struct LinkDecl { + SourceLocation Location; + StringRef Library; + LLVM_PREFERRED_TYPE(bool) + unsigned Framework : 1; +}; + +struct ConfigMacrosDecl { + SourceLocation Location; + std::vector Macros; + LLVM_PREFERRED_TYPE(bool) + unsigned Exhaustive : 1; +}; + +struct ConflictDecl { + SourceLocation Location; + ModuleId Id; + StringRef Message; +}; + +using TopLevelDecl = std::variant; + +struct ModuleMapFile { + std::vector Decls; +}; + +std::optional parseModuleMap(FileEntryRef File, benlangmuir wrote: To add to this, I would like to see doc comments for at least `struct ModuleMapFile` and `parseModuleMap`. https://github.com/llvm/llvm-project/pull/119740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Separate parsing of modulemaps (PR #119740)
https://github.com/benlangmuir edited https://github.com/llvm/llvm-project/pull/119740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Separate parsing of modulemaps (PR #119740)
@@ -3157,25 +2140,18 @@ bool ModuleMap::parseModuleMapFile(FileEntryRef File, bool IsSystem, assert((!Offset || *Offset <= Buffer->getBufferSize()) && "invalid buffer offset"); - // Parse this module map file. - Lexer L(SourceMgr.getLocForStartOfFile(ID), MMapLangOpts, - Buffer->getBufferStart(), - Buffer->getBufferStart() + (Offset ? *Offset : 0), - Buffer->getBufferEnd()); - SourceLocation Start = L.getSourceLocation(); - ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, ID, Dir, IsSystem); - bool Result = Parser.parseModuleMapFile(); - ParsedModuleMap[File] = Result; - - if (Offset) { -auto Loc = SourceMgr.getDecomposedLoc(Parser.getLocation()); -assert(Loc.first == ID && "stopped in a different file?"); -*Offset = Loc.second; + std::optional MMF = + modulemap::parseModuleMap(File, SourceMgr, Diags, IsSystem, Offset); + bool Result = false; + if (MMF) { +ModuleMapParser Parser(*MMF, SourceMgr, Diags, *this, ID, Dir, IsSystem); +Result = Parser.parseModuleMapFile(); } + ParsedModuleMap[File] = Result; // Notify callbacks that we parsed it. for (const auto &Cb : Callbacks) -Cb->moduleMapFileRead(Start, File, IsSystem); +Cb->moduleMapFileRead(SourceLocation(), File, IsSystem); benlangmuir wrote: The empty source loc deserves a comment (a TODO maybe since you plan to change this?) https://github.com/llvm/llvm-project/pull/119740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Separate parsing of modulemaps (PR #119740)
@@ -0,0 +1,141 @@ +//===- ModuleMapFile.h - Parsing and representation -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_LEX_MODULEMAPFILE_H +#define LLVM_CLANG_LEX_MODULEMAPFILE_H + +#include "clang/Basic/LLVM.h" +// TODO: Consider moving ModuleId to another header, parsing a modulemap file is +// intended to not depend on anything about the clang::Module class. +#include "clang/Basic/Module.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/StringRef.h" + +#include +#include + +namespace clang { + +class DiagnosticsEngine; +class SourceManager; + +namespace modulemap { + +using Decl = +std::variant; + +struct RequiresFeature { + SourceLocation Location; + StringRef Feature; + bool RequiredState = true; +}; + +struct RequiresDecl { + SourceLocation Location; + std::vector Features; +}; + +struct HeaderDecl { + SourceLocation Location; + StringRef Path; + SourceLocation PathLoc; + std::optional Size; + std::optional MTime; + LLVM_PREFERRED_TYPE(bool) + unsigned Private : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned Textual : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned Umbrella : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned Excluded : 1; +}; + +struct UmbrellaDirDecl { + SourceLocation Location; + StringRef Path; +}; + +struct ModuleDecl { + SourceLocation Location; /// Points to the first keyword in the decl. + ModuleId Id; + ModuleAttributes Attrs; + std::vector Decls; + + LLVM_PREFERRED_TYPE(bool) + unsigned Explicit : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned Framework : 1; +}; + +struct ExcludeDecl { + SourceLocation Location; + StringRef Module; +}; + +struct ExportDecl { + SourceLocation Location; + ModuleId Id; + bool Wildcard; +}; + +struct ExportAsDecl { + SourceLocation Location; + ModuleId Id; +}; + +struct ExternModuleDecl { + SourceLocation Location; + ModuleId Id; + StringRef Path; +}; + +struct UseDecl { + SourceLocation Location; + ModuleId Id; +}; + +struct LinkDecl { + SourceLocation Location; + StringRef Library; + LLVM_PREFERRED_TYPE(bool) + unsigned Framework : 1; +}; + +struct ConfigMacrosDecl { + SourceLocation Location; + std::vector Macros; + LLVM_PREFERRED_TYPE(bool) + unsigned Exhaustive : 1; +}; + +struct ConflictDecl { + SourceLocation Location; + ModuleId Id; + StringRef Message; +}; + +using TopLevelDecl = std::variant; + +struct ModuleMapFile { + std::vector Decls; +}; + +std::optional parseModuleMap(FileEntryRef File, +SourceManager &SM, +DiagnosticsEngine &Diags, +bool IsSystem, unsigned *Offset); +void dumpModuleMapFile(ModuleMapFile &MMF, llvm::raw_ostream &out); benlangmuir wrote: Normally I would expect `ModuleMapFile::dump` not a top-level function. https://github.com/llvm/llvm-project/pull/119740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Separate parsing of modulemaps (PR #119740)
https://github.com/benlangmuir commented: I'm happy with the way this split of the code worked out! > Currently this has no effect other than slightly changing diagnostics. Can you say more about the ordering changes? I understand we can't always emit diagnostics in source order, but it's helpful for readability when we do so I wasn't thrilled to see that seems to be changing. https://github.com/llvm/llvm-project/pull/119740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] Reapply "[clang] Avoid re-evaluating field bitwidth" (PR #122289)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/JDevlieghere approved this pull request. LGTM but please give @Michael137 a chance to take a look as this is his area of expertise. https://github.com/llvm/llvm-project/pull/122289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [nfc][ubsan] Add local-bounds test (PR #122415)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/122415 >From 0021fbc549fcc8c27b184af163ba963c31acc0c1 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Thu, 9 Jan 2025 20:26:03 -0800 Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 [skip ci] --- clang/test/CodeGen/allow-ubsan-check.c | 337 +++-- 1 file changed, 145 insertions(+), 192 deletions(-) diff --git a/clang/test/CodeGen/allow-ubsan-check.c b/clang/test/CodeGen/allow-ubsan-check.c index 5232d240854666..76dd9f653309cb 100644 --- a/clang/test/CodeGen/allow-ubsan-check.c +++ b/clang/test/CodeGen/allow-ubsan-check.c @@ -1,86 +1,65 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=TRAP -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=RECOVER +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=TRAP +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=RECOVER -// CHECK-LABEL: define dso_local i32 @div( -// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] { -// CHECK-NEXT: entry: -// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4 -// CHECK-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4 -// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4 -// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[Y_ADDR]], align 4 -// CHECK-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0, !nosanitize [[META2:![0-9]+]] -// CHECK-NEXT:[[TMP3:%.*]] = icmp ne i32 [[TMP0]], -2147483648, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP4:%.*]] = icmp ne i32 [[TMP1]], -1, !nosanitize [[META2]] -// CHECK-NEXT:[[OR:%.*]] = or i1 [[TMP3]], [[TMP4]], !nosanitize [[META2]] -// CHECK-NEXT:[[TMP5:%.*]] = and i1 [[TMP2]], [[OR]], !nosanitize [[META2]] -// CHECK-NEXT:[[TMP6:%.*]] = call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]] -// CHECK-NEXT:[[TMP7:%.*]] = xor i1 [[TMP6]], true, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP8:%.*]] = or i1 [[TMP5]], [[TMP7]], !nosanitize [[META2]] -// CHECK-NEXT:br i1 [[TMP8]], label [[CONT:%.*]], label [[HANDLER_DIVREM_OVERFLOW:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]] -// CHECK: handler.divrem_overflow: -// CHECK-NEXT:[[TMP9:%.*]] = zext i32 [[TMP0]] to i64, !nosanitize [[META2]] -// CHECK-NEXT:[[TMP10:%.*]] = zext i32 [[TMP1]] to i64, !nosanitize [[META2]] -// CHECK-NEXT:call void @__ubsan_handle_divrem_overflow_abort(ptr @[[GLOB1:[0-9]+]], i64 [[TMP9]], i64 [[TMP10]]) #[[ATTR4:[0-9]+]], !nosanitize [[META2]] +// CHECK-LABEL: define dso_local noundef i32 @div( +// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT:[[TMP0:%.*]] = icmp eq i32 [[Y]], 0, !nosanitize [[META2:![0-9]+]] +// CHECK-NEXT:[[TMP1:%.*]] = icmp eq i32 [[X]], -2147483648, !nosanitize [[META2]] +// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i32 [[Y]], -1, !nosanitize [[META2]] +// CHECK-NEXT:[[OR_NOT5:%.*]] = and i1 [[TMP1]], [[TMP2]] +// CHECK-NEXT:[[DOTNOT3:%.*]] = or i1 [[TMP0]], [[OR_NOT5]] +// CHECK-NEXT:[[TMP3:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]] +// CHECK-NEXT:[[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]] +// CHECK-NEXT:br i1 [[DOTNOT1]], labe
[clang] [InstrProf] Fix format issue in user manual (PR #122559)
https://github.com/ellishg closed https://github.com/llvm/llvm-project/pull/122559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0cb1884 - [InstrProf] Fix format issue in user manual (#122559)
Author: Ellis Hoag Date: 2025-01-10T17:08:22-08:00 New Revision: 0cb1884989bca72895b2a1cd555955bfc33ac520 URL: https://github.com/llvm/llvm-project/commit/0cb1884989bca72895b2a1cd555955bfc33ac520 DIFF: https://github.com/llvm/llvm-project/commit/0cb1884989bca72895b2a1cd555955bfc33ac520.diff LOG: [InstrProf] Fix format issue in user manual (#122559) Fix a small formatting issue in the user manual after #122385. https://clang.llvm.org/docs/UsersManual.html#cmdoption-ftemporal-profile Added: Modified: clang/docs/UsersManual.rst Removed: diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index f58fca465c5494..4de288250f3ad8 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -3051,7 +3051,7 @@ indexed format, regardeless whether it is produced by frontend or the IR pass. $ llvm-profdata merge -o code.profdata yyy/zzz Using the resulting profile, we can generate a function order to pass to the - linker via `--symbol-ordering-file` for ELF or `-order_file` for Mach-O. + linker via ``--symbol-ordering-file`` for ELF or ``-order_file`` for Mach-O. .. code-block:: console ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)
@@ -137,6 +137,10 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, Alloca = new llvm::AllocaInst(Ty, CGM.getDataLayout().getAllocaAddrSpace(), ArraySize, Name, AllocaInsertPt->getIterator()); + if (Alloca->getName() != Name.str() && vitalybuka wrote: My understanding was you are asking to produce medatada for all compilation modes, even without asan? https://github.com/llvm/llvm-project/pull/119387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add the `annotate_decl` attribute. (PR #122431)
https://github.com/martinboehme updated https://github.com/llvm/llvm-project/pull/122431 >From 5c1ce9b825d1263f4c9e1c1306b682ad633c1c76 Mon Sep 17 00:00:00 2001 From: Martin Braenne Date: Fri, 10 Jan 2025 08:31:39 + Subject: [PATCH] [Clang] Add the `annotate_decl` attribute. This attribute is intended as a general-purpose mechanism to add annotations for use by Clang-based tools. People have been using the existing `annotate` attribute for this purpose, but this can interfere with optimizations -- see https://github.com/llvm/llvm-project/issues/55190. For details, see this RFC: https://discourse.llvm.org/t/rfc-new-attribute-annotate-decl/84006 --- clang/include/clang/Basic/Attr.td | 8 clang/include/clang/Basic/AttrDocs.td | 35 +++- clang/lib/Sema/SemaDeclAttr.cpp | 29 + clang/test/SemaCXX/annotate-decl.cpp | 48 ++ clang/unittests/AST/AttrTest.cpp | 59 +-- 5 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 clang/test/SemaCXX/annotate-decl.cpp diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 12faf06597008e..1c5a13bf8db65b 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -962,6 +962,14 @@ def Annotate : InheritableParamOrStmtAttr { let Documentation = [Undocumented]; } +def AnnotateDecl : Attr { + let Spellings = [CXX11<"clang", "annotate_decl">, C23<"clang", "annotate_decl">]; + let Args = [StringArgument<"Annotation">, VariadicExprArgument<"Args">]; + let HasCustomParsing = 1; + let AcceptsExprPack = 1; + let Documentation = [AnnotateDeclDocs]; +} + def AnnotateType : TypeAttr { let Spellings = [CXX11<"clang", "annotate_type">, C23<"clang", "annotate_type">]; let Args = [StringArgument<"Annotation">, VariadicExprArgument<"Args">]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index b8d702e41aa0bb..dcbbb06c7d922e 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -8146,14 +8146,45 @@ and copied back to the argument after the callee returns. }]; } +def AnnotateDeclDocs : Documentation { + let Category = DocCatType; + let Heading = "annotate_decl"; + let Content = [{ +This attribute is used to add annotations to declarations, typically for use by +static analysis tools that are not integrated into the core Clang compiler +(e.g., Clang-Tidy checks or out-of-tree Clang-based tools). See also the +`annotate_type` attribute, which serves the same purpose, but for types. + +The attribute takes a mandatory string literal argument specifying the +annotation category and an arbitrary number of optional arguments that provide +additional information specific to the annotation category. The optional +arguments must be constant expressions of arbitrary type. + +For example: + +.. code-block:: c++ + + [[clang::annotate_decl("category", "foo", 1)]] int i; + +The attribute does not have any effect on the semantics of the declaration or +the code that should be produced for it. + +There is no requirement that different declarations of an entity (i.e. +redeclarations) use the same `annotate_decl` annotations, so that the annotation +can be used as flexibly as possible. If a Clang-based tool wants to impose +additional rules for specific annotations, it needs to check for and enforce +these itself. + }]; +} + def AnnotateTypeDocs : Documentation { let Category = DocCatType; let Heading = "annotate_type"; let Content = [{ This attribute is used to add annotations to types, typically for use by static analysis tools that are not integrated into the core Clang compiler (e.g., -Clang-Tidy checks or out-of-tree Clang-based tools). It is a counterpart to the -`annotate` attribute, which serves the same purpose, but for declarations. +Clang-Tidy checks or out-of-tree Clang-based tools). See also the +`annotate_decl` attribute, which serves the same purpose, but for declarations. The attribute takes a mandatory string literal argument specifying the annotation category and an arbitrary number of optional arguments that provide diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index bb4d33560b93b8..748b03f4a24c1c 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4113,6 +4113,32 @@ static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { } } +static void handleAnnotateDeclAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + if (AL.getNumArgs() < 1) { +S.Diag(AL.getLoc(), diag::err_attribute_too_few_arguments) << AL << 1; +return; + } + + // Make sure that there is a string literal as the annotation's first + // argument. + StringRef Str; + if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) +return; + + llvm::SmallVector Args; + Args.reserve(AL.getNumArgs() - 1); + for (unsigned Idx = 1;
[clang] [Clang] Add the `annotate_decl` attribute. (PR #122431)
https://github.com/martinboehme edited https://github.com/llvm/llvm-project/pull/122431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Widen loops: Augment assignment note when values invalidated at the start of a loop (PR #122398)
steakhal wrote: I agree that it's important to augment the bug reports with information about the source of the symbols. Especially for conjured and derived symbols that are produced widely because of invalidations. Loop widening is just one source of invalidation, and we could generalize it slightly. Read this post of mine: https://discourse.llvm.org/t/memory-region-invalidation-tracking-improvements/62432 Unfortunately, I never got to implement it, but I'd be very happy as a reviewer to guide you through. https://github.com/llvm/llvm-project/pull/122398 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] Remove `StringLiteral` in favor of `StringRef` (PR #122366)
jh7370 wrote: > Do we care about performance on MSVC ? Just responding to this point (although I accept it's moot in the current context): yes we care about performance when building with MSVC - our downstream toolchain is hosted on Windows. I'm sure we're not the only Windows client either. https://github.com/llvm/llvm-project/pull/122366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86] Extend kCFI with a 3-bit arity indicator (PR #121070)
@@ -254,6 +254,7 @@ FEATURE(is_trivially_constructible, LangOpts.CPlusPlus) FEATURE(is_trivially_copyable, LangOpts.CPlusPlus) FEATURE(is_union, LangOpts.CPlusPlus) FEATURE(kcfi, LangOpts.Sanitize.has(SanitizerKind::KCFI)) +FEATURE(kcfi_x86_arity, LangOpts.Sanitize.has(SanitizerKind::KCFI)) Darksonn wrote: I still think it would be best to support both hash types via flags to avoid limiting which compiler versions work together. https://github.com/llvm/llvm-project/pull/121070 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][SME] Add diagnostics for SME attributes on lambda functions (PR #121777)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-cmake-x86_64-avx512-linux` running on `avx512-intel64` while building `clang` at step 12 "setup lit". Full details are available at: https://lab.llvm.org/buildbot/#/builders/133/builds/9473 Here is the relevant piece of the build log for the reference ``` Step 12 (setup lit) failure: '/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/test/sandbox/bin/python /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/test/lnt/setup.py ...' (failure) ... See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. !! self.initialize_options() zip_safe flag not set; analyzing archive contents... Adding python-gnupg 0.3.7 to easy-install.pth file detected new path './pytz-2016.10-py3.9.egg' Installed /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/test/sandbox/lib64/python3.9/site-packages/python_gnupg-0.3.7-py3.9.egg Searching for itsdangerous==0.24 Reading https://pypi.org/simple/itsdangerous/ Downloading https://files.pythonhosted.org/packages/dc/b4/a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4/itsdangerous-0.24.tar.gz#sha256=cbb3fcf8d3e33df861709ecaf89d9e6629cff0a217bc2848f1b41cd30d360519 Best match: itsdangerous 0.24 Processing itsdangerous-0.24.tar.gz Writing /tmp/easy_install-ga32lss_/itsdangerous-0.24/setup.cfg Running itsdangerous-0.24/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ga32lss_/itsdangerous-0.24/egg-dist-tmp-6f5fns26 warning: no previously-included files matching '*' found under directory 'docs/_build' /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/test/sandbox/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. !! self.initialize_options() Adding itsdangerous 0.24 to easy-install.pth file detected new path './python_gnupg-0.3.7-py3.9.egg' Installed /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/test/sandbox/lib64/python3.9/site-packages/itsdangerous-0.24-py3.9.egg Searching for Werkzeug==0.15.6 Reading https://pypi.org/simple/Werkzeug/ Downloading https://files.pythonhosted.org/packages/b7/61/c0a1adf9ad80db012ed7191af98fa05faa95fa09eceb71bb6fa8b66e6a43/Werkzeug-0.15.6-py2.py3-none-any.whl#sha256=00d32beac38fcd48d329566f80d39f10ec2ed994efbecfb8dd4b320062d05902 Best match: Werkzeug 0.15.6 Processing Werkzeug-0.15.6-py2.py3-none-any.whl Installing Werkzeug-0.15.6-py2.py3-none-any.whl to /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/test/sandbox/lib64/python3.9/site-packages Adding Werkzeug 0.15.6 to easy-install.pth file detected new path './itsdangerous-0.24-py3.9.egg' Installed /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/test/sandbox/lib64/python3.9/site-packages/Werkzeug-0.15.6-py3.9.egg Searching for SQLAlchemy==1.2.19 Reading https://pypi.org/simple/SQLAlchemy/ Downloading https://files.pythonhosted.org/packages/f9/67/d07cf7ac7e6dd0bc55ba62816753f86d7c558107104ca915e730c9ec2512/SQLAlchemy-1.2.19.tar.gz#sha256=5bb2c4fc2bcc3447ad45716c66581eab982c007dcf925482498d8733f86f17c7 error: [Errno 104] Connection reset by peer ``` https://github.com/llvm/llvm-project/pull/121777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add the `annotate_decl` attribute. (PR #122431)
@@ -8146,14 +8146,45 @@ and copied back to the argument after the callee returns. }]; } +def AnnotateDeclDocs : Documentation { + let Category = DocCatType; + let Heading = "annotate_decl"; + let Content = [{ +This attribute is used to add annotations to declarations, typically for use by +static analysis tools that are not integrated into the core Clang compiler +(e.g., Clang-Tidy checks or out-of-tree Clang-based tools). See also the +`annotate_type` attribute, which serves the same purpose, but for types. + +The attribute takes a mandatory string literal argument specifying the +annotation category and an arbitrary number of optional arguments that provide +additional information specific to the annotation category. The optional +arguments must be constant expressions of arbitrary type. zmodem wrote: Are there any special semantics for the "category" argument? Otherwise it sounds like this could be simplified to say that the attribute takes at least one argument, the first of which needs to be a string literal. https://github.com/llvm/llvm-project/pull/122431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)
@@ -0,0 +1,48 @@ +// RUN: %clang_analyze_cc1 -triple=x86_64-pc-linux-gnu -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=armv8-none-linux-eabi -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=aarch64-linux-gnu -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=hexagon -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s + +#include "Inputs/system-header-simulator.h" + +char *get_str(char *Input); + +void check_f_leak() { + FILE *fp = fopen("test", "rb"); + if (NULL == fp) { +return; + } + char str[64]; + if (get_str(str) != str) { +fclose(fp); + } +}// expected-warning {{Opened stream never closed. Potential resource leak}} + +void check_f_leak_2() { + FILE *fp = fopen("test", "rb"); + if (NULL == fp) { +return; + } + char str[64]; + if (get_str(str) != NULL) { +fclose(fp); + } +}// expected-warning {{Opened stream never closed. Potential resource leak}} + + +char *get_str_other(char *Input) {return Input;} + +void check_f_leak_3() { + FILE *fp = fopen("test", "rb"); + if (NULL == fp) { +return; + } + char str[64]; + if (get_str_other(str) != str) { +fclose(fp); steakhal wrote: This is dead code. https://github.com/llvm/llvm-project/pull/122404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)
@@ -0,0 +1,48 @@ +// RUN: %clang_analyze_cc1 -triple=x86_64-pc-linux-gnu -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=armv8-none-linux-eabi -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=aarch64-linux-gnu -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=hexagon -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s + +#include "Inputs/system-header-simulator.h" + +char *get_str(char *Input); + +void check_f_leak() { + FILE *fp = fopen("test", "rb"); + if (NULL == fp) { +return; + } + char str[64]; + if (get_str(str) != str) { +fclose(fp); + } +}// expected-warning {{Opened stream never closed. Potential resource leak}} + +void check_f_leak_2() { + FILE *fp = fopen("test", "rb"); + if (NULL == fp) { +return; + } + char str[64]; + if (get_str(str) != NULL) { +fclose(fp); + } +}// expected-warning {{Opened stream never closed. Potential resource leak}} + + +char *get_str_other(char *Input) {return Input;} steakhal wrote: One usually calls this identity. https://github.com/llvm/llvm-project/pull/122404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)
@@ -952,6 +952,12 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state, const MemSpaceRegion *RightMS = RightBase->getMemorySpace(); const MemSpaceRegion *UnknownMS = MemMgr.getUnknownRegion(); +if (LeftMS != RightMS && +((isa(LeftMS) && isa(RightMS)) || + (isa(LeftMS) && isa(RightMS { + return UnknownVal(); +} + steakhal wrote: In the current form, it's likely that the subsequent check could be simplified, that checks something really similar like this one. Please consider hoisting common subexpressions, and simplifying the subsequent check as well. https://github.com/llvm/llvm-project/pull/122404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/122404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)
https://github.com/steakhal requested changes to this pull request. In general, the concept of having the memory space directly embedded into a memory region is flawed. And that is the root cause of the problem. Ideally, the property of "in what memory space does this region live in" is a trait, that could be changed as we learn about aliasing properties in the program. As such, we should be able to say, we didn't know exactly what is the memory space of a symbol, but now that we learned that this is equal to some other memory region that lives on the stack, we must also live on the stack. So ideally, we would purge the whole memoryspace portion of the memregion class hierarchy. As an easier workaround, we could probably get away with having this program trait defined only for memregions that have UnknownMemorySpace. This way we could fix these issues while saving some work of completely rewriting the whole memregion class hierarchy. (I tried that, and it's not trivial.) @Flandini could you please chim in and collaborate with him/her? https://github.com/llvm/llvm-project/pull/122404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix wrong result of pointers comparison between unknown and stack (PR #122404)
@@ -0,0 +1,48 @@ +// RUN: %clang_analyze_cc1 -triple=x86_64-pc-linux-gnu -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=armv8-none-linux-eabi -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=aarch64-linux-gnu -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s +// RUN: %clang_analyze_cc1 -triple=hexagon -analyzer-checker=core,unix.Stream,debug.ExprInspection \ +// RUN: -analyzer-config eagerly-assume=false,unix.Stream:Pedantic=true -verify %s + +#include "Inputs/system-header-simulator.h" + +char *get_str(char *Input); steakhal wrote: Does it matter if this takes any parameters? I think we are better off not having any parameters, because those would be just confusing at the call site. https://github.com/llvm/llvm-project/pull/122404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)
MichelleCDjunaidi wrote: @PiotrZSL @5chmidti I'll need help to merge this into the repo, as I don't have write permissions. Thank you so much and have a nice day! https://github.com/llvm/llvm-project/pull/102299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/3] Reapply "[Clang] Implement CWG2369 "Ordering between constraints and substitution"" (#122130) This reverts commit 3972ed57088f6515b787d7d38dec03dc74e51827. --- clang/include/clang/Sema/Sema.h | 22 +++- clang/include/clang/Sema/Template.h | 6 + clang/lib/Sema/SemaConcept.cpp| 47 ++- clang/lib/Sema/SemaTemplateDeduction.cpp | 49 +--- clang/lib/Sema/SemaTemplateDeductionGuide.cpp | 8 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 -- clang/lib/Sema/TreeTransform.h| 2 +- clang/test/CXX/drs/cwg23xx.cpp| 29 + clang/test/CXX/drs/cwg26xx.cpp| 2 +- clang/test/CXX/drs/cwg27xx.cpp| 20 +++ .../expr.prim.req/nested-requirement.cpp | 2 +- .../constrant-satisfaction-conversions.cpp| 6 +- .../SemaCXX/concept-crash-on-diagnostic.cpp | 2 +- clang/test/SemaCXX/cxx20-ctad-type-alias.cpp | 2 +- clang/test/SemaCXX/cxx23-assume.cpp | 6 +- clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 2 +- clang/test/SemaCXX/lambda-unevaluated.cpp | 4 +- .../SemaTemplate/concepts-recursive-inst.cpp | 4 +- .../SemaTemplate/cxx2a-constraint-exprs.cpp | 2 +- clang/test/SemaTemplate/deduction-guide.cpp | 5 - .../nested-implicit-deduction-guides.cpp | 8 +- clang/www/cxx_dr_status.html | 8 +- 22 files changed, 289 insertions(+), 62 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index a41f16f6dc8c9b..18fd95f77ec227 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13062,6 +13062,7 @@ class Sema final : public SemaBase { /// /// \param SkipForSpecialization when specified, any template specializations /// in a traversal would be ignored. + /// /// \param ForDefaultArgumentSubstitution indicates we should continue looking /// when encountering a specialized member function template, rather than /// returning immediately. @@ -13073,6 +13074,17 @@ class Sema final : public SemaBase { bool SkipForSpecialization = false, bool ForDefaultArgumentSubstitution = false); + /// Apart from storing the result to \p Result, this behaves the same as + /// another overload. + void getTemplateInstantiationArgs( + MultiLevelTemplateArgumentList &Result, const NamedDecl *D, + const DeclContext *DC = nullptr, bool Final = false, + std::optional> Innermost = std::nullopt, + bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr, + bool ForConstraintInstantiation = false, + bool SkipForSpecialization = false, + bool ForDefaultArgumentSubstitution = false); + /// RAII object to handle the state changes required to synthesize /// a function body. class SynthesizedFunctionScope { @@ -13342,7 +13354,7 @@ class Sema final : public SemaBase { ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); - // Unlike the above, this does not evaluates constraints. + // Unlike the above, this does not evaluate constraints. ExprResult SubstConstraintExprWithoutSatisfaction( Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); @@ -14463,10 +14475,10 @@ class Sema final : public SemaBase { const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange); - bool CheckInstantiatedFunctionTemplateConstraints( - SourceLocation PointOfInstantiation, FunctionDecl *Decl, - ArrayRef TemplateArgs, - ConstraintSatisfaction &Satisfaction); + bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation, +FunctionDecl *Decl, +ArrayRef TemplateArgs, +ConstraintSatisfaction &Satisfaction); /// \brief Emit diagnostics explaining why a constraint expression was deemed /// unsatisfied. diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 9800f75f676aaf..59a0575ca98036 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char { llvm::PointerUnion * findInstantiationOf(const Decl *D); +/// Similar to \p findInstantiationOf(), but it wouldn't assert if the +/// instantiation was not found within the current instantiation scope. This +/// is helpful for on-demand declaration instantiation. +llvm::PointerUnion * +findInstantiationUnsafe(const Decl *D); + void InstantiatedLocal(const Decl *D, Decl *Inst
[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
https://github.com/zyn0217 converted_to_draft https://github.com/llvm/llvm-project/pull/122423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add an option to control indentation of `export { ... }` (PR #110381)
@@ -1522,6 +1523,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never; LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock; LLVMStyle.ExperimentalAutoDetectBinPacking = false; + LLVMStyle.ExportBlockIndentation = false; mydeveloperday wrote: doesn't clang-format currently by default indent the export, so shouldn't this be true? so we don't change any existing code that might like the indentation https://github.com/llvm/llvm-project/pull/110381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/5] Reapply "[Clang] Implement CWG2369 "Ordering between constraints and substitution"" (#122130) This reverts commit 3972ed57088f6515b787d7d38dec03dc74e51827. --- clang/include/clang/Sema/Sema.h | 22 +++- clang/include/clang/Sema/Template.h | 6 + clang/lib/Sema/SemaConcept.cpp| 47 ++- clang/lib/Sema/SemaTemplateDeduction.cpp | 49 +--- clang/lib/Sema/SemaTemplateDeductionGuide.cpp | 8 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 -- clang/lib/Sema/TreeTransform.h| 2 +- clang/test/CXX/drs/cwg23xx.cpp| 29 + clang/test/CXX/drs/cwg26xx.cpp| 2 +- clang/test/CXX/drs/cwg27xx.cpp| 20 +++ .../expr.prim.req/nested-requirement.cpp | 2 +- .../constrant-satisfaction-conversions.cpp| 6 +- .../SemaCXX/concept-crash-on-diagnostic.cpp | 2 +- clang/test/SemaCXX/cxx20-ctad-type-alias.cpp | 2 +- clang/test/SemaCXX/cxx23-assume.cpp | 6 +- clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 2 +- clang/test/SemaCXX/lambda-unevaluated.cpp | 4 +- .../SemaTemplate/concepts-recursive-inst.cpp | 4 +- .../SemaTemplate/cxx2a-constraint-exprs.cpp | 2 +- clang/test/SemaTemplate/deduction-guide.cpp | 5 - .../nested-implicit-deduction-guides.cpp | 8 +- clang/www/cxx_dr_status.html | 8 +- 22 files changed, 289 insertions(+), 62 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index a41f16f6dc8c9b..18fd95f77ec227 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13062,6 +13062,7 @@ class Sema final : public SemaBase { /// /// \param SkipForSpecialization when specified, any template specializations /// in a traversal would be ignored. + /// /// \param ForDefaultArgumentSubstitution indicates we should continue looking /// when encountering a specialized member function template, rather than /// returning immediately. @@ -13073,6 +13074,17 @@ class Sema final : public SemaBase { bool SkipForSpecialization = false, bool ForDefaultArgumentSubstitution = false); + /// Apart from storing the result to \p Result, this behaves the same as + /// another overload. + void getTemplateInstantiationArgs( + MultiLevelTemplateArgumentList &Result, const NamedDecl *D, + const DeclContext *DC = nullptr, bool Final = false, + std::optional> Innermost = std::nullopt, + bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr, + bool ForConstraintInstantiation = false, + bool SkipForSpecialization = false, + bool ForDefaultArgumentSubstitution = false); + /// RAII object to handle the state changes required to synthesize /// a function body. class SynthesizedFunctionScope { @@ -13342,7 +13354,7 @@ class Sema final : public SemaBase { ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); - // Unlike the above, this does not evaluates constraints. + // Unlike the above, this does not evaluate constraints. ExprResult SubstConstraintExprWithoutSatisfaction( Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); @@ -14463,10 +14475,10 @@ class Sema final : public SemaBase { const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange); - bool CheckInstantiatedFunctionTemplateConstraints( - SourceLocation PointOfInstantiation, FunctionDecl *Decl, - ArrayRef TemplateArgs, - ConstraintSatisfaction &Satisfaction); + bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation, +FunctionDecl *Decl, +ArrayRef TemplateArgs, +ConstraintSatisfaction &Satisfaction); /// \brief Emit diagnostics explaining why a constraint expression was deemed /// unsatisfied. diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 9800f75f676aaf..59a0575ca98036 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char { llvm::PointerUnion * findInstantiationOf(const Decl *D); +/// Similar to \p findInstantiationOf(), but it wouldn't assert if the +/// instantiation was not found within the current instantiation scope. This +/// is helpful for on-demand declaration instantiation. +llvm::PointerUnion * +findInstantiationUnsafe(const Decl *D); + void InstantiatedLocal(const Decl *D, Decl *Inst
[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/5] Reapply "[Clang] Implement CWG2369 "Ordering between constraints and substitution"" (#122130) This reverts commit 3972ed57088f6515b787d7d38dec03dc74e51827. --- clang/include/clang/Sema/Sema.h | 22 +++- clang/include/clang/Sema/Template.h | 6 + clang/lib/Sema/SemaConcept.cpp| 47 ++- clang/lib/Sema/SemaTemplateDeduction.cpp | 49 +--- clang/lib/Sema/SemaTemplateDeductionGuide.cpp | 8 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 -- clang/lib/Sema/TreeTransform.h| 2 +- clang/test/CXX/drs/cwg23xx.cpp| 29 + clang/test/CXX/drs/cwg26xx.cpp| 2 +- clang/test/CXX/drs/cwg27xx.cpp| 20 +++ .../expr.prim.req/nested-requirement.cpp | 2 +- .../constrant-satisfaction-conversions.cpp| 6 +- .../SemaCXX/concept-crash-on-diagnostic.cpp | 2 +- clang/test/SemaCXX/cxx20-ctad-type-alias.cpp | 2 +- clang/test/SemaCXX/cxx23-assume.cpp | 6 +- clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 2 +- clang/test/SemaCXX/lambda-unevaluated.cpp | 4 +- .../SemaTemplate/concepts-recursive-inst.cpp | 4 +- .../SemaTemplate/cxx2a-constraint-exprs.cpp | 2 +- clang/test/SemaTemplate/deduction-guide.cpp | 5 - .../nested-implicit-deduction-guides.cpp | 8 +- clang/www/cxx_dr_status.html | 8 +- 22 files changed, 289 insertions(+), 62 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index a41f16f6dc8c9b..18fd95f77ec227 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13062,6 +13062,7 @@ class Sema final : public SemaBase { /// /// \param SkipForSpecialization when specified, any template specializations /// in a traversal would be ignored. + /// /// \param ForDefaultArgumentSubstitution indicates we should continue looking /// when encountering a specialized member function template, rather than /// returning immediately. @@ -13073,6 +13074,17 @@ class Sema final : public SemaBase { bool SkipForSpecialization = false, bool ForDefaultArgumentSubstitution = false); + /// Apart from storing the result to \p Result, this behaves the same as + /// another overload. + void getTemplateInstantiationArgs( + MultiLevelTemplateArgumentList &Result, const NamedDecl *D, + const DeclContext *DC = nullptr, bool Final = false, + std::optional> Innermost = std::nullopt, + bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr, + bool ForConstraintInstantiation = false, + bool SkipForSpecialization = false, + bool ForDefaultArgumentSubstitution = false); + /// RAII object to handle the state changes required to synthesize /// a function body. class SynthesizedFunctionScope { @@ -13342,7 +13354,7 @@ class Sema final : public SemaBase { ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); - // Unlike the above, this does not evaluates constraints. + // Unlike the above, this does not evaluate constraints. ExprResult SubstConstraintExprWithoutSatisfaction( Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); @@ -14463,10 +14475,10 @@ class Sema final : public SemaBase { const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange); - bool CheckInstantiatedFunctionTemplateConstraints( - SourceLocation PointOfInstantiation, FunctionDecl *Decl, - ArrayRef TemplateArgs, - ConstraintSatisfaction &Satisfaction); + bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation, +FunctionDecl *Decl, +ArrayRef TemplateArgs, +ConstraintSatisfaction &Satisfaction); /// \brief Emit diagnostics explaining why a constraint expression was deemed /// unsatisfied. diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 9800f75f676aaf..59a0575ca98036 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char { llvm::PointerUnion * findInstantiationOf(const Decl *D); +/// Similar to \p findInstantiationOf(), but it wouldn't assert if the +/// instantiation was not found within the current instantiation scope. This +/// is helpful for on-demand declaration instantiation. +llvm::PointerUnion * +findInstantiationUnsafe(const Decl *D); + void InstantiatedLocal(const Decl *D, Decl *Inst
[clang] 854cbbf - [clang][analyzer] Split NullDereferenceChecker into modeling and reporting (#122139)
Author: Balázs Kéri Date: 2025-01-10T11:17:06+01:00 New Revision: 854cbbf4a8e7e98b7461eae2c2a37cfa767f791c URL: https://github.com/llvm/llvm-project/commit/854cbbf4a8e7e98b7461eae2c2a37cfa767f791c DIFF: https://github.com/llvm/llvm-project/commit/854cbbf4a8e7e98b7461eae2c2a37cfa767f791c.diff LOG: [clang][analyzer] Split NullDereferenceChecker into modeling and reporting (#122139) The checker currently reports beneath the null dereference dereferences of undefined value and of label addresses. If we want to add more kinds of invalid dereferences (or split the existing functionality) it is more useful to make it separate checkers. To make this possible the existing checker is split into a DereferenceModeling part and a NullDereference checker that actually only switches on the check of null dereference. This is similar architecture as in MallocChecker and CStringChecker. The change is almost NFC but a new (modeling) checker is added. If the NullDereference checker is turned off the found invalid dereferences will still stop the analysis without emitted warning (this is different compared to the old behavior). Added: Modified: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp clang/test/Analysis/analyzer-enabled-checkers.c clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c Removed: diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index b34e940682fc5e..1361da46c3c81d 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -206,7 +206,12 @@ def CallAndMessageChecker : Checker<"CallAndMessage">, Documentation, Dependencies<[CallAndMessageModeling]>; -def DereferenceChecker : Checker<"NullDereference">, +def DereferenceModeling : Checker<"DereferenceModeling">, + HelpText<"General support for dereference related checkers">, + Documentation, + Hidden; + +def NullDereferenceChecker : Checker<"NullDereference">, HelpText<"Check for dereferences of null pointers">, CheckerOptions<[ CmdLineOption, "true", Released> ]>, - Documentation; + Documentation, + Dependencies<[DereferenceModeling]>; def NonNullParamChecker : Checker<"NonNullParamChecker">, HelpText<"Check for null pointers passed as arguments to a function whose " diff --git a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp index 0355eede75eae7..e9e2771c739b60 100644 --- a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -33,12 +33,6 @@ class DereferenceChecker EventDispatcher > { enum DerefKind { NullPointer, UndefinedPointerValue, AddressOfLabel }; - BugType BT_Null{this, "Dereference of null pointer", categories::LogicError}; - BugType BT_Undef{this, "Dereference of undefined pointer value", - categories::LogicError}; - BugType BT_Label{this, "Dereference of the address of a label", - categories::LogicError}; - void reportBug(DerefKind K, ProgramStateRef State, const Stmt *S, CheckerContext &C) const; @@ -56,6 +50,12 @@ class DereferenceChecker bool loadedFrom = false); bool SuppressAddressSpaces = false; + + bool CheckNullDereference = false; + + std::unique_ptr BT_Null; + std::unique_ptr BT_Undef; + std::unique_ptr BT_Label; }; } // end anonymous namespace @@ -155,22 +155,27 @@ static bool isDeclRefExprToReference(const Expr *E) { void DereferenceChecker::reportBug(DerefKind K, ProgramStateRef State, const Stmt *S, CheckerContext &C) const { + if (!CheckNullDereference) { +C.addSink(); +return; + } + const BugType *BT = nullptr; llvm::StringRef DerefStr1; llvm::StringRef DerefStr2; switch (K) { case DerefKind::NullPointer: -BT = &BT_Null; +BT = BT_Null.get(); DerefStr1 = " results in a null pointer dereference"; DerefStr2 = " results in a dereference of a null pointer"; break; case DerefKind::UndefinedPointerValue: -BT = &BT_Undef; +BT = BT_Undef.get(); DerefStr1 = " results in an undefined pointer dereference"; DerefStr2 = " results in a dereference of an undefined pointer value"; break; case DerefKind::AddressOfLabel: -BT = &BT_Label; +BT = BT_Label.get(); DerefStr1 = " results in an undefined pointer dereference"; DerefStr2 = " results in a dereference of an address of a label"; break; @@ -351,12 +356,30 @@ void DereferenceChecker::checkBind(SVal L, SVal V, const Stmt *S, C.addTransition(State, this); } -void ent
[clang] [clang][analyzer] Split NullDereferenceChecker into modeling and reporting (PR #122139)
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/122139 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] [Modules] Delay reading type source info of the preferred_name attribute. (PR #122250)
https://github.com/VitaNuo updated https://github.com/llvm/llvm-project/pull/122250 >From 0a615576181a538bc0d8eff6499ad87cbdeb89c3 Mon Sep 17 00:00:00 2001 From: Viktoriia Bakalova Date: Thu, 9 Jan 2025 09:36:35 +0100 Subject: [PATCH 1/6] [WIP] Delay reading type source info of the preferred_name attribute. --- clang/include/clang/Serialization/ASTReader.h | 18 - .../clang/Serialization/ASTRecordReader.h | 7 ++ clang/lib/Serialization/ASTReader.cpp | 25 +++ clang/lib/Serialization/ASTReaderDecl.cpp | 72 --- clang/lib/Serialization/ASTWriter.cpp | 5 +- clang/test/Modules/preferred_name.cppm| 13 clang/test/Modules/preferred_name_2.cppm | 47 7 files changed, 163 insertions(+), 24 deletions(-) create mode 100644 clang/test/Modules/preferred_name_2.cppm diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index f739fe688c110d..3c79a4c86a5617 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -13,7 +13,10 @@ #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H #define LLVM_CLANG_SERIALIZATION_ASTREADER_H +#include "clang/AST/DeclID.h" +#include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/Type.h" +#include "clang/Basic/AttributeCommonInfo.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/IdentifierTable.h" @@ -1156,6 +1159,19 @@ class ASTReader SmallVector, 16> PendingDeducedVarTypes; + struct PendingPreferredNameAttribute { +Decl* D; +AttributeCommonInfo Info; +serialization::TypeID TypeID; +bool isInherited; +bool isImplicit; +bool isPackExpansion; +SourceLocation ElaboratedTypedefSourceLocation; +NestedNameSpecifierLoc NNS; +SourceLocation TypedefSourceLocation; + }; + std::deque PendingPreferredNameAttributes; + /// The list of redeclaration chains that still need to be /// reconstructed, and the local offset to the corresponding list /// of redeclarations. @@ -1419,7 +1435,7 @@ class ASTReader const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const; -private: + private: struct ImportedModule { ModuleFile *Mod; ModuleFile *ImportedBy; diff --git a/clang/include/clang/Serialization/ASTRecordReader.h b/clang/include/clang/Serialization/ASTRecordReader.h index 2561418b78ca7f..f476d72fcf9e71 100644 --- a/clang/include/clang/Serialization/ASTRecordReader.h +++ b/clang/include/clang/Serialization/ASTRecordReader.h @@ -337,6 +337,13 @@ class ASTRecordReader /// Reads attributes from the current stream position, advancing Idx. void readAttributes(AttrVec &Attrs); + /// Reads one attribute from the current stream position, advancing Idx. + Attr *readAttr(Decl *D); + + /// Reads attributes from the current stream position, advancing Idx. + void readAttributes(AttrVec &Attrs, Decl *D); + + /// Read an BTFTypeTagAttr object. BTFTypeTagAttr *readBTFTypeTagAttr() { return cast(readAttr()); diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index ec85fad3389a1c..4ee04552f13a96 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -23,6 +23,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclGroup.h" +#include "clang/AST/DeclID.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/DeclarationName.h" @@ -41,6 +42,7 @@ #include "clang/AST/TypeLocVisitor.h" #include "clang/AST/UnresolvedSet.h" #include "clang/Basic/ASTSourceDescriptor.h" +#include "clang/Basic/AttributeCommonInfo.h" #include "clang/Basic/CommentOptions.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticError.h" @@ -9860,6 +9862,29 @@ void ASTReader::finishPendingActions() { } PendingDeducedVarTypes.clear(); +ASTContext &Context = getContext(); +for (unsigned I = 0; I != PendingPreferredNameAttributes.size(); ++I) { + auto *D = PendingPreferredNameAttributes[I].D; + QualType InfoTy = GetType(PendingPreferredNameAttributes[I].TypeID); + TypeSourceInfo *TInfo = nullptr; + if (!InfoTy.isNull()) { +TInfo = getContext().CreateTypeSourceInfo(InfoTy); +// TODO - this piece doesn't work yet +ElaboratedTypeLoc &Loc = (ElaboratedTypeLoc)TInfo->getTypeLoc(); + Loc.setElaboratedKeywordLoc(PendingPreferredNameAttributes[I].ElaboratedTypedefSourceLocation); +Loc.setQualifierLoc(PendingPreferredNameAttributes[I].NNS); + Loc.setNameLoc(PendingPreferredNameAttributes[I].TypedefSourceLocation); + } + + AttrVec &Attrs = getContext().getDeclAttrs(D); + PreferredNameAttr *New = new (Context) PreferredNameAttr(Context, PendingPreferredNameAttributes[I].Info, TInfo)
[clang] 3def49c - [AMDGPU] Remove s_wakeup_barrier instruction (#122277)
Author: Mirko Brkušanin Date: 2025-01-10T11:30:22+01:00 New Revision: 3def49cb64ec1298290724081bd37dbdeb2ea5f8 URL: https://github.com/llvm/llvm-project/commit/3def49cb64ec1298290724081bd37dbdeb2ea5f8 DIFF: https://github.com/llvm/llvm-project/commit/3def49cb64ec1298290724081bd37dbdeb2ea5f8.diff LOG: [AMDGPU] Remove s_wakeup_barrier instruction (#122277) Added: Modified: clang/include/clang/Basic/BuiltinsAMDGPU.def clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl llvm/include/llvm/IR/IntrinsicsAMDGPU.td llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp llvm/lib/Target/AMDGPU/SIISelLowering.cpp llvm/lib/Target/AMDGPU/SOPInstructions.td llvm/test/CodeGen/AMDGPU/s-barrier.ll llvm/test/MC/AMDGPU/gfx12_asm_sop1.s llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_sop1.txt Removed: diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 14c1746716cdd6..1b29a8e359c205 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -489,7 +489,6 @@ TARGET_BUILTIN(__builtin_amdgcn_s_barrier_wait, "vIs", "n", "gfx12-insts") TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal_isfirst, "bIi", "n", "gfx12-insts") TARGET_BUILTIN(__builtin_amdgcn_s_barrier_init, "vv*i", "n", "gfx12-insts") TARGET_BUILTIN(__builtin_amdgcn_s_barrier_join, "vv*", "n", "gfx12-insts") -TARGET_BUILTIN(__builtin_amdgcn_s_wakeup_barrier, "vv*", "n", "gfx12-insts") TARGET_BUILTIN(__builtin_amdgcn_s_barrier_leave, "vIs", "n", "gfx12-insts") TARGET_BUILTIN(__builtin_amdgcn_s_get_barrier_state, "Uii", "n", "gfx12-insts") TARGET_BUILTIN(__builtin_amdgcn_s_get_named_barrier_state, "Uiv*", "n", "gfx12-insts") diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl index b1866a8e492c84..5b5ae419f0a4a9 100644 --- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl @@ -173,21 +173,6 @@ void test_s_barrier_join(void *bar) __builtin_amdgcn_s_barrier_join(bar); } -// CHECK-LABEL: @test_s_wakeup_barrier( -// CHECK-NEXT: entry: -// CHECK-NEXT:[[BAR_ADDR:%.*]] = alloca ptr, align 8, addrspace(5) -// CHECK-NEXT:[[BAR_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[BAR_ADDR]] to ptr -// CHECK-NEXT:store ptr [[BAR:%.*]], ptr [[BAR_ADDR_ASCAST]], align 8 -// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[BAR_ADDR_ASCAST]], align 8 -// CHECK-NEXT:[[TMP1:%.*]] = addrspacecast ptr [[TMP0]] to ptr addrspace(3) -// CHECK-NEXT:call void @llvm.amdgcn.s.wakeup.barrier(ptr addrspace(3) [[TMP1]]) -// CHECK-NEXT:ret void -// -void test_s_wakeup_barrier(void *bar) -{ - __builtin_amdgcn_s_wakeup_barrier(bar); -} - // CHECK-LABEL: @test_s_barrier_leave( // CHECK-NEXT: entry: // CHECK-NEXT:call void @llvm.amdgcn.s.barrier.leave(i16 1) diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td index 92418b9104ad14..b930d6983e2251 100644 --- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td +++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td @@ -284,12 +284,6 @@ def int_amdgcn_s_barrier_join : ClangBuiltin<"__builtin_amdgcn_s_barrier_join">, Intrinsic<[], [local_ptr_ty], [IntrNoMem, IntrHasSideEffects, IntrConvergent, IntrWillReturn, IntrNoCallback, IntrNoFree]>; -// void @llvm.amdgcn.s.wakeup.barrier(ptr addrspace(3) %barrier) -// The %barrier argument must be uniform, otherwise behavior is undefined. -def int_amdgcn_s_wakeup_barrier : ClangBuiltin<"__builtin_amdgcn_s_wakeup_barrier">, - Intrinsic<[], [local_ptr_ty], [IntrNoMem, IntrHasSideEffects, IntrConvergent, IntrWillReturn, -IntrNoCallback, IntrNoFree]>; - // void @llvm.amdgcn.s.barrier.wait(i16 %barrierType) def int_amdgcn_s_barrier_wait : ClangBuiltin<"__builtin_amdgcn_s_barrier_wait">, Intrinsic<[], [llvm_i16_ty], [ImmArg>, IntrNoMem, IntrHasSideEffects, IntrConvergent, diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp index 1e654b260cbfa5..926c1e4b23b4a1 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp @@ -2239,7 +2239,6 @@ bool AMDGPUInstructionSelector::selectG_INTRINSIC_W_SIDE_EFFECTS( case Intrinsic::amdgcn_s_barrier_signal_var: return selectNamedBarrierInit(I, IntrinsicID); case Intrinsic::amdgcn_s_barrier_join: - case Intrinsic::amdgcn_s_wakeup_barrier: case Intrinsic::amdgcn_s_get_named_barrier_state: return selectNamedBarrierInst(I, IntrinsicID); case Intrinsic::amdgcn_s_get_barrier_state: @@ -5838,8 +5837,6 @@ unsigned getNamed
[clang] [WIP] [Modules] Delay reading type source info of the preferred_name attribute. (PR #122250)
https://github.com/VitaNuo updated https://github.com/llvm/llvm-project/pull/122250 >From 0a615576181a538bc0d8eff6499ad87cbdeb89c3 Mon Sep 17 00:00:00 2001 From: Viktoriia Bakalova Date: Thu, 9 Jan 2025 09:36:35 +0100 Subject: [PATCH 1/7] [WIP] Delay reading type source info of the preferred_name attribute. --- clang/include/clang/Serialization/ASTReader.h | 18 - .../clang/Serialization/ASTRecordReader.h | 7 ++ clang/lib/Serialization/ASTReader.cpp | 25 +++ clang/lib/Serialization/ASTReaderDecl.cpp | 72 --- clang/lib/Serialization/ASTWriter.cpp | 5 +- clang/test/Modules/preferred_name.cppm| 13 clang/test/Modules/preferred_name_2.cppm | 47 7 files changed, 163 insertions(+), 24 deletions(-) create mode 100644 clang/test/Modules/preferred_name_2.cppm diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index f739fe688c110d..3c79a4c86a5617 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -13,7 +13,10 @@ #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H #define LLVM_CLANG_SERIALIZATION_ASTREADER_H +#include "clang/AST/DeclID.h" +#include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/Type.h" +#include "clang/Basic/AttributeCommonInfo.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/IdentifierTable.h" @@ -1156,6 +1159,19 @@ class ASTReader SmallVector, 16> PendingDeducedVarTypes; + struct PendingPreferredNameAttribute { +Decl* D; +AttributeCommonInfo Info; +serialization::TypeID TypeID; +bool isInherited; +bool isImplicit; +bool isPackExpansion; +SourceLocation ElaboratedTypedefSourceLocation; +NestedNameSpecifierLoc NNS; +SourceLocation TypedefSourceLocation; + }; + std::deque PendingPreferredNameAttributes; + /// The list of redeclaration chains that still need to be /// reconstructed, and the local offset to the corresponding list /// of redeclarations. @@ -1419,7 +1435,7 @@ class ASTReader const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const; -private: + private: struct ImportedModule { ModuleFile *Mod; ModuleFile *ImportedBy; diff --git a/clang/include/clang/Serialization/ASTRecordReader.h b/clang/include/clang/Serialization/ASTRecordReader.h index 2561418b78ca7f..f476d72fcf9e71 100644 --- a/clang/include/clang/Serialization/ASTRecordReader.h +++ b/clang/include/clang/Serialization/ASTRecordReader.h @@ -337,6 +337,13 @@ class ASTRecordReader /// Reads attributes from the current stream position, advancing Idx. void readAttributes(AttrVec &Attrs); + /// Reads one attribute from the current stream position, advancing Idx. + Attr *readAttr(Decl *D); + + /// Reads attributes from the current stream position, advancing Idx. + void readAttributes(AttrVec &Attrs, Decl *D); + + /// Read an BTFTypeTagAttr object. BTFTypeTagAttr *readBTFTypeTagAttr() { return cast(readAttr()); diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index ec85fad3389a1c..4ee04552f13a96 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -23,6 +23,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclGroup.h" +#include "clang/AST/DeclID.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/DeclarationName.h" @@ -41,6 +42,7 @@ #include "clang/AST/TypeLocVisitor.h" #include "clang/AST/UnresolvedSet.h" #include "clang/Basic/ASTSourceDescriptor.h" +#include "clang/Basic/AttributeCommonInfo.h" #include "clang/Basic/CommentOptions.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticError.h" @@ -9860,6 +9862,29 @@ void ASTReader::finishPendingActions() { } PendingDeducedVarTypes.clear(); +ASTContext &Context = getContext(); +for (unsigned I = 0; I != PendingPreferredNameAttributes.size(); ++I) { + auto *D = PendingPreferredNameAttributes[I].D; + QualType InfoTy = GetType(PendingPreferredNameAttributes[I].TypeID); + TypeSourceInfo *TInfo = nullptr; + if (!InfoTy.isNull()) { +TInfo = getContext().CreateTypeSourceInfo(InfoTy); +// TODO - this piece doesn't work yet +ElaboratedTypeLoc &Loc = (ElaboratedTypeLoc)TInfo->getTypeLoc(); + Loc.setElaboratedKeywordLoc(PendingPreferredNameAttributes[I].ElaboratedTypedefSourceLocation); +Loc.setQualifierLoc(PendingPreferredNameAttributes[I].NNS); + Loc.setNameLoc(PendingPreferredNameAttributes[I].TypedefSourceLocation); + } + + AttrVec &Attrs = getContext().getDeclAttrs(D); + PreferredNameAttr *New = new (Context) PreferredNameAttr(Context, PendingPreferredNameAttributes[I].Info, TInfo)
[clang] [llvm] [AMDGPU] Remove s_wakeup_barrier instruction (PR #122277)
https://github.com/mbrkusanin closed https://github.com/llvm/llvm-project/pull/122277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits