[clang] [Tooling] Simplify code with StringMap::operator[] (NFC) (PR #113071)
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/113071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] prevent setting default lexical access specifier for missing primary declarations (PR #112424)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/112424 >From a22c6bae4f42f42e67f8e0c2b1f914e50d140099 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Tue, 15 Oct 2024 22:43:24 +0300 Subject: [PATCH 1/2] [Clang] prevent setting default lexical access specifier for missing primary declarations --- clang/docs/ReleaseNotes.rst | 2 ++ clang/lib/Sema/SemaAccess.cpp | 3 ++- clang/test/SemaCXX/enum.cpp | 8 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 817e3abef8d566..64ffdcde045a3a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -517,6 +517,8 @@ Bug Fixes to C++ Support certain situations. (#GH47400), (#GH90896) - Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441) - During the lookup for a base class name, non-type names are ignored. (#GH16855) +- Fixed an assertion failure when the default lexical access specifier was set for missing + primary declarations. (#GH112208) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index df6edb21a50dee..8b4a5b70669d84 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -39,7 +39,8 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl, AccessSpecifier LexicalAS) { if (!PrevMemberDecl) { // Use the lexical access specifier. -MemberDecl->setAccess(LexicalAS); +if (LexicalAS != AS_none) + MemberDecl->setAccess(LexicalAS); return false; } diff --git a/clang/test/SemaCXX/enum.cpp b/clang/test/SemaCXX/enum.cpp index 9c398cc8da886c..44042d8bf5cfc8 100644 --- a/clang/test/SemaCXX/enum.cpp +++ b/clang/test/SemaCXX/enum.cpp @@ -143,3 +143,11 @@ struct PR28903 { }) }; }; + +namespace GH112208 { +class C { + enum E { e = 0 }; + void f(int, enum E;); // expected-error {{ISO C++ forbids forward references to 'enum' types}} \ +// expected-error {{unexpected ';' before ')'}} +}; +} >From 83ce02f2e0c7a4f5e8e774694240a9c2939bc2fa Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Fri, 18 Oct 2024 14:55:47 +0300 Subject: [PATCH 2/2] prevent assertion failure by handling invalid enum forward declarations --- clang/docs/ReleaseNotes.rst | 3 +-- clang/lib/Sema/SemaAccess.cpp | 3 +-- clang/lib/Sema/SemaDecl.cpp | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 64ffdcde045a3a..3fd37663ca7bc6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -517,8 +517,7 @@ Bug Fixes to C++ Support certain situations. (#GH47400), (#GH90896) - Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441) - During the lookup for a base class name, non-type names are ignored. (#GH16855) -- Fixed an assertion failure when the default lexical access specifier was set for missing - primary declarations. (#GH112208) +- Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index 8b4a5b70669d84..df6edb21a50dee 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -39,8 +39,7 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl, AccessSpecifier LexicalAS) { if (!PrevMemberDecl) { // Use the lexical access specifier. -if (LexicalAS != AS_none) - MemberDecl->setAccess(LexicalAS); +MemberDecl->setAccess(LexicalAS); return false; } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index fece22c663d00c..9eb3d06289e88f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -17942,6 +17942,8 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, << Name; Invalid = true; } + if (TUK == TagUseKind::Declaration && Name) +Invalid = true; } else if (!PrevDecl) { Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)
yonghong-song wrote: For commit 2, I see the following commit messages: ``` Unlike existing atomic operations that only support BPF_W (32-bit) and BPF_DW (64-bit) size modifiers, load-acquires and store-releases also support BPF_B (8-bit) and BPF_H (16-bit). An 8- or 16-bit load-acquire zero-extends the value before writing it to a 32-bit register, just like ARM64 instruction LDAPRH and friends. ``` Currently for load, we have class BPF_MEM and BPF_MEMSX whre BPF_MEM represents unsigned load and BPF_MEMSX represents load with sign-extension. If we replace BPF_MEM/BPF_MEMSX with BPF_ATOMIC, then we lose distinction between unsigned and signed for 8- and 16-bit loads. In the above, you will do unsigned load extension. But what about signed extension load variant? https://github.com/llvm/llvm-project/pull/108636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC (PR #113104)
@@ -1110,6 +1110,10 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty, isa(Base)) { return true; } + if (CGM.getTarget().getTriple().isX86() && + CGM.getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts)) { efriedma-quic wrote: This looks like it might affect non-vectorcall calls; can you check (and add a testcase)? Please also add test coverage for 32-bit x86. https://github.com/llvm/llvm-project/pull/113104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Narrow pointer in UO_Deref unary operators (PR #113089)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/113089 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] df8b785 - [clang][bytecode] Narrow pointer in UO_Deref unary operators (#113089)
Author: Timm Baeder Date: 2024-10-21T07:51:49+02:00 New Revision: df8b785838a2db01b4d056e603f7317209accefb URL: https://github.com/llvm/llvm-project/commit/df8b785838a2db01b4d056e603f7317209accefb DIFF: https://github.com/llvm/llvm-project/commit/df8b785838a2db01b4d056e603f7317209accefb.diff LOG: [clang][bytecode] Narrow pointer in UO_Deref unary operators (#113089) Otherwise we treat this like an array element even though we should treat it as a single object. Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/lib/AST/ByteCode/Pointer.cpp clang/test/AST/ByteCode/cxx98.cpp Removed: diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 672fa7fc25d6d0..3f068aa8c189a9 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -5738,9 +5738,17 @@ bool Compiler::VisitUnaryOperator(const UnaryOperator *E) { // We should already have a pointer when we get here. return this->delegate(SubExpr); case UO_Deref: // *x -if (DiscardResult) +if (DiscardResult) { + // assert(false); return this->discard(SubExpr); -return this->visit(SubExpr); +} + +if (!this->visit(SubExpr)) + return false; +if (classifyPrim(SubExpr) == PT_Ptr) + return this->emitNarrowPtr(E); +return true; + case UO_Not: // ~x if (!T) return this->emitError(E); diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 75b00dcb2ab242..c9de039c195d94 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -635,7 +635,7 @@ std::optional Pointer::toRValue(const Context &Ctx, // Return the composite type. APValue Result; - if (!Composite(getType(), *this, Result)) + if (!Composite(ResultType, *this, Result)) return std::nullopt; return Result; } diff --git a/clang/test/AST/ByteCode/cxx98.cpp b/clang/test/AST/ByteCode/cxx98.cpp index 471a58f8e05518..20f98d33c31c4f 100644 --- a/clang/test/AST/ByteCode/cxx98.cpp +++ b/clang/test/AST/ByteCode/cxx98.cpp @@ -54,3 +54,8 @@ _Static_assert(a == 0, ""); // both-error {{static assertion expression is not a struct SelfReference { SelfReference &r; }; extern SelfReference self_reference_1; SelfReference self_reference_2 = {self_reference_1}; + +struct PR65784s{ + int *ptr; +} const PR65784[] = {(int *)""}; +PR65784s PR65784f() { return *PR65784; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] New clang-format-indent-mode for Emacs (PR #78904)
owenca wrote: > That's a great idea, I'll have to look into that more! @amygrinn Do you still need to go forward with this PR? https://github.com/llvm/llvm-project/pull/78904 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ai32_bextr builtins for integer args (PR #113128)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/113128 None >From 89a268bbdbc0194c9d46abf7607b458320cd27ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 21 Oct 2024 07:42:40 +0200 Subject: [PATCH] [clang][bytecode] Check ai32_bextr builtins for integer args --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 4 1 file changed, 4 insertions(+) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index c7b9dac5fec80c..10e33c14f4b455 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1253,6 +1253,10 @@ static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->getType()->isIntegerType() || + !Call->getArg(1)->getType()->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType IndexT = *S.Ctx.classify(Call->getArg(1)); APSInt Val = peekToAPSInt(S.Stk, ValT, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ai32_bextr builtins for integer args (PR #113128)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/113128.diff 1 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+4) ``diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index c7b9dac5fec80c..10e33c14f4b455 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1253,6 +1253,10 @@ static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->getType()->isIntegerType() || + !Call->getArg(1)->getType()->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType IndexT = *S.Ctx.classify(Call->getArg(1)); APSInt Val = peekToAPSInt(S.Stk, ValT, `` https://github.com/llvm/llvm-project/pull/113128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove support for RenderScript (PR #112916)
tbaederr wrote: I think this reference should go as well: https://github.com/llvm/llvm-project/blob/main/clang/www/index.html#L20 ? https://github.com/llvm/llvm-project/pull/112916 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix a crash issue that caused by handling of fields with initializers in nested anonymous unions (PR #113049)
@@ -115,3 +115,14 @@ namespace nested_union { // of Test3, or we should exclude f(Test3) as a candidate. static_assert(f({1}) == 2, ""); // expected-error {{call to 'f' is ambiguous}} } + +// Fix crash issue https://github.com/llvm/llvm-project/issues/112560. +// Make sure clang compiles the following code without crashing: +namespace GH112560 { +union U { + int f = ; // expected-error {{expected expression}} efriedma-quic wrote: As far as I can tell, the reason the code in SemaInit is getting confused is that the union is marked "hasInClassInitializer" because of the initializer... but then there isn't actually an initializer anywhere because we failed to parse it. I think hasInClassInitializer() on RecordDecl needs to be consistent with hasInClassInitializer() on FieldDecl. If hasInClassInitializer is true, there should be an initializer somewhere. Either we should pretend the user didn't write the "=", or we should construct a RecoveryExpr to represent the missing initializer. Adding extra handling to every bit of code that checks hasInClassInitializer spreads out error handling to places it shouldn't exist. https://github.com/llvm/llvm-project/pull/113049 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 615a5eb - [clang][bytecode] Check ai32_bextr builtins for integer args (#113128)
Author: Timm Baeder Date: 2024-10-21T08:15:51+02:00 New Revision: 615a5eb02c91ef78f59461f842873617dd187450 URL: https://github.com/llvm/llvm-project/commit/615a5eb02c91ef78f59461f842873617dd187450 DIFF: https://github.com/llvm/llvm-project/commit/615a5eb02c91ef78f59461f842873617dd187450.diff LOG: [clang][bytecode] Check ai32_bextr builtins for integer args (#113128) Added: Modified: clang/lib/AST/ByteCode/InterpBuiltin.cpp Removed: diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index c7b9dac5fec80c..10e33c14f4b455 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1253,6 +1253,10 @@ static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->getType()->isIntegerType() || + !Call->getArg(1)->getType()->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType IndexT = *S.Ctx.classify(Call->getArg(1)); APSInt Val = peekToAPSInt(S.Stk, ValT, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ai32_bextr builtins for integer args (PR #113128)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/113128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d80b9cf - [Clang][ASTMatchers] Add visibility macros to variables declared by macros (#110206)
Author: Thomas Fransham Date: 2024-10-21T08:14:52+03:00 New Revision: d80b9cf713fd1698641c5b265de6b66618991476 URL: https://github.com/llvm/llvm-project/commit/d80b9cf713fd1698641c5b265de6b66618991476 DIFF: https://github.com/llvm/llvm-project/commit/d80b9cf713fd1698641c5b265de6b66618991476.diff LOG: [Clang][ASTMatchers] Add visibility macros to variables declared by macros (#110206) This will fix missing symbols for ASTMatchersTests on windows when building with CLANG_LINK_CLANG and explicit visibility macros are used. This PR depends on macros that will be be added in #108276 This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM\Clang plugins on window. Added: Modified: clang/include/clang/ASTMatchers/ASTMatchersMacros.h Removed: diff --git a/clang/include/clang/ASTMatchers/ASTMatchersMacros.h b/clang/include/clang/ASTMatchers/ASTMatchersMacros.h index 592a3898a29591..f781e0a565eb36 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersMacros.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersMacros.h @@ -49,6 +49,8 @@ #ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHERSMACROS_H #define LLVM_CLANG_ASTMATCHERS_ASTMATCHERSMACROS_H +#include "clang/Support/Compiler.h" + /// AST_MATCHER_FUNCTION(ReturnType, DefineMatcher) { ... } /// defines a zero parameter function named DefineMatcher() that returns a /// ReturnType object. @@ -367,7 +369,7 @@ static QualType (T::*value())() const { return &T::FunctionName; } \ }; \ } \ - extern const ::clang::ast_matchers::internal:: \ + CLANG_ABI extern const ::clang::ast_matchers::internal:: \ TypeTraversePolymorphicMatcher< \ QualType, \ ::clang::ast_matchers::internal::TypeMatcher##MatcherName##Getter, \ @@ -407,7 +409,7 @@ static TypeLoc (T::*value())() const { return &T::FunctionName##Loc; } \ }; \ } \ - extern const ::clang::ast_matchers::internal:: \ + CLANG_ABI extern const ::clang::ast_matchers::internal:: \ TypeTraversePolymorphicMatcher< \ TypeLoc, \ ::clang::ast_matchers::internal:: \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][ASTMatchers] Add visibility macros to variables declared by macros (PR #110206)
https://github.com/vgvassilev closed https://github.com/llvm/llvm-project/pull/110206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ia32_{pext, pdep} builtins for integer args (PR #113091)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/113091 >From 19bd55a4150c39fc29758c20fb31ac76d20beddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 20 Oct 2024 18:08:08 +0200 Subject: [PATCH] [clang][bytecode] Check ia32_{pext,pdep} builtins for integer args --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 8 1 file changed, 8 insertions(+) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index d4a8e6c2035ee5..c7b9dac5fec80c 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1331,6 +1331,10 @@ static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->getType()->isIntegerType() || + !Call->getArg(1)->getType()->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); @@ -1352,6 +1356,10 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->getType()->isIntegerType() || + !Call->getArg(1)->getType()->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5405ba5 - [clang][bytecode] Check ia32_{pext,pdep} builtins for integer args (#113091)
Author: Timm Baeder Date: 2024-10-20T19:37:41+02:00 New Revision: 5405ba50de6753e3969f4e6c690f53f2abb29b2f URL: https://github.com/llvm/llvm-project/commit/5405ba50de6753e3969f4e6c690f53f2abb29b2f DIFF: https://github.com/llvm/llvm-project/commit/5405ba50de6753e3969f4e6c690f53f2abb29b2f.diff LOG: [clang][bytecode] Check ia32_{pext,pdep} builtins for integer args (#113091) Added: Modified: clang/lib/AST/ByteCode/InterpBuiltin.cpp Removed: diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index d4a8e6c2035ee5..c7b9dac5fec80c 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1331,6 +1331,10 @@ static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->getType()->isIntegerType() || + !Call->getArg(1)->getType()->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); @@ -1352,6 +1356,10 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->getType()->isIntegerType() || + !Call->getArg(1)->getType()->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ia32_{pext, pdep} builtins for integer args (PR #113091)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/113091 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] [Modules] Support Reusable Modules Builder (PR #106683)
ChuanqiXu9 wrote: I'd like to land this in 2 weeks if no more comments came in. Given: - In our downstream, we've landed this patch for more than a year and it seems running well. And also in the open source world, I tried to send it to https://github.com/ChuanqiXu9/clangd-for-modules . Everyone experienced it didn't complain about it for bugs. So I believe this is well tested. - There are other following patches and I really wish we can have something workable in the next release. - This patch doesn't change the shape of modules support in clangd. The major change lives in ModulesBuilder.cpp, which we can think it as an implementation detail instead of some global things. For policy related comments, please sent it to https://discourse.llvm.org/t/rfc-directions-for-modules-support-in-clangd/78072/6 https://github.com/llvm/llvm-project/pull/106683 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)
@@ -94,3 +94,45 @@ template void g2(Ts... p1s) { void f1() { g(); } } // namespace GH61460 + +namespace GH112352 { + +template +constexpr bool foo = false; + +template +constexpr bool bar = false; + +template class> +constexpr bool baz = false; + +struct S { + template void foldExpr1() { +(void)[] { + ([] { +Is; +// Propagate up the flag ContainsUnexpandedParameterPack from VarDecl. +S var(foo); +foo; +bar; + } && + ...); +}; + } + + template class... TTPs> void foldExpr2() { +(void)[] { + ([] { +Is; +baz; zyn0217 wrote: Both work. Added to the test though https://github.com/llvm/llvm-project/pull/112896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/112896 >From 6caf16d6ce8eb939c91ed87493c2ccab82d38411 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 18 Oct 2024 20:22:08 +0800 Subject: [PATCH 1/3] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas --- clang/docs/ReleaseNotes.rst | 2 +- clang/lib/Sema/SemaTemplateVariadic.cpp | 49 ++-- clang/test/SemaCXX/lambda-pack-expansion.cpp | 40 3 files changed, 75 insertions(+), 16 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b430b2b0ee3187..d071c480f36dc7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -486,7 +486,7 @@ Bug Fixes to C++ Support - Clang no longer tries to capture non-odr used default arguments of template parameters of generic lambdas (#GH107048) - Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588) - Fix a crash when using ``source_location`` in the trailing return type of a lambda expression. (#GH67134) -- A follow-up fix was added for (#GH61460), as the previous fix was not entirely correct. (#GH86361) +- A follow-up fix was added for (#GH61460), as the previous fix was not entirely correct. (#GH86361), (#GH112352) - Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887) - Fixed a crash when clang tries to subtitute parameter pack while retaining the parameter pack. (#GH63819), (#GH107560) diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp index 19bd4547665835..151b328872bd75 100644 --- a/clang/lib/Sema/SemaTemplateVariadic.cpp +++ b/clang/lib/Sema/SemaTemplateVariadic.cpp @@ -41,7 +41,7 @@ namespace { unsigned DepthLimit = (unsigned)-1; #ifndef NDEBUG -bool ContainsFunctionParmPackExpr = false; +bool ContainsIntermediatePacks = false; #endif void addUnexpanded(NamedDecl *ND, SourceLocation Loc = SourceLocation()) { @@ -114,6 +114,11 @@ namespace { addUnexpanded(TTP); } +#ifndef NDEBUG + ContainsIntermediatePacks |= + (bool)Template.getAsSubstTemplateTemplateParmPack(); +#endif + return inherited::TraverseTemplateName(Template); } @@ -297,13 +302,28 @@ namespace { #ifndef NDEBUG bool TraverseFunctionParmPackExpr(FunctionParmPackExpr *) { - ContainsFunctionParmPackExpr = true; + ContainsIntermediatePacks = true; + return true; +} + +bool TraverseSubstNonTypeTemplateParmPackExpr( +SubstNonTypeTemplateParmPackExpr *) { + ContainsIntermediatePacks = true; + return true; +} + +bool VisitSubstTemplateTypeParmPackType(SubstTemplateTypeParmPackType *) { + ContainsIntermediatePacks = true; return true; } -bool containsFunctionParmPackExpr() const { - return ContainsFunctionParmPackExpr; +bool +VisitSubstTemplateTypeParmPackTypeLoc(SubstTemplateTypeParmPackTypeLoc) { + ContainsIntermediatePacks = true; + return true; } + +bool containsIntermediatePacks() const { return ContainsIntermediatePacks; } #endif }; } @@ -439,21 +459,20 @@ bool Sema::DiagnoseUnexpandedParameterPack(Expr *E, if (!E->containsUnexpandedParameterPack()) return false; - // FunctionParmPackExprs are special: - // - // 1) they're used to model DeclRefExprs to packs that have been expanded but - // had that expansion held off in the process of transformation. - // - // 2) they always have the unexpanded dependencies but don't introduce new - // unexpanded packs. - // - // We might encounter a FunctionParmPackExpr being a full expression, which a - // larger CXXFoldExpr would expand. SmallVector Unexpanded; CollectUnexpandedParameterPacksVisitor Visitor(Unexpanded); Visitor.TraverseStmt(E); - assert((!Unexpanded.empty() || Visitor.containsFunctionParmPackExpr()) && +#ifndef NDEBUG + // The expression might contain a type/subexpression that has been substituted + // but has the expansion held off, e.g. a FunctionParmPackExpr which a larger + // CXXFoldExpr would expand. It's only possible when expanding a lambda as a + // pattern of a fold expression, so don't fire on an empty result in that + // case. + bool LambdaReferencingOuterPacks = + getEnclosingLambdaOrBlock() && Visitor.containsIntermediatePacks(); + assert((!Unexpanded.empty() || LambdaReferencingOuterPacks) && "Unable to find unexpanded parameter packs"); +#endif return DiagnoseUnexpandedParameterPacks(E->getBeginLoc(), UPPC, Unexpanded); } diff --git a/clang/test/SemaCXX/lambda-pack-expansion.cpp b/clang/test/SemaCXX/lambda-pack-expansion.cpp index 0e60ecd8756600..7f7dd3bb095d57 100644 --- a/clang/test/SemaCXX/lambda-pack-expansion.cpp +++ b/clang/test/SemaCXX/lambda-pack-expansion.cpp @@ -94,3 +94,43 @@ template void g2(Ts... p1s) { void f1() { g(); }
[clang] [lld] [llvm] [mlir] [IR] Introduce `U` to `DataLayout` to represent undesirable address space if a target has it (PR #108786)
arsenm wrote: > More specifically, how do you expect Clang to figure this out when e.g. > compiling C++ for some AS rich target that decided to default to something > odd I do not expect clang to be using the datalayout to decide anything. That is not really the purpose of the datalayout. It does not provide semantic information to the frontend. The frontend needs to directly understand the source language semantics and the address spaces of the target. https://github.com/llvm/llvm-project/pull/108786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [mlir] [IR] Introduce `U` to `DataLayout` to represent undesirable address space if a target has it (PR #108786)
AlexVlx wrote: > > I do believe that this is a necessary bit of query-able information, > > especially from a Clang, for correctness reasons (more on that below). > > I don't think this buys frontends much. Clang still needs to understand the > full language address space -> target address space mapping. This would just > allow populating one entry generically > > > Ah, this is part of the challenge - we do indeed assume that 0 is flat, but > > Targets aren't bound by LangRef to use 0 to denote flat (and some, like > > SPIR / SPIR-V) do not > > As I mentioned above, SPIRV can just work its way out of this problem for its > IR. SPIR's only reason for existence is bitcode compatibility, so doing > anything with there will be quite a lot of work which will never > realistically happen. > > > I'm fine with adding the enforcement in LLVM that AS0 needs to be the flat > > AS, if a target has it, but the definition of a flat AS still needs to be > > set. If we do that, how will SPIR/SPIR-V work? > > This is the most generic wording I can come up with so far. Happy to hear > > more feedbacks. > > I would like to avoid adding additional special properties to AS0, or > defining the flat concept. This is all fine, let's ignore SPIR-V for a second (SPIR being relevant is debatable, and I'm not sure what its reason for being was, but I'm pretty sure nothing is being done with it), and assume that that gets fixed. What is there to prevent some other target coming in and doing the same thing (using 0 to represent some constrained / problematic AS), without placing any sort of additional constraints on 0 (the absence thereof being an issue as it stands), and without giving the FE a mechanism to at least attempt to get flat/flat-like AS? More specifically, how do you expect Clang to figure this out when e.g. compiling C++ for some AS rich target that decided to default to something odd (so querying the correspondent for LangAS::Default is not useful) and uses 0 to denote a special purpose AS (so the many uses of getUnqual/get with the AS argument defaulted end up doing something wrong)? There isn't an awful lot of guidance being provided, you don't want to update LangRef, and the "undesirable" wording is rather opaque to put it mildly. https://github.com/llvm/llvm-project/pull/108786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 490b7d1 - [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (#113083)
Author: Timm Baeder Date: 2024-10-20T17:44:48+02:00 New Revision: 490b7d12f6bef2c399fca83e6a6dde31be021913 URL: https://github.com/llvm/llvm-project/commit/490b7d12f6bef2c399fca83e6a6dde31be021913 DIFF: https://github.com/llvm/llvm-project/commit/490b7d12f6bef2c399fca83e6a6dde31be021913.diff LOG: [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (#113083) Added: Modified: clang/include/clang/AST/ExprCXX.h clang/lib/AST/ExprCXX.cpp Removed: diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 975bcdac5069b9..cfe3938f83847b 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -876,13 +876,13 @@ class CXXTypeidExpr : public Expr { /// Best-effort check if the expression operand refers to a most derived /// object. This is not a strong guarantee. - bool isMostDerived(ASTContext &Context) const; + bool isMostDerived(const ASTContext &Context) const; bool isTypeOperand() const { return Operand.is(); } /// Retrieves the type operand of this typeid() expression after /// various required adjustments (removing reference types, cv-qualifiers). - QualType getTypeOperand(ASTContext &Context) const; + QualType getTypeOperand(const ASTContext &Context) const; /// Retrieve source information for the type operand. TypeSourceInfo *getTypeOperandSourceInfo() const { diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 83ce404add5f50..a2c0c60d43dd14 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -147,7 +147,7 @@ bool CXXTypeidExpr::isPotentiallyEvaluated() const { return false; } -bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const { +bool CXXTypeidExpr::isMostDerived(const ASTContext &Context) const { assert(!isTypeOperand() && "Cannot call isMostDerived for typeid(type)"); const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context); if (const auto *DRE = dyn_cast(E)) { @@ -159,7 +159,7 @@ bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const { return false; } -QualType CXXTypeidExpr::getTypeOperand(ASTContext &Context) const { +QualType CXXTypeidExpr::getTypeOperand(const ASTContext &Context) const { assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); Qualifiers Quals; return Context.getUnqualifiedArrayType( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/113083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Narrow pointer in UO_Deref unary operators (PR #113089)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/113089 Otherwise we treat this like an array element even though we should treat it as a single object. >From 9ad54bebfd5c3572b3338e30c6a3047fb922c057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 20 Oct 2024 13:57:49 +0200 Subject: [PATCH] [clang][bytecode] Narrow pointer in UO_Deref unary operators Otherwise we treat this like an array element even though we should treat it as a single object. --- clang/lib/AST/ByteCode/Compiler.cpp | 12 ++-- clang/test/AST/ByteCode/cxx98.cpp | 5 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 672fa7fc25d6d0..3f068aa8c189a9 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -5738,9 +5738,17 @@ bool Compiler::VisitUnaryOperator(const UnaryOperator *E) { // We should already have a pointer when we get here. return this->delegate(SubExpr); case UO_Deref: // *x -if (DiscardResult) +if (DiscardResult) { + // assert(false); return this->discard(SubExpr); -return this->visit(SubExpr); +} + +if (!this->visit(SubExpr)) + return false; +if (classifyPrim(SubExpr) == PT_Ptr) + return this->emitNarrowPtr(E); +return true; + case UO_Not: // ~x if (!T) return this->emitError(E); diff --git a/clang/test/AST/ByteCode/cxx98.cpp b/clang/test/AST/ByteCode/cxx98.cpp index 471a58f8e05518..20f98d33c31c4f 100644 --- a/clang/test/AST/ByteCode/cxx98.cpp +++ b/clang/test/AST/ByteCode/cxx98.cpp @@ -54,3 +54,8 @@ _Static_assert(a == 0, ""); // both-error {{static assertion expression is not a struct SelfReference { SelfReference &r; }; extern SelfReference self_reference_1; SelfReference self_reference_2 = {self_reference_1}; + +struct PR65784s{ + int *ptr; +} const PR65784[] = {(int *)""}; +PR65784s PR65784f() { return *PR65784; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Narrow pointer in UO_Deref unary operators (PR #113089)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes Otherwise we treat this like an array element even though we should treat it as a single object. --- Full diff: https://github.com/llvm/llvm-project/pull/113089.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+10-2) - (modified) clang/test/AST/ByteCode/cxx98.cpp (+5) ``diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 672fa7fc25d6d0..3f068aa8c189a9 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -5738,9 +5738,17 @@ bool Compiler::VisitUnaryOperator(const UnaryOperator *E) { // We should already have a pointer when we get here. return this->delegate(SubExpr); case UO_Deref: // *x -if (DiscardResult) +if (DiscardResult) { + // assert(false); return this->discard(SubExpr); -return this->visit(SubExpr); +} + +if (!this->visit(SubExpr)) + return false; +if (classifyPrim(SubExpr) == PT_Ptr) + return this->emitNarrowPtr(E); +return true; + case UO_Not: // ~x if (!T) return this->emitError(E); diff --git a/clang/test/AST/ByteCode/cxx98.cpp b/clang/test/AST/ByteCode/cxx98.cpp index 471a58f8e05518..20f98d33c31c4f 100644 --- a/clang/test/AST/ByteCode/cxx98.cpp +++ b/clang/test/AST/ByteCode/cxx98.cpp @@ -54,3 +54,8 @@ _Static_assert(a == 0, ""); // both-error {{static assertion expression is not a struct SelfReference { SelfReference &r; }; extern SelfReference self_reference_1; SelfReference self_reference_2 = {self_reference_1}; + +struct PR65784s{ + int *ptr; +} const PR65784[] = {(int *)""}; +PR65784s PR65784f() { return *PR65784; } `` https://github.com/llvm/llvm-project/pull/113089 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20][Modules] Quote header unit name in preprocessor output (-E) (PR #112883)
@@ -952,13 +952,15 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok, continue; } else if (Tok.is(tok::annot_header_unit)) { // This is a header-name that has been (effectively) converted into a - // module-name. + // module-name, print them inside quote. // FIXME: The module name could contain non-identifier module name - // components. We don't have a good way to round-trip those. + // components and OS specific file paths components. We don't have a good + // way to round-trip those. Module *M = reinterpret_cast(Tok.getAnnotationValue()); std::string Name = M->getFullModuleName(); - Callbacks->OS->write(Name.data(), Name.size()); - Callbacks->HandleNewlinesInToken(Name.data(), Name.size()); + *Callbacks->OS << '"'; ChuanqiXu9 wrote: What if the header was imported by `<>`? https://github.com/llvm/llvm-project/pull/112883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang-format] Add CI check confirming ClangFormatStyleOptions.rst is up-to-date. (PR #111513)
owenca wrote: > > Because only part of the doc is generated by dump_format_style.py. > > It should still be possible to only include the non-generated parts in the > repo and then modify the script to add all the generated components on > afterwards as a build step? Not sure if I'm missing something here. Sometimes we need to edit the non-generated parts, and it would be easier to have the entire contexts. Anyway, don't we need the generated RST file in the repo so that the corresponding HTML file (e.g. https://clang.llvm.org/docs/ClangFormatStyleOptions.html) will be readily available? https://github.com/llvm/llvm-project/pull/111513 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/test/CoverageMapping/single-byte-counters.cpp: Rewrite counters with matches (PR #113114)
https://github.com/chapuni created https://github.com/llvm/llvm-project/pull/113114 None >From 52f072e5058267660aa8c8fbb00c5d09634f22b3 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Fri, 18 Oct 2024 08:32:39 +0900 Subject: [PATCH] clang/test/CoverageMapping/single-byte-counters.cpp: Rewrite counter matches --- .../CoverageMapping/single-byte-counters.cpp | 163 +++--- 1 file changed, 65 insertions(+), 98 deletions(-) diff --git a/clang/test/CoverageMapping/single-byte-counters.cpp b/clang/test/CoverageMapping/single-byte-counters.cpp index 8e9b613dcc68f7..d20b695bc2636a 100644 --- a/clang/test/CoverageMapping/single-byte-counters.cpp +++ b/clang/test/CoverageMapping/single-byte-counters.cpp @@ -1,169 +1,136 @@ // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -mllvm -enable-single-byte-coverage=true -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name single-byte-counters.cpp %s | FileCheck %s // CHECK: testIf -int testIf(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+10]]:2 = #0 -// CHECK-NEXT: File 0, [[@LINE+5]]:7 -> [[@LINE+5]]:13 = #0 -// CHECK-NEXT: Gap,File 0, [[@LINE+4]]:14 -> [[@LINE+5]]:5 = #1 -// CHECK-NEXT: File 0, [[@LINE+4]]:5 -> [[@LINE+4]]:16 = #1 -// CHECK-NEXT: File 0, [[@LINE+5]]:3 -> [[@LINE+5]]:16 = #2 +int testIf(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+7]]:2 = [[C00:#0]] int result = 0; - if (x == 0) -result = -1; + if (x == 0) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = [[C00]] +// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+1]]:5 = [[C0T:#1]] +result = -1;// CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:16 = [[C0T]] - return result; + return result;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C0E:#2]] } // CHECK-NEXT: testIfElse -int testIfElse(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+13]]:2 = #0 -// CHECK-NEXT: File 0, [[@LINE+7]]:7 -> [[@LINE+7]]:12 = #0 -// CHECK-NEXT: Gap,File 0, [[@LINE+6]]:13 -> [[@LINE+7]]:5 = #1 -// CHECK-NEXT: File 0, [[@LINE+6]]:5 -> [[@LINE+6]]:15 = #1 -// CHECK-NEXT: Gap,File 0, [[@LINE+5]]:16 -> [[@LINE+7]]:5 = #2 -// CHECK-NEXT: File 0, [[@LINE+6]]:5 -> [[@LINE+6]]:19 = #2 -// CHECK-NEXT: File 0, [[@LINE+6]]:3 -> [[@LINE+6]]:16 = #3 +int testIfElse(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+8]]:2 = [[C10:#0]] int result = 0; - if (x < 0) -result = 0; - else -result = x * x; - return result; + if (x < 0)// CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C10]] +// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C1T:#1]] +result = 0; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:15 = [[C1T]] + else // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:16 -> [[@LINE+1]]:5 = [[C1F:#2]] +result = x * x; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:19 = [[C1F]] + return result;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C1E:#3]] } // CHECK-NEXT: testIfElseReturn -int testIfElseReturn(int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+14]]:2 = #0 - // CHECK-NEXT: File 0, [[@LINE+8]]:7 -> [[@LINE+8]]:12 = #0 - // CHECK-NEXT: Gap,File 0, [[@LINE+7]]:13 -> [[@LINE+8]]:5 = #1 - // CHECK-NEXT: File 0, [[@LINE+7]]:5 -> [[@LINE+7]]:19 = #1 - // CHECK-NEXT: Gap,File 0, [[@LINE+6]]:20 -> [[@LINE+8]]:5 = #2 - // CHECK-NEXT: File 0, [[@LINE+7]]:5 -> [[@LINE+7]]:13 = #2 - // CHECK-NEXT: Gap,File 0, [[@LINE+6]]:14 -> [[@LINE+7]]:3 = #3 - // CHECK-NEXT: File 0, [[@LINE+6]]:3 -> [[@LINE+6]]:16 = #3 +int testIfElseReturn(int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+9]]:2 = [[C20:#0]] int result = 0; - if (x > 0) -result = x * x; - else -return 0; - return result; + if (x > 0) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C20]] + // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C2T:#1]] +result = x * x; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:19 = [[C2T]] + else// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:20 -> [[@LINE+1]]:5 = [[C2F:#2]] +return 0; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:13 = [[C2F]] + // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+1]]:3 = [[C2E:#3]] + return result; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C2E:#3]] } // CHECK-NEXT: te
[clang] clang/test/CoverageMapping/single-byte-counters.cpp: Rewrite counters with matches (PR #113114)
llvmbot wrote: @llvm/pr-subscribers-clang Author: NAKAMURA Takumi (chapuni) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/113114.diff 1 Files Affected: - (modified) clang/test/CoverageMapping/single-byte-counters.cpp (+65-98) ``diff diff --git a/clang/test/CoverageMapping/single-byte-counters.cpp b/clang/test/CoverageMapping/single-byte-counters.cpp index 8e9b613dcc68f7..d20b695bc2636a 100644 --- a/clang/test/CoverageMapping/single-byte-counters.cpp +++ b/clang/test/CoverageMapping/single-byte-counters.cpp @@ -1,169 +1,136 @@ // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -mllvm -enable-single-byte-coverage=true -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name single-byte-counters.cpp %s | FileCheck %s // CHECK: testIf -int testIf(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+10]]:2 = #0 -// CHECK-NEXT: File 0, [[@LINE+5]]:7 -> [[@LINE+5]]:13 = #0 -// CHECK-NEXT: Gap,File 0, [[@LINE+4]]:14 -> [[@LINE+5]]:5 = #1 -// CHECK-NEXT: File 0, [[@LINE+4]]:5 -> [[@LINE+4]]:16 = #1 -// CHECK-NEXT: File 0, [[@LINE+5]]:3 -> [[@LINE+5]]:16 = #2 +int testIf(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+7]]:2 = [[C00:#0]] int result = 0; - if (x == 0) -result = -1; + if (x == 0) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = [[C00]] +// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+1]]:5 = [[C0T:#1]] +result = -1;// CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:16 = [[C0T]] - return result; + return result;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C0E:#2]] } // CHECK-NEXT: testIfElse -int testIfElse(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+13]]:2 = #0 -// CHECK-NEXT: File 0, [[@LINE+7]]:7 -> [[@LINE+7]]:12 = #0 -// CHECK-NEXT: Gap,File 0, [[@LINE+6]]:13 -> [[@LINE+7]]:5 = #1 -// CHECK-NEXT: File 0, [[@LINE+6]]:5 -> [[@LINE+6]]:15 = #1 -// CHECK-NEXT: Gap,File 0, [[@LINE+5]]:16 -> [[@LINE+7]]:5 = #2 -// CHECK-NEXT: File 0, [[@LINE+6]]:5 -> [[@LINE+6]]:19 = #2 -// CHECK-NEXT: File 0, [[@LINE+6]]:3 -> [[@LINE+6]]:16 = #3 +int testIfElse(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+8]]:2 = [[C10:#0]] int result = 0; - if (x < 0) -result = 0; - else -result = x * x; - return result; + if (x < 0)// CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C10]] +// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C1T:#1]] +result = 0; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:15 = [[C1T]] + else // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:16 -> [[@LINE+1]]:5 = [[C1F:#2]] +result = x * x; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:19 = [[C1F]] + return result;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C1E:#3]] } // CHECK-NEXT: testIfElseReturn -int testIfElseReturn(int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+14]]:2 = #0 - // CHECK-NEXT: File 0, [[@LINE+8]]:7 -> [[@LINE+8]]:12 = #0 - // CHECK-NEXT: Gap,File 0, [[@LINE+7]]:13 -> [[@LINE+8]]:5 = #1 - // CHECK-NEXT: File 0, [[@LINE+7]]:5 -> [[@LINE+7]]:19 = #1 - // CHECK-NEXT: Gap,File 0, [[@LINE+6]]:20 -> [[@LINE+8]]:5 = #2 - // CHECK-NEXT: File 0, [[@LINE+7]]:5 -> [[@LINE+7]]:13 = #2 - // CHECK-NEXT: Gap,File 0, [[@LINE+6]]:14 -> [[@LINE+7]]:3 = #3 - // CHECK-NEXT: File 0, [[@LINE+6]]:3 -> [[@LINE+6]]:16 = #3 +int testIfElseReturn(int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+9]]:2 = [[C20:#0]] int result = 0; - if (x > 0) -result = x * x; - else -return 0; - return result; + if (x > 0) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C20]] + // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C2T:#1]] +result = x * x; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:19 = [[C2T]] + else// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:20 -> [[@LINE+1]]:5 = [[C2F:#2]] +return 0; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:13 = [[C2F]] + // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+1]]:3 = [[C2E:#3]] + return result; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C2E:#3]] } // CHECK-NEXT: testSwitch -int testSwitch(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+22]]:2 = #0 -// CHECK-NEXT: Gap,File 0, [[@LINE+9]]:14 -> [[@LINE+
[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)
owenca wrote: > > I'm inclined to think that all the AllowShort options should work the same > > way whether ColumnLimit is 0. However, a couple of them I checked > > (AllowShortLoops and AllowShortBlocks) have no effect unless set to false. > > I suggest that we mark the test as a FIXME or don't include it here. > > As an active user of ColumnLimit 0, I disagree. At least for my team we use > ColumnLimit of 0 to allow for more customization and variability of the > column limit. Treating it like ColumnLimit: Infinity causes huge constructs > to be pulled into a single line for some of these 'AllowShort' options, which > we actively don't want. Making somewhat arbitrary and contextual decisions > about how to do the breaking is a 'feature' in my opinion - although I'm not > sure if that's truly the intent and vision behind ColumnLimit 0. Below is the documentation on [`ColumnLimit`](https://releases.llvm.org/19.1.0/tools/clang/docs/ClangFormatStyleOptions.html#columnlimit): > A column limit of `0` means that there is no column limit. In this case, > clang-format will respect the input’s line breaking decisions within > statements unless they contradict other rules. The term _statements_ above can be loosely interpreted as _unwrapped lines_. Since all the `AllowShort` options involve merging _wrapped_ ines, they should not be ignored even when `ColumnLimit` is set to 0. (See also [` RemoveEmptyLinesInUnwrappedLines `](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removeemptylinesinunwrappedlines).) > My thought here is that this feature should function similarly to how > CompactNamespaces interacts with ColumnLimit: 0, which is basically that it > allows arbitrary line breaking. So you could have a 1000 character line, or > you could break it after every namespace. Forcing it to always pull single > statements no matter how long onto a single line would be undesirable in my > opinion. IMO a better way to have arbitrary line breakings is to add a `Leave` suboption. > I'm definitely open to changing things here, and being consistent if there is > some other vision of how features are supposed to interact with ColumnLimit > 0, but this has been my mental model so far, and that seems to be the natural > behavior that I've observed, so validating that functionality in the tests > seems reasonable to me. I don't think we want to add any tests whose formats are questionable or still under discussion. WDYT @mydeveloperday @HazardyKnusperkeks @rymiel ? https://github.com/llvm/llvm-project/pull/105597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix working -assume-filename with .clang-format-ignore (PR #113100)
https://github.com/kakkoko updated https://github.com/llvm/llvm-project/pull/113100 >From 506a4a497b7a0d5a5fed2504428d8114400c2467 Mon Sep 17 00:00:00 2001 From: kakkoko Date: Mon, 21 Oct 2024 03:48:13 +0900 Subject: [PATCH] [clang-format] Fix working -assume-filename with .clang-format-ignore The filename given by the `-assume-filename` option is used to search for `.clang-format` files, etc., but is not used to match the contents of the `.clang-format-ignore` file. Fixed that when the `-assume-filename` option is specified, the `.clang-format-ignore` file is processed for that filename. --- clang/test/Format/clang-format-ignore.cpp | 11 +++ clang/tools/clang-format/ClangFormat.cpp | 5 - 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/clang/test/Format/clang-format-ignore.cpp b/clang/test/Format/clang-format-ignore.cpp index fb49fa9dd52c65..198ef3200a3845 100644 --- a/clang/test/Format/clang-format-ignore.cpp +++ b/clang/test/Format/clang-format-ignore.cpp @@ -46,5 +46,16 @@ // CHECK5-NEXT: {{Formatting \[4/5] .*foo\.c}} // CHECK5-NOT: foo.js +// RUN: echo "foo.*" > .clang-format-ignore +// RUN: touch foo.c +// RUN: echo foo | clang-format -assume-filename=foo.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK6 -allow-empty +// CHECK6-NOT: foo + +// RUN: touch bar.c +// RUN: echo foo | clang-format -assume-filename=bar.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK7 -allow-empty +// CHECK7: foo + // RUN: cd .. // RUN: rm -r %t.dir diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 108db7204aa68a..4f4a1b2c6be9cf 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -707,8 +707,11 @@ int main(int argc, const char **argv) { errs() << "Clang-formatting " << LineNo << " files\n"; } - if (FileNames.empty()) + if (FileNames.empty()) { +if (!AssumeFileName.empty() && isIgnored(AssumeFileName)) + return 0; return clang::format::format("-", FailOnIncompleteFormat); + } if (FileNames.size() > 1 && (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty())) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix working -assume-filename with .clang-format-ignore (PR #113100)
https://github.com/kakkoko updated https://github.com/llvm/llvm-project/pull/113100 >From 506a4a497b7a0d5a5fed2504428d8114400c2467 Mon Sep 17 00:00:00 2001 From: kakkoko Date: Mon, 21 Oct 2024 03:48:13 +0900 Subject: [PATCH] [clang-format] Fix working -assume-filename with .clang-format-ignore The filename given by the `-assume-filename` option is used to search for `.clang-format` files, etc., but is not used to match the contents of the `.clang-format-ignore` file. Fixed that when the `-assume-filename` option is specified, the `.clang-format-ignore` file is processed for that filename. --- clang/test/Format/clang-format-ignore.cpp | 11 +++ clang/tools/clang-format/ClangFormat.cpp | 5 - 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/clang/test/Format/clang-format-ignore.cpp b/clang/test/Format/clang-format-ignore.cpp index fb49fa9dd52c65..198ef3200a3845 100644 --- a/clang/test/Format/clang-format-ignore.cpp +++ b/clang/test/Format/clang-format-ignore.cpp @@ -46,5 +46,16 @@ // CHECK5-NEXT: {{Formatting \[4/5] .*foo\.c}} // CHECK5-NOT: foo.js +// RUN: echo "foo.*" > .clang-format-ignore +// RUN: touch foo.c +// RUN: echo foo | clang-format -assume-filename=foo.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK6 -allow-empty +// CHECK6-NOT: foo + +// RUN: touch bar.c +// RUN: echo foo | clang-format -assume-filename=bar.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK7 -allow-empty +// CHECK7: foo + // RUN: cd .. // RUN: rm -r %t.dir diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 108db7204aa68a..4f4a1b2c6be9cf 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -707,8 +707,11 @@ int main(int argc, const char **argv) { errs() << "Clang-formatting " << LineNo << " files\n"; } - if (FileNames.empty()) + if (FileNames.empty()) { +if (!AssumeFileName.empty() && isIgnored(AssumeFileName)) + return 0; return clang::format::format("-", FailOnIncompleteFormat); + } if (FileNames.size() > 1 && (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty())) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/test/CoverageMapping/single-byte-counters.cpp: Rewrite counters with matches (PR #113114)
chapuni wrote: I think I could dissolve `single-byte-counters.cpp` to other tests. Let me rework. https://github.com/llvm/llvm-project/pull/113114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
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 10 "Add check check-offload". Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/7325 Here is the relevant piece of the build log for the reference ``` Step 10 (Add check check-offload) failure: 1200 seconds without output running [b'ninja', b'-j 32', b'check-offload'], attempting to kill ... PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug47654.cpp (866 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug53727.cpp (867 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug49779.cpp (868 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/test_libc.cpp (869 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/wtime.c (870 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu :: offloading/bug49021.cpp (871 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu :: offloading/std_complex_arithmetic.cpp (872 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/complex_reduction.cpp (873 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug49021.cpp (874 of 879) PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/std_complex_arithmetic.cpp (875 of 879) command timed out: 1200 seconds without output running [b'ninja', b'-j 32', b'check-offload'], attempting to kill process killed by signal 9 program finished with exit code -1 elapsedTime=1237.428812 ``` https://github.com/llvm/llvm-project/pull/113083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-ppc64le-linux-multistage` running on `ppc64le-clang-multistage-test` while building `clang` at step 5 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/3813 Here is the relevant piece of the build log for the reference ``` Step 5 (ninja check 1) failure: stage 1 checked (failure) TEST 'LLVM-Unit :: Support/./SupportTests/818/1383' FAILED Script(shard): -- GTEST_OUTPUT=json:/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/unittests/Support/./SupportTests-LLVM-Unit-1633489-818-1383.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=1383 GTEST_SHARD_INDEX=818 /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/unittests/Support/./SupportTests -- Script: -- /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/unittests/Support/./SupportTests --gtest_filter=ProgramEnvTest.CreateProcessTrailingSlash -- /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/unittests/Support/ProgramTest.cpp:203: Failure Expected equality of these values: 0 rc Which is: -2 /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/unittests/Support/ProgramTest.cpp:203 Expected equality of these values: 0 rc Which is: -2 ``` https://github.com/llvm/llvm-project/pull/113083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-s390x-linux` running on `systemz-1` while building `clang` at step 6 "test-openmp". Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/3670 Here is the relevant piece of the build log for the reference ``` Step 6 (test-openmp) failure: 1200 seconds without output running [b'ninja', b'-j 4', b'check-openmp'], attempting to kill ... PASS: ompd-test :: openmp_examples/example_2.c (439 of 449) PASS: ompd-test :: openmp_examples/example_4.c (440 of 449) PASS: ompd-test :: openmp_examples/example_task.c (441 of 449) PASS: ompd-test :: openmp_examples/example_5.c (442 of 449) UNSUPPORTED: ompd-test :: openmp_examples/ompd_bt.c (443 of 449) PASS: ompd-test :: openmp_examples/fibonacci.c (444 of 449) UNSUPPORTED: ompd-test :: openmp_examples/ompd_parallel.c (445 of 449) PASS: ompd-test :: openmp_examples/parallel.c (446 of 449) PASS: ompd-test :: openmp_examples/nested.c (447 of 449) PASS: ompd-test :: openmp_examples/ompd_icvs.c (448 of 449) command timed out: 1200 seconds without output running [b'ninja', b'-j 4', b'check-openmp'], attempting to kill process killed by signal 9 program finished with exit code -1 elapsedTime=1315.774288 ``` https://github.com/llvm/llvm-project/pull/113083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] fix range calculation for conditionals with throw expressions (PR #112081)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/112081 >From 67c41612085489a2a17eec49f98dbfa0e5bb97cf Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sat, 12 Oct 2024 08:27:51 +0300 Subject: [PATCH 1/2] [Clang] fix range calculation for conditionals with throw expressions --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaChecking.cpp | 3 +++ clang/test/SemaCXX/conditional-expr.cpp | 7 +++ 3 files changed, 11 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 337e3fc10bf49d..2ab13640bfa53c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -512,6 +512,7 @@ Bug Fixes to C++ Support and undeclared templates. (#GH107047, #GH49093) - Clang no longer crashes when a lambda contains an invalid block declaration that contains an unexpanded parameter pack. (#GH109148) +- Fixed assertion failure in range calculations for conditional throw expressions (#GH111854) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 2bcb930acdcb57..b3d88f053872c1 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -9827,6 +9827,9 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, return IntRange(BitField->getBitWidthValue(C), BitField->getType()->isUnsignedIntegerOrEnumerationType()); + if (GetExprType(E)->isVoidType()) +return IntRange{0, true}; + return IntRange::forValueOfType(C, GetExprType(E)); } diff --git a/clang/test/SemaCXX/conditional-expr.cpp b/clang/test/SemaCXX/conditional-expr.cpp index 01effaa189322b..8f17555fd806ff 100644 --- a/clang/test/SemaCXX/conditional-expr.cpp +++ b/clang/test/SemaCXX/conditional-expr.cpp @@ -429,3 +429,10 @@ void g() { long e = a = b ? throw 0 : throw 1; } } // namespace PR46484 + +namespace GH111854 { +void f() { + (true ? throw 0 : 0) <= 0; // expected-warning {{relational comparison result unused}} + (false ? 0 : throw 0) <= 0; // expected-warning {{relational comparison result unused}} +} +} >From 9c2a745ed365449be45cd062f29c89cabde0f514 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sat, 19 Oct 2024 00:00:19 +0300 Subject: [PATCH 2/2] change return type to nullable for handling invalid ranges in integer expression evaluation --- clang/lib/Sema/SemaChecking.cpp | 198 +++- 1 file changed, 118 insertions(+), 80 deletions(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index b3d88f053872c1..2ca342a6065550 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -9582,8 +9582,10 @@ static QualType GetExprType(const Expr *E) { ///particular, assume that arithmetic on narrower types doesn't leave ///those types. If \c false, return a range including all possible ///result values. -static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, - bool InConstantContext, bool Approximate) { +static std::optional TryGetExprRange(ASTContext &C, const Expr *E, + unsigned MaxWidth, + bool InConstantContext, + bool Approximate) { E = E->IgnoreParens(); // Try a full evaluation first. @@ -9596,8 +9598,8 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, // being of the new, wider type. if (const auto *CE = dyn_cast(E)) { if (CE->getCastKind() == CK_NoOp || CE->getCastKind() == CK_LValueToRValue) - return GetExprRange(C, CE->getSubExpr(), MaxWidth, InConstantContext, - Approximate); + return TryGetExprRange(C, CE->getSubExpr(), MaxWidth, InConstantContext, + Approximate); IntRange OutputTypeRange = IntRange::forValueOfType(C, GetExprType(CE)); @@ -9608,40 +9610,52 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, if (!isIntegerCast) return OutputTypeRange; -IntRange SubRange = GetExprRange(C, CE->getSubExpr(), - std::min(MaxWidth, OutputTypeRange.Width), - InConstantContext, Approximate); +std::optional SubRange = TryGetExprRange( +C, CE->getSubExpr(), std::min(MaxWidth, OutputTypeRange.Width), +InConstantContext, Approximate); +if (!SubRange) + return std::nullopt; // Bail out if the subexpr's range is as wide as the cast type. -if (SubRange.Width >= OutputTypeRange.Width) +if (SubRange->Width >= OutputTypeRange.Width) return OutputTypeRange; // Otherwise, we take the smaller width, and we're non-negative if // either the output type or the subexpr is. -
[clang] [Clang] prevent setting default lexical access specifier for missing primary declarations (PR #112424)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/112424 >From a22c6bae4f42f42e67f8e0c2b1f914e50d140099 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Tue, 15 Oct 2024 22:43:24 +0300 Subject: [PATCH 1/2] [Clang] prevent setting default lexical access specifier for missing primary declarations --- clang/docs/ReleaseNotes.rst | 2 ++ clang/lib/Sema/SemaAccess.cpp | 3 ++- clang/test/SemaCXX/enum.cpp | 8 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 817e3abef8d566..64ffdcde045a3a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -517,6 +517,8 @@ Bug Fixes to C++ Support certain situations. (#GH47400), (#GH90896) - Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441) - During the lookup for a base class name, non-type names are ignored. (#GH16855) +- Fixed an assertion failure when the default lexical access specifier was set for missing + primary declarations. (#GH112208) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index df6edb21a50dee..8b4a5b70669d84 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -39,7 +39,8 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl, AccessSpecifier LexicalAS) { if (!PrevMemberDecl) { // Use the lexical access specifier. -MemberDecl->setAccess(LexicalAS); +if (LexicalAS != AS_none) + MemberDecl->setAccess(LexicalAS); return false; } diff --git a/clang/test/SemaCXX/enum.cpp b/clang/test/SemaCXX/enum.cpp index 9c398cc8da886c..44042d8bf5cfc8 100644 --- a/clang/test/SemaCXX/enum.cpp +++ b/clang/test/SemaCXX/enum.cpp @@ -143,3 +143,11 @@ struct PR28903 { }) }; }; + +namespace GH112208 { +class C { + enum E { e = 0 }; + void f(int, enum E;); // expected-error {{ISO C++ forbids forward references to 'enum' types}} \ +// expected-error {{unexpected ';' before ')'}} +}; +} >From 83ce02f2e0c7a4f5e8e774694240a9c2939bc2fa Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Fri, 18 Oct 2024 14:55:47 +0300 Subject: [PATCH 2/2] prevent assertion failure by handling invalid enum forward declarations --- clang/docs/ReleaseNotes.rst | 3 +-- clang/lib/Sema/SemaAccess.cpp | 3 +-- clang/lib/Sema/SemaDecl.cpp | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 64ffdcde045a3a..3fd37663ca7bc6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -517,8 +517,7 @@ Bug Fixes to C++ Support certain situations. (#GH47400), (#GH90896) - Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441) - During the lookup for a base class name, non-type names are ignored. (#GH16855) -- Fixed an assertion failure when the default lexical access specifier was set for missing - primary declarations. (#GH112208) +- Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index 8b4a5b70669d84..df6edb21a50dee 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -39,8 +39,7 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl, AccessSpecifier LexicalAS) { if (!PrevMemberDecl) { // Use the lexical access specifier. -if (LexicalAS != AS_none) - MemberDecl->setAccess(LexicalAS); +MemberDecl->setAccess(LexicalAS); return false; } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index fece22c663d00c..9eb3d06289e88f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -17942,6 +17942,8 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, << Name; Invalid = true; } + if (TUK == TagUseKind::Declaration && Name) +Invalid = true; } else if (!PrevDecl) { Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while building `clang` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/3334 Here is the relevant piece of the build log for the reference ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... PASS: HWAddressSanitizer-aarch64 :: TestCases/Posix/ignore_free_hook.cpp (529 of 1718) PASS: HWAddressSanitizer-aarch64 :: TestCases/heap-buffer-overflow.c (530 of 1718) PASS: HWAddressSanitizer-aarch64 :: TestCases/libc_thread_freeres.c (531 of 1718) PASS: HWAddressSanitizer-aarch64 :: TestCases/longjmp-out-of-range.c (532 of 1718) PASS: HWAddressSanitizer-aarch64 :: TestCases/deep-recursion.c (533 of 1718) PASS: HWAddressSanitizer-aarch64 :: TestCases/malloc-test.c (534 of 1718) PASS: AddressSanitizer-aarch64-android :: TestCases/use-after-scope-types.cpp (535 of 1718) PASS: HWAddressSanitizer-aarch64 :: TestCases/lto.c (536 of 1718) PASS: HWAddressSanitizer-aarch64 :: TestCases/longjmp-setjmp-interception.c (537 of 1718) PASS: HWAddressSanitizer-aarch64 :: TestCases/malloc-align.c (538 of 1718) FAIL: HWAddressSanitizer-aarch64 :: TestCases/hwasan_symbolize_stack_overflow.cpp (539 of 1718) TEST 'HWAddressSanitizer-aarch64 :: TestCases/hwasan_symbolize_stack_overflow.cpp' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 1: rm -rf /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_aarch64/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp; mkdir /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_aarch64/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp + rm -rf /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_aarch64/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp + mkdir /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_aarch64/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp RUN: at line 2: /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/sanitizer_common/android_commands/android_compile.py /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/bin/clang --target=aarch64-linux-android24 --sysroot=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -B/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -fuse-ld=lld -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -Wl,--build-id -g /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp -o /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_aarch64/test/hwasan/AARCH64/TestCases/Output/hwasan_symbolize_stack_overflow.cpp.tmp/hwasan_overflow + /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/sanitizer_common/android_commands/android_compile.py /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/bin/clang --target=aarch64-linux-android24 --sysroot=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -B/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -fuse-ld=lld -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -Wl,--build-id -g /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_overflow.cpp -o /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-a
[clang] [compiler-rt] [libcxx] [llvm] [clang] Warn about memset/memcpy to NonTriviallyCopyable types (PR #111434)
@@ -102,7 +102,7 @@ struct __aliasing_iterator_wrapper { _LIBCPP_HIDE_FROM_ABI _Alias operator*() const _NOEXCEPT { _Alias __val; - __builtin_memcpy(&__val, std::__to_address(__base_), sizeof(value_type)); + __builtin_memcpy(&__val, static_cast(std::__to_address(__base_)), sizeof(value_type)); philnik777 wrote: Well, cppreference isn't exactly normative. Anyways, where is the actual disconnect? Is it whether you're allowed to - inspect the bytes of a non-trivially copyable object - implicitly start the lifetime of a trivial type with bytes from a different object - do any of the above via `memcpy` - do the above together in a single `memcpy` - something else? https://github.com/llvm/llvm-project/pull/111434 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][HIP] Deprecate the AMDGCN_WAVEFRONT_SIZE macros (PR #112849)
https://github.com/AlexVlx edited https://github.com/llvm/llvm-project/pull/112849 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][HIP] Deprecate the AMDGCN_WAVEFRONT_SIZE macros (PR #112849)
@@ -337,9 +337,12 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts, if (hasFastFMA()) Builder.defineMacro("FP_FAST_FMA"); - Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE__", Twine(WavefrontSize)); - // ToDo: deprecate this macro for naming consistency. - Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE", Twine(WavefrontSize)); + Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE__", Twine(WavefrontSize), + "compile-time-constant access to the wavefront size will " + "be removed in a future release"); + Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE", Twine(WavefrontSize), + "compile-time-constant access to the wavefront size will " + "be removed in a future release"); AlexVlx wrote: If you are removing an antipattern, the replacement is “don't do this”? Not all things that exists are valid. We should absolutely remove this, at least for HIP, where it creates needless divergence from CUDA and is a bug farm as a consequence. Orthogonally, what are the uses for it that you have in mind, and which non-offloading languages are you thinking of? The only scenario I can envision here is if one does an end-to-end compile (so not the weird 1-per-target thing we do with offload, and not playing games around single AST that gets forked at CodeGen time). In that case, yes, that *might* be useful, but delivering it as a macro is fundamentally a bad design IMHO, so even there we should not have this. Furthermore, at the moment, that sort of use is incredibly underspecified / governed by happens to work by accident rather than by design, so building some early technical debt seems problematic, at least to me https://github.com/llvm/llvm-project/pull/112849 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ia32_{pext, pdep} builtins for integer args (PR #113091)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/113091 None >From f9e95ab2ffe38ec1ade35681b24b5ed095adb8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 20 Oct 2024 18:08:08 +0200 Subject: [PATCH] [clang][bytecode] Check ia32_{pext,pdep} builtins for integer args --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 8 1 file changed, 8 insertions(+) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index d4a8e6c2035ee5..5cf39ab5167313 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1331,6 +1331,10 @@ static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->isIntegerType() || + !Call->getArg(1)->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); @@ -1352,6 +1356,10 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->isIntegerType() || + !Call->getArg(1)->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ia32_{pext, pdep} builtins for integer args (PR #113091)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/113091.diff 1 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+8) ``diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index d4a8e6c2035ee5..5cf39ab5167313 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1331,6 +1331,10 @@ static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->isIntegerType() || + !Call->getArg(1)->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); @@ -1352,6 +1356,10 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->isIntegerType() || + !Call->getArg(1)->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); `` https://github.com/llvm/llvm-project/pull/113091 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ia32_{pext, pdep} builtins for integer args (PR #113091)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/113091 >From e947bb4ef9a80f2ba730238e668d9ea732bf40fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 20 Oct 2024 18:08:08 +0200 Subject: [PATCH] [clang][bytecode] Check ia32_{pext,pdep} builtins for integer args --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 6 ++ 1 file changed, 6 insertions(+) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index d4a8e6c2035ee5..0db03714f128ba 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1331,6 +1331,9 @@ static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->isIntegerType() || !Call->getArg(1)->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); @@ -1352,6 +1355,9 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { + if (!Call->getArg(0)->isIntegerType() || !Call->getArg(1)->isIntegerType()) +return false; + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check ia32_{pext, pdep} builtins for integer args (PR #113091)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 490b7d12f6bef2c399fca83e6a6dde31be021913 f9e95ab2ffe38ec1ade35681b24b5ed095adb8e2 --extensions cpp -- clang/lib/AST/ByteCode/InterpBuiltin.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 5cf39ab516..0db03714f1 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1331,8 +1331,7 @@ static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { - if (!Call->getArg(0)->isIntegerType() || - !Call->getArg(1)->isIntegerType()) + if (!Call->getArg(0)->isIntegerType() || !Call->getArg(1)->isIntegerType()) return false; PrimType ValT = *S.Ctx.classify(Call->getArg(0)); @@ -1356,8 +1355,7 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, const CallExpr *Call) { - if (!Call->getArg(0)->isIntegerType() || - !Call->getArg(1)->isIntegerType()) + if (!Call->getArg(0)->isIntegerType() || !Call->getArg(1)->isIntegerType()) return false; PrimType ValT = *S.Ctx.classify(Call->getArg(0)); `` https://github.com/llvm/llvm-project/pull/113091 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Start implementing __builtin_bit_cast (PR #112126)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/112126 >From 81d236ada5a300f425de447d5802714af65c98f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 13 Oct 2024 08:57:48 +0200 Subject: [PATCH] [clang][bytecode] Start implementing __builtin_bit_cast --- clang/lib/AST/ByteCode/Boolean.h | 10 + clang/lib/AST/ByteCode/Compiler.cpp | 64 +++ clang/lib/AST/ByteCode/Compiler.h | 1 + clang/lib/AST/ByteCode/Floating.h | 5 + clang/lib/AST/ByteCode/Integral.h | 12 + clang/lib/AST/ByteCode/IntegralAP.h | 6 + clang/lib/AST/ByteCode/Interp.cpp | 17 + clang/lib/AST/ByteCode/Interp.h | 31 ++ clang/lib/AST/ByteCode/InterpBuiltin.cpp | 1 + .../lib/AST/ByteCode/InterpBuiltinBitCast.cpp | 353 clang/lib/AST/ByteCode/InterpBuiltinBitCast.h | 26 ++ clang/lib/AST/ByteCode/Opcodes.td | 10 + clang/lib/AST/CMakeLists.txt | 1 + clang/test/AST/ByteCode/builtin-bit-cast.cpp | 392 ++ 14 files changed, 929 insertions(+) create mode 100644 clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp create mode 100644 clang/lib/AST/ByteCode/InterpBuiltinBitCast.h create mode 100644 clang/test/AST/ByteCode/builtin-bit-cast.cpp diff --git a/clang/lib/AST/ByteCode/Boolean.h b/clang/lib/AST/ByteCode/Boolean.h index c568b557574e2b..78d75e75c7531a 100644 --- a/clang/lib/AST/ByteCode/Boolean.h +++ b/clang/lib/AST/ByteCode/Boolean.h @@ -81,6 +81,16 @@ class Boolean final { Boolean truncate(unsigned TruncBits) const { return *this; } + static Boolean bitcastFromMemory(const std::byte *Buff, unsigned BitWidth) { +// Boolean width is currently always 8 for all supported targets. If this +// changes we need to get the bool width from the target info. +assert(BitWidth == 8); +bool Val = static_cast(*Buff); +return Boolean(Val); + } + + void bitcastToMemory(std::byte *Buff) { std::memcpy(Buff, &V, sizeof(V)); } + void print(llvm::raw_ostream &OS) const { OS << (V ? "true" : "false"); } std::string toDiagnosticString(const ASTContext &Ctx) const { std::string NameStr; diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 672fa7fc25d6d0..91eeed94797dd0 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -470,6 +470,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { return this->emitDecayPtr(*FromT, *ToT, CE); } + case CK_LValueToRValueBitCast: +return this->emitBuiltinBitCast(CE); + case CK_IntegralToBoolean: case CK_FixedPointToBoolean: case CK_BooleanToSignedIntegral: @@ -6419,6 +6422,67 @@ bool Compiler::emitDestruction(const Descriptor *Desc, return this->emitRecordDestruction(Desc->ElemRecord, Loc); } +// This function is constexpr if and only if To, From, and the types of +// all subobjects of To and From are types T such that... +// (3.1) - is_union_v is false; +// (3.2) - is_pointer_v is false; +// (3.3) - is_member_pointer_v is false; +// (3.4) - is_volatile_v is false; and +// (3.5) - T has no non-static data members of reference type +template +bool Compiler::emitBuiltinBitCast(const CastExpr *E) { + const Expr *SubExpr = E->getSubExpr(); + QualType FromType = SubExpr->getType(); + QualType ToType = E->getType(); + std::optional ToT = classify(ToType); + + assert(!DiscardResult && "Implement DiscardResult mode for bitcasts."); + + if (ToType->isNullPtrType()) { +if (!this->discard(SubExpr)) + return false; + +return this->emitNullPtr(nullptr, E); + } + + if (FromType->isNullPtrType() && ToT) { +if (!this->discard(SubExpr)) + return false; + +return visitZeroInitializer(*ToT, ToType, E); + } + assert(!ToType->isReferenceType()); + + // Get a pointer to the value-to-cast on the stack. + if (!this->visit(SubExpr)) +return false; + + if (!ToT || ToT == PT_Ptr) { +// Conversion to an array or record type. +assert(false && "Implement bitcast to pointers."); + } + assert(ToT); + + const llvm::fltSemantics *TargetSemantics = nullptr; + if (ToT == PT_Float) +TargetSemantics = &Ctx.getFloatSemantics(ToType); + + // Conversion to a primitive type. FromType can be another + // primitive type, or a record/array. + bool ToTypeIsUChar = (ToType->isSpecificBuiltinType(BuiltinType::UChar) || +ToType->isSpecificBuiltinType(BuiltinType::Char_U)); + uint32_t ResultBitWidth = std::max(Ctx.getBitWidth(ToType), 8u); + + if (!this->emitBitCast(*ToT, ToTypeIsUChar || ToType->isStdByteType(), + ResultBitWidth, TargetSemantics, E)) +return false; + + if (DiscardResult) +return this->emitPop(*ToT, E); + + return true; +} + namespace clang { namespace interp { diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h i
[clang] f13d3f7 - [Tooling] Simplify code with StringMap::operator[] (NFC) (#113071)
Author: Kazu Hirata Date: 2024-10-20T09:05:55-07:00 New Revision: f13d3f72118b83e326169592e8f3c5962fd0eb29 URL: https://github.com/llvm/llvm-project/commit/f13d3f72118b83e326169592e8f3c5962fd0eb29 DIFF: https://github.com/llvm/llvm-project/commit/f13d3f72118b83e326169592e8f3c5962fd0eb29.diff LOG: [Tooling] Simplify code with StringMap::operator[] (NFC) (#113071) Added: Modified: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp Removed: diff --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp index 0cb96097415ea8..01b3be700b9fad 100644 --- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp +++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp @@ -335,10 +335,9 @@ HeaderIncludes::HeaderIncludes(StringRef FileName, StringRef Code, // \p Offset: the start of the line following this include directive. void HeaderIncludes::addExistingInclude(Include IncludeToAdd, unsigned NextLineOffset) { - auto Iter = - ExistingIncludes.try_emplace(trimInclude(IncludeToAdd.Name)).first; - Iter->second.push_back(std::move(IncludeToAdd)); - auto &CurInclude = Iter->second.back(); + auto &Incs = ExistingIncludes[trimInclude(IncludeToAdd.Name)]; + Incs.push_back(std::move(IncludeToAdd)); + auto &CurInclude = Incs.back(); // The header name with quotes or angle brackets. // Only record the offset of current #include if we can insert after it. if (CurInclude.R.getOffset() <= MaxInsertOffset) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Tooling] Simplify code with StringMap::operator[] (NFC) (PR #113071)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/113071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-m68k-linux-cross` running on `suse-gary-m68k-cross` while building `clang` at step 5 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/792 Here is the relevant piece of the build log for the reference ``` Step 5 (ninja check 1) failure: stage 1 checked (failure) ... [200/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ASTSelectionTest.cpp.o [201/372] Building CXX object tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/StructuralEquivalenceTest.cpp.o [202/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/QualTypeNamesTest.cpp.o [203/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LookupTest.cpp.o [204/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o [205/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RangeSelectorTest.cpp.o [206/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/Attr.cpp.o [207/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LexicallyOrderedRecursiveASTVisitorTest.cpp.o [208/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/BitfieldInitializer.cpp.o [209/372] Building CXX object tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o FAILED: tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o /usr/bin/c++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/unittests/AST -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/AST -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googletest/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG -std=c++17 -Wno-variadic-macros -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o -MF tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o.d -o tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o -c /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/AST/ASTImporterTest.cpp c++: fatal error: Killed signal terminated program cc1plus compilation terminated. [210/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ConstructExpr.cpp.o [211/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXMethodDecl.cpp.o [212/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXMemberCall.cpp.o [213/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/Class.cpp.o [214/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp.o [215/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp.o [216/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ImplicitCtor.cpp.o [217/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/DeductionGuide.cpp.o [218/372] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ImplicitCtorIni
[clang] [clang][bytecode] Narrow pointer in UO_Deref unary operators (PR #113089)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/113089 >From 6942291d0f529baa323cfd35e2f5d9b4f818c0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 20 Oct 2024 13:57:49 +0200 Subject: [PATCH] [clang][bytecode] Narrow pointer in UO_Deref unary operators Otherwise we treat this like an array element even though we should treat it as a single object. --- clang/lib/AST/ByteCode/Compiler.cpp | 12 ++-- clang/lib/AST/ByteCode/Pointer.cpp | 2 +- clang/test/AST/ByteCode/cxx98.cpp | 5 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 672fa7fc25d6d0..3f068aa8c189a9 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -5738,9 +5738,17 @@ bool Compiler::VisitUnaryOperator(const UnaryOperator *E) { // We should already have a pointer when we get here. return this->delegate(SubExpr); case UO_Deref: // *x -if (DiscardResult) +if (DiscardResult) { + // assert(false); return this->discard(SubExpr); -return this->visit(SubExpr); +} + +if (!this->visit(SubExpr)) + return false; +if (classifyPrim(SubExpr) == PT_Ptr) + return this->emitNarrowPtr(E); +return true; + case UO_Not: // ~x if (!T) return this->emitError(E); diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 75b00dcb2ab242..c9de039c195d94 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -635,7 +635,7 @@ std::optional Pointer::toRValue(const Context &Ctx, // Return the composite type. APValue Result; - if (!Composite(getType(), *this, Result)) + if (!Composite(ResultType, *this, Result)) return std::nullopt; return Result; } diff --git a/clang/test/AST/ByteCode/cxx98.cpp b/clang/test/AST/ByteCode/cxx98.cpp index 471a58f8e05518..20f98d33c31c4f 100644 --- a/clang/test/AST/ByteCode/cxx98.cpp +++ b/clang/test/AST/ByteCode/cxx98.cpp @@ -54,3 +54,8 @@ _Static_assert(a == 0, ""); // both-error {{static assertion expression is not a struct SelfReference { SelfReference &r; }; extern SelfReference self_reference_1; SelfReference self_reference_2 = {self_reference_1}; + +struct PR65784s{ + int *ptr; +} const PR65784[] = {(int *)""}; +PR65784s PR65784f() { return *PR65784; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Extend pointer TBAA to pointers of non-builtin types. (PR #110569)
https://github.com/rjmccall commented: Thanks, LGTM other than the memory leak. https://github.com/llvm/llvm-project/pull/110569 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Extend pointer TBAA to pointers of non-builtin types. (PR #110569)
@@ -119,6 +120,7 @@ class CodeGenTBAA { llvm::Module &Module; const CodeGenOptions &CodeGenOpts; const LangOptions &Features; + MangleContext *MangleCtx; rjmccall wrote: This should either be a unique_ptr or you need to delete it in the destructor. https://github.com/llvm/llvm-project/pull/110569 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Extend pointer TBAA to pointers of non-builtin types. (PR #110569)
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/110569 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
https://github.com/vabridgers updated https://github.com/llvm/llvm-project/pull/110471 >From 1cf734f9f39f8ef9268d3eafd89634a93693ad63 Mon Sep 17 00:00:00 2001 From: einvbri Date: Thu, 26 Sep 2024 16:24:59 +0200 Subject: [PATCH] [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy This change moves the alpha.nondeterministic.PointerSorting and alpha.nondeterministic.PointerIteration static analyzer checkers to a single clang-tidy check. Those checkers were implemented as clang-tidy checks wrapped in the static analyzer framework. The documentation was updated to describe what the checks can and cannot do, and testing was completed on a broad set of open source projects. --- .../bugprone/BugproneTidyModule.cpp | 3 + .../clang-tidy/bugprone/CMakeLists.txt| 1 + ...eterministicPointerIterationOrderCheck.cpp | 66 ...ndeterministicPointerIterationOrderCheck.h | 37 + clang-tools-extra/docs/ReleaseNotes.rst | 6 + ...ndeterministic-pointer-iteration-order.rst | 35 .../system-header-simulator/sim_algorithm | 31 .../system-header-simulator/sim_c++config.h | 11 ++ .../sim_initializer_list | 39 + .../system-header-simulator/sim_iterator_base | 22 +++ .../Inputs/system-header-simulator/sim_map| 34 .../Inputs/system-header-simulator/sim_set| 44 + .../system-header-simulator/sim_stl_pair | 33 .../system-header-simulator/sim_type_traits | 19 +++ .../system-header-simulator/sim_unordered_map | 34 .../system-header-simulator/sim_unordered_set | 35 .../Inputs/system-header-simulator/sim_vector | 150 ++ ...ndeterministic-pointer-iteration-order.cpp | 83 ++ clang/docs/ReleaseNotes.rst | 6 + clang/docs/analyzer/checkers.rst | 31 .../clang/StaticAnalyzer/Checkers/Checkers.td | 18 --- .../StaticAnalyzer/Checkers/CMakeLists.txt| 2 - .../Checkers/PointerIterationChecker.cpp | 101 .../Checkers/PointerSortingChecker.cpp| 115 -- clang/test/Analysis/ptr-iter.cpp | 28 clang/test/Analysis/ptr-sort.cpp | 36 - 26 files changed, 689 insertions(+), 331 deletions(-) create mode 100644 clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerIterationOrderCheck.cpp create mode 100644 clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerIterationOrderCheck.h create mode 100644 clang-tools-extra/docs/clang-tidy/checks/bugprone/nondeterministic-pointer-iteration-order.rst create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_algorithm create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_c++config.h create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_initializer_list create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_iterator_base create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_map create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_set create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_stl_pair create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_type_traits create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_unordered_map create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_unordered_set create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator/sim_vector create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/nondeterministic-pointer-iteration-order.cpp delete mode 100644 clang/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp delete mode 100644 clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp delete mode 100644 clang/test/Analysis/ptr-iter.cpp delete mode 100644 clang/test/Analysis/ptr-sort.cpp diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index 9120c4b6c0d9ae..33ac65e715ce81 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -49,6 +49,7 @@ #include "MultipleStatementMacroCheck.h" #include "NoEscapeCheck.h" #include "NonZeroEnumToBoolConversionCheck.h" +#include "NondeterministicPointerIterationOrderCheck.h" #include "NotNullTerminatedResultCheck.h" #include "OptionalValueConversionCheck.h" #include "ParentVirtualCallCheck.h" @@ -174,6 +175,8 @@ class BugproneModule : public C
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" + .bind("cxxForRangeStmt"), + this); + + auto SortFuncM = anyOf(callee(functionDecl(hasName("std::is_sorted"))), + callee(functionDecl(hasName("std::nth_element"))), + callee(functionDecl(hasName("std::sort"))), + callee(functionDecl(hasName("std::partial_sort"))), + callee(functionDecl(hasName("std::partition"))), + callee(functionDecl(hasName("std::stable_partition"))), + callee(functionDecl(hasName("std::stable_sort"; + + auto IteratesPointerEltsM = hasArgument( + 0, + cxxMemberCallExpr(on(hasType(cxxRecordDecl(has(fieldDecl(hasType( + hasCanonicalType(pointsTo(hasCanonicalType(pointerType(; + + Finder->addMatcher(stmt(callExpr(allOf(SortFuncM, IteratesPointerEltsM))) + .bind("sortsemantic"), vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" + .bind("cxxForRangeStmt"), + this); + + auto SortFuncM = anyOf(callee(functionDecl(hasName("std::is_sorted"))), + callee(functionDecl(hasName("std::nth_element"))), + callee(functionDecl(hasName("std::sort"))), + callee(functionDecl(hasName("std::partial_sort"))), + callee(functionDecl(hasName("std::partition"))), + callee(functionDecl(hasName("std::stable_partition"))), + callee(functionDecl(hasName("std::stable_sort"; + + auto IteratesPointerEltsM = hasArgument( + 0, + cxxMemberCallExpr(on(hasType(cxxRecordDecl(has(fieldDecl(hasType( + hasCanonicalType(pointsTo(hasCanonicalType(pointerType(; + + Finder->addMatcher(stmt(callExpr(allOf(SortFuncM, IteratesPointerEltsM))) + .bind("sortsemantic"), + this); +} + +void NondeterministicPointerUsageCheck::check( +const MatchFinder::MatchResult &Result) { + const auto *ForRangePointers = + Result.Nodes.getNodeAs("cxxForRangeStmt"); + const auto *SortPointers = Result.Nodes.getNodeAs("sortsemantic"); + + if ((ForRangePointers) && !(ForRangePointers->getBeginLoc().isMacroID())) { +const auto *Node = dyn_cast(ForRangePointers); +diag(Node->getRParenLoc(), "Iteration of pointers is nondeterministic"); vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" + .bind("cxxForRangeStmt"), + this); + + auto SortFuncM = anyOf(callee(functionDecl(hasName("std::is_sorted"))), + callee(functionDecl(hasName("std::nth_element"))), + callee(functionDecl(hasName("std::sort"))), + callee(functionDecl(hasName("std::partial_sort"))), + callee(functionDecl(hasName("std::partition"))), + callee(functionDecl(hasName("std::stable_partition"))), + callee(functionDecl(hasName("std::stable_sort"; + + auto IteratesPointerEltsM = hasArgument( + 0, + cxxMemberCallExpr(on(hasType(cxxRecordDecl(has(fieldDecl(hasType( vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" + .bind("cxxForRangeStmt"), + this); + + auto SortFuncM = anyOf(callee(functionDecl(hasName("std::is_sorted"))), + callee(functionDecl(hasName("std::nth_element"))), + callee(functionDecl(hasName("std::sort"))), + callee(functionDecl(hasName("std::partial_sort"))), + callee(functionDecl(hasName("std::partition"))), + callee(functionDecl(hasName("std::stable_partition"))), + callee(functionDecl(hasName("std::stable_sort"; vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" + .bind("cxxForRangeStmt"), vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -174,6 +175,8 @@ class BugproneModule : public ClangTidyModule { "bugprone-multiple-new-in-one-expression"); CheckFactories.registerCheck( "bugprone-multiple-statement-macro"); +CheckFactories.registerCheck( +"bugprone-nondeterministic-pointer-iteration-order"); vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,35 @@ + +#ifndef _SIM_MAP +#define _SIM_MAP + +#pragma clang system_header +#include "sim_stl_pair" + +namespace std { + +template +class map { + public: + using value_type = pair; + map(); + map(initializer_list> initList); + value_type& operator[](const Key& key); + value_type& operator[](Key&& key); +class iterator { +public: + iterator(Key *key): ptr(key) {} + iterator& operator++() { ++ptr; return *this; } + bool operator!=(const iterator &other) const { return ptr != other.ptr; } + const Key &operator*() const { return *ptr; } +private: + Key *ptr; +}; + public: vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,35 @@ +.. title:: clang-tidy - bugprone-nondeterministic-pointer-iteration-order + +bugprone-nondeterministic-pointer-iteration-order += + +Finds nondeterministic usages of pointers in unordered containers. + +One canonical example is iteration across a container of pointers. + +.. code-block:: c++ + + { +int a = 1, b = 2; +std::unordered_set UnorderedPtrSet = {&a, &b}; +for (auto i : UnorderedPtrSet) + f(i); + } + +Another such example is sorting a container of pointers. + +.. code-block:: c++ + + { +int a = 1, b = 2; +std::vector VectorOfPtr = {&a, &b}; +std::sort(VectorOfPtr.begin(), VectorOfPtr.end()); + } + +Iteration of a containers of pointers may present the order of different +pointers differently across different runs of a program. In some cases this +may be acceptable behavior, in others this may be unexpected behavior. This +check is advisory for this reason. + +This check only detects range-based for loops over unordered sets. Other vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,45 @@ + +#ifndef _SIM_SET +#define _SIM_SET + +#pragma clang system_header +#include "sim_initializer_list" + +namespace std { + +template< class T = void > +struct less; + +template< class T > +struct allocator; + +template< class Key > +struct hash; + +template< + class Key, + class Compare = std::less, + class Alloc = std::allocator +> class set { + public: +set(initializer_list __list) {} + +class iterator { +public: + iterator(Key *key): ptr(key) {} + iterator& operator++() { ++ptr; return *this; } + bool operator!=(const iterator &other) const { return ptr != other.ptr; } + const Key &operator*() const { return *ptr; } +private: + Key *ptr; +}; + + public: vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" + .bind("cxxForRangeStmt"), + this); + + auto SortFuncM = anyOf(callee(functionDecl(hasName("std::is_sorted"))), + callee(functionDecl(hasName("std::nth_element"))), + callee(functionDecl(hasName("std::sort"))), + callee(functionDecl(hasName("std::partial_sort"))), + callee(functionDecl(hasName("std::partition"))), + callee(functionDecl(hasName("std::stable_partition"))), + callee(functionDecl(hasName("std::stable_sort"; + + auto IteratesPointerEltsM = hasArgument( + 0, + cxxMemberCallExpr(on(hasType(cxxRecordDecl(has(fieldDecl(hasType( + hasCanonicalType(pointsTo(hasCanonicalType(pointerType(; + + Finder->addMatcher(stmt(callExpr(allOf(SortFuncM, IteratesPointerEltsM))) + .bind("sortsemantic"), + this); +} + +void NondeterministicPointerUsageCheck::check( +const MatchFinder::MatchResult &Result) { + const auto *ForRangePointers = + Result.Nodes.getNodeAs("cxxForRangeStmt"); + const auto *SortPointers = Result.Nodes.getNodeAs("sortsemantic"); + + if ((ForRangePointers) && !(ForRangePointers->getBeginLoc().isMacroID())) { +const auto *Node = dyn_cast(ForRangePointers); +diag(Node->getRParenLoc(), "Iteration of pointers is nondeterministic"); vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,67 @@ +//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===// +// +// 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 +// +//===--===// + +#include "NondeterministicPointerUsageCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void NondeterministicPointerUsageCheck::registerMatchers(MatchFinder *Finder) { + + auto LoopVariable = varDecl(hasType(hasCanonicalType(pointerType(; + + auto RangeInit = declRefExpr(to(varDecl(hasType(recordDecl( + anyOf(hasName("std::unordered_set"), hasName("std::unordered_map"), +hasName("std::unordered_multiset"), +hasName("std::unordered_multimap"))); + + Finder->addMatcher( + stmt(cxxForRangeStmt(hasRangeInit(RangeInit.bind("rangeinit")), + hasLoopVariable(LoopVariable.bind("loopVar" + .bind("cxxForRangeStmt"), + this); + + auto SortFuncM = anyOf(callee(functionDecl(hasName("std::is_sorted"))), + callee(functionDecl(hasName("std::nth_element"))), + callee(functionDecl(hasName("std::sort"))), + callee(functionDecl(hasName("std::partial_sort"))), + callee(functionDecl(hasName("std::partition"))), + callee(functionDecl(hasName("std::stable_partition"))), + callee(functionDecl(hasName("std::stable_sort"; + + auto IteratesPointerEltsM = hasArgument( + 0, + cxxMemberCallExpr(on(hasType(cxxRecordDecl(has(fieldDecl(hasType( + hasCanonicalType(pointsTo(hasCanonicalType(pointerType(; + + Finder->addMatcher(stmt(callExpr(allOf(SortFuncM, IteratesPointerEltsM))) + .bind("sortsemantic"), + this); +} + +void NondeterministicPointerUsageCheck::check( +const MatchFinder::MatchResult &Result) { + const auto *ForRangePointers = + Result.Nodes.getNodeAs("cxxForRangeStmt"); + const auto *SortPointers = Result.Nodes.getNodeAs("sortsemantic"); vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,35 @@ +#ifndef _SIM_UNORDERED_MAP +#define _SIM_UNORDERED_MAP + + +#pragma clang system_header +#include "sim_initializer_list" + +namespace std { + +template +class unordered_map { + public: + using value_type = pair; + unordered_map(); + unordered_map(initializer_list> initList); + value_type& operator[](const Key& key); + value_type& operator[](Key&& key); +class iterator { +public: + iterator(Key *key): ptr(key) {} + iterator& operator++() { ++ptr; return *this; } + bool operator!=(const iterator &other) const { return ptr != other.ptr; } + const Key &operator*() const { return *ptr; } +private: + Key *ptr; +}; + public: vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -121,6 +121,12 @@ New checks Gives warnings for tagged unions, where the number of tags is different from the number of data members inside the union. +- New :doc:`bugprone-nondeterministic-pointer-iteration-order vabridgers wrote: I believe I've address this. Marking as resolved. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
@@ -0,0 +1,83 @@ +// RUN: %check_clang_tidy %s bugprone-nondeterministic-pointer-iteration-order %t -- -- -I%S -std=c++!4 + +#include "Inputs/system-header-simulator/sim_set" +#include "Inputs/system-header-simulator/sim_unordered_set" +#include "Inputs/system-header-simulator/sim_map" +#include "Inputs/system-header-simulator/sim_unordered_map" +#include "Inputs/system-header-simulator/sim_vector" +#include "Inputs/system-header-simulator/sim_algorithm" + +template +void f(T x); + +void PointerIteration() { + int a = 1, b = 2; + std::set OrderedIntSet = {a, b}; + std::set OrderedPtrSet = {&a, &b}; + std::unordered_set UnorderedIntSet = {a, b}; + std::unordered_set UnorderedPtrSet = {&a, &b}; + std::map IntMap = { std::make_pair(a,a), std::make_pair(b,b) }; + std::map PtrMap = { std::make_pair(&a,&a), std::make_pair(&b,&b) }; + std::unordered_map IntUnorderedMap = { std::make_pair(a,a), std::make_pair(b,b) }; + std::unordered_map PtrUnorderedMap = { std::make_pair(&a,&a), std::make_pair(&b,&b) }; + + for (auto i : OrderedIntSet) // no-warning +f(i); + + for (auto i : OrderedPtrSet) // no-warning +f(i); + + for (auto i : UnorderedIntSet) // no-warning +f(i); + + for (auto i : UnorderedPtrSet) +f(i); + // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: Iteration of pointers is nondeterministic + + for (auto &i : UnorderedPtrSet) // no-warning +f(i); vabridgers wrote: Looking at this, will update when ready. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (PR #110471)
vabridgers wrote: Thanks for the comments, I've resolved most, but not all. Not requested updated review comments yet, but if you're so inclined, would appreciate a quick scan to see if if I missed anything. Thanks. https://github.com/llvm/llvm-project/pull/110471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC (PR #113104)
https://github.com/kin4stat updated https://github.com/llvm/llvm-project/pull/113104 >From 86127708ed74db3c6a826c13f7c21b11a457c76d Mon Sep 17 00:00:00 2001 From: kin4stat Date: Sun, 20 Oct 2024 23:43:03 +0300 Subject: [PATCH] [clang codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC MSVC normally has a bunch of restrictions on returning values directly which don't apply to passing values directly. (This roughly corresponds to the definition of a C++14 aggregate.) However, these restrictions don't apply to HVAs and HFAs; make sure we check for that. Fixes llvm/llvm-project#63417 --- clang/lib/CodeGen/MicrosoftCXXABI.cpp | 4 .../CodeGenCXX/homogeneous-aggregates.cpp | 19 +++ 2 files changed, 23 insertions(+) diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 0b0b45ffead92f..fa5d83243f60fe 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1110,6 +1110,10 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty, isa(Base)) { return true; } + if (CGM.getTarget().getTriple().isX86() && + CGM.getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts)) { +return true; + } // We use the C++14 definition of an aggregate, so we also // check for: diff --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp index 63ffc6b5bfac84..cf8019d2f18964 100644 --- a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp +++ b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp @@ -302,3 +302,22 @@ struct test2 : base2 { test2(double); protected: double v2;}; test2 f(test2 *x) { return *x; } // WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr dead_on_unwind inreg noalias writable sret(%"struct.pr62223::test2") align 8 %{{.*}}, ptr noundef %{{.*}}) } + +namespace pr113104 { +struct HFA { + float a; + float b; +}; + +using HVA = float __attribute__((__vector_size__(16), __aligned__(16))); + +struct base_hfa { HFA v1; }; +struct test_hfa : base_hfa { test_hfa(double); protected: HFA v2;}; +test_hfa CC f(test_hfa *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hfa" @"\01_ZN8pr1131041fEPNS_8test_hfaE@@8"(ptr noundef %x) + +struct base_hva { HVA v1; }; +struct test_hva : base_hva { test_hva(double); protected: HVA v2;}; +test_hva CC f(test_hva *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hva" @"\01_ZN8pr1131041fEPNS_8test_hvaE@@8"(ptr noundef %x) +} \ No newline at end of file ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC (PR #113104)
https://github.com/kin4stat updated https://github.com/llvm/llvm-project/pull/113104 >From 86127708ed74db3c6a826c13f7c21b11a457c76d Mon Sep 17 00:00:00 2001 From: kin4stat Date: Sun, 20 Oct 2024 23:43:03 +0300 Subject: [PATCH] [clang codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC MSVC normally has a bunch of restrictions on returning values directly which don't apply to passing values directly. (This roughly corresponds to the definition of a C++14 aggregate.) However, these restrictions don't apply to HVAs and HFAs; make sure we check for that. Fixes llvm/llvm-project#63417 --- clang/lib/CodeGen/MicrosoftCXXABI.cpp | 4 .../CodeGenCXX/homogeneous-aggregates.cpp | 19 +++ 2 files changed, 23 insertions(+) diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 0b0b45ffead92f..fa5d83243f60fe 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1110,6 +1110,10 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty, isa(Base)) { return true; } + if (CGM.getTarget().getTriple().isX86() && + CGM.getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts)) { +return true; + } // We use the C++14 definition of an aggregate, so we also // check for: diff --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp index 63ffc6b5bfac84..cf8019d2f18964 100644 --- a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp +++ b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp @@ -302,3 +302,22 @@ struct test2 : base2 { test2(double); protected: double v2;}; test2 f(test2 *x) { return *x; } // WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr dead_on_unwind inreg noalias writable sret(%"struct.pr62223::test2") align 8 %{{.*}}, ptr noundef %{{.*}}) } + +namespace pr113104 { +struct HFA { + float a; + float b; +}; + +using HVA = float __attribute__((__vector_size__(16), __aligned__(16))); + +struct base_hfa { HFA v1; }; +struct test_hfa : base_hfa { test_hfa(double); protected: HFA v2;}; +test_hfa CC f(test_hfa *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hfa" @"\01_ZN8pr1131041fEPNS_8test_hfaE@@8"(ptr noundef %x) + +struct base_hva { HVA v1; }; +struct test_hva : base_hva { test_hva(double); protected: HVA v2;}; +test_hva CC f(test_hva *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hva" @"\01_ZN8pr1131041fEPNS_8test_hvaE@@8"(ptr noundef %x) +} \ No newline at end of file ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/113083 None >From c72b3ea5ef4e1e51f5832886a722d310e6b98498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 19 Oct 2024 12:04:17 +0200 Subject: [PATCH] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API --- clang/include/clang/AST/ExprCXX.h | 4 ++-- clang/lib/AST/ExprCXX.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 975bcdac5069b9..cfe3938f83847b 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -876,13 +876,13 @@ class CXXTypeidExpr : public Expr { /// Best-effort check if the expression operand refers to a most derived /// object. This is not a strong guarantee. - bool isMostDerived(ASTContext &Context) const; + bool isMostDerived(const ASTContext &Context) const; bool isTypeOperand() const { return Operand.is(); } /// Retrieves the type operand of this typeid() expression after /// various required adjustments (removing reference types, cv-qualifiers). - QualType getTypeOperand(ASTContext &Context) const; + QualType getTypeOperand(const ASTContext &Context) const; /// Retrieve source information for the type operand. TypeSourceInfo *getTypeOperandSourceInfo() const { diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 83ce404add5f50..a2c0c60d43dd14 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -147,7 +147,7 @@ bool CXXTypeidExpr::isPotentiallyEvaluated() const { return false; } -bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const { +bool CXXTypeidExpr::isMostDerived(const ASTContext &Context) const { assert(!isTypeOperand() && "Cannot call isMostDerived for typeid(type)"); const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context); if (const auto *DRE = dyn_cast(E)) { @@ -159,7 +159,7 @@ bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const { return false; } -QualType CXXTypeidExpr::getTypeOperand(ASTContext &Context) const { +QualType CXXTypeidExpr::getTypeOperand(const ASTContext &Context) const { assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); Qualifiers Quals; return Context.getUnqualifiedArrayType( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/113083.diff 2 Files Affected: - (modified) clang/include/clang/AST/ExprCXX.h (+2-2) - (modified) clang/lib/AST/ExprCXX.cpp (+2-2) ``diff diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 975bcdac5069b9..cfe3938f83847b 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -876,13 +876,13 @@ class CXXTypeidExpr : public Expr { /// Best-effort check if the expression operand refers to a most derived /// object. This is not a strong guarantee. - bool isMostDerived(ASTContext &Context) const; + bool isMostDerived(const ASTContext &Context) const; bool isTypeOperand() const { return Operand.is(); } /// Retrieves the type operand of this typeid() expression after /// various required adjustments (removing reference types, cv-qualifiers). - QualType getTypeOperand(ASTContext &Context) const; + QualType getTypeOperand(const ASTContext &Context) const; /// Retrieve source information for the type operand. TypeSourceInfo *getTypeOperandSourceInfo() const { diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 83ce404add5f50..a2c0c60d43dd14 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -147,7 +147,7 @@ bool CXXTypeidExpr::isPotentiallyEvaluated() const { return false; } -bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const { +bool CXXTypeidExpr::isMostDerived(const ASTContext &Context) const { assert(!isTypeOperand() && "Cannot call isMostDerived for typeid(type)"); const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context); if (const auto *DRE = dyn_cast(E)) { @@ -159,7 +159,7 @@ bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const { return false; } -QualType CXXTypeidExpr::getTypeOperand(ASTContext &Context) const { +QualType CXXTypeidExpr::getTypeOperand(const ASTContext &Context) const { assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); Qualifiers Quals; return Context.getUnqualifiedArrayType( `` https://github.com/llvm/llvm-project/pull/113083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Pass const ASTContext& to CXXTypeidExpr API (PR #113083)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/113083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix working -assume-filename with .clang-format-ignore (PR #113100)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff d1401822e2d2753bed3ac597a42cc0b261de40a4 74e9d297f6090d77e52dd93fa356f37cf1afc2f7 --extensions cpp -- clang/test/Format/clang-format-ignore.cpp clang/tools/clang-format/ClangFormat.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 84eaf32cc4..4f4a1b2c6b 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -708,9 +708,8 @@ int main(int argc, const char **argv) { } if (FileNames.empty()) { -if (!AssumeFileName.empty() && isIgnored(AssumeFileName)) { +if (!AssumeFileName.empty() && isIgnored(AssumeFileName)) return 0; -} return clang::format::format("-", FailOnIncompleteFormat); } `` https://github.com/llvm/llvm-project/pull/113100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm] Support llvm::Any across shared libraries on windows (PR #108051)
https://github.com/fsfod updated https://github.com/llvm/llvm-project/pull/108051 >From e39aee57ce8a98723f40f67ae33808bc6213c61d Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Sat, 7 Sep 2024 15:53:09 +0100 Subject: [PATCH 1/5] [llvm] Support llvm::Any across shared libraries on windows in a limited form Explicitly import and export Any::TypeId template instantiations for uses of llvm::Any in the LLVM codebase to support LLVM Windows shared library builds. This change is required to allow external code to use PassManager callbacks including LLVM's own tests for it. Remove the only use of llvm::Any for LoopNest that only existed in debug code and there was no code creating Any --- llvm/include/llvm/Analysis/LazyCallGraph.h | 5 + llvm/include/llvm/IR/PassInstrumentation.h | 12 +++- llvm/lib/Analysis/LazyCallGraph.cpp| 4 llvm/lib/IR/PassInstrumentation.cpp| 6 ++ llvm/lib/Transforms/Scalar/LoopPassManager.cpp | 2 -- llvm/unittests/IR/PassBuilderCallbacksTest.cpp | 2 -- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/Analysis/LazyCallGraph.h b/llvm/include/llvm/Analysis/LazyCallGraph.h index e7fd18967d9bed..55060f506c3330 100644 --- a/llvm/include/llvm/Analysis/LazyCallGraph.h +++ b/llvm/include/llvm/Analysis/LazyCallGraph.h @@ -34,6 +34,7 @@ #ifndef LLVM_ANALYSIS_LAZYCALLGRAPH_H #define LLVM_ANALYSIS_LAZYCALLGRAPH_H +#include "llvm/ADT/Any.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerIntPair.h" @@ -1308,6 +1309,10 @@ class LazyCallGraphDOTPrinterPass static bool isRequired() { return true; } }; +#ifdef _WIN32 +extern template struct LLVM_TEMPLATE_ABI +Any::TypeId; +#endif } // end namespace llvm #endif // LLVM_ANALYSIS_LAZYCALLGRAPH_H diff --git a/llvm/include/llvm/IR/PassInstrumentation.h b/llvm/include/llvm/IR/PassInstrumentation.h index 9fcc2d5957a30c..c41c287f5f1e99 100644 --- a/llvm/include/llvm/IR/PassInstrumentation.h +++ b/llvm/include/llvm/IR/PassInstrumentation.h @@ -50,10 +50,11 @@ #define LLVM_IR_PASSINSTRUMENTATION_H #include "llvm/ADT/Any.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/DenseMap.h" #include "llvm/IR/PassManager.h" +#include "llvm/Support/Compiler.h" #include #include @@ -61,6 +62,15 @@ namespace llvm { class PreservedAnalyses; class StringRef; +class Module; +class Loop; +class Function; + +#ifdef _WIN32 +extern template struct LLVM_TEMPLATE_ABI Any::TypeId; +extern template struct LLVM_TEMPLATE_ABI Any::TypeId; +extern template struct LLVM_TEMPLATE_ABI Any::TypeId; +#endif /// This class manages callbacks registration, as well as provides a way for /// PassInstrumentation to pass control to the registered callbacks. diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index e6bf8c9cbb289f..9d74bce98122bb 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -37,6 +37,10 @@ using namespace llvm; #define DEBUG_TYPE "lcg" +#ifdef _WIN32 +template struct LLVM_EXPORT_TEMPLATE Any::TypeId; +#endif + void LazyCallGraph::EdgeSequence::insertEdgeInternal(Node &TargetN, Edge::Kind EK) { EdgeIndexMap.try_emplace(&TargetN, Edges.size()); diff --git a/llvm/lib/IR/PassInstrumentation.cpp b/llvm/lib/IR/PassInstrumentation.cpp index 0c4e7698d9fa87..134990eee26988 100644 --- a/llvm/lib/IR/PassInstrumentation.cpp +++ b/llvm/lib/IR/PassInstrumentation.cpp @@ -17,6 +17,12 @@ namespace llvm { +#ifdef _WIN32 +template struct LLVM_EXPORT_TEMPLATE Any::TypeId; +template struct LLVM_EXPORT_TEMPLATE Any::TypeId; +template struct LLVM_EXPORT_TEMPLATE Any::TypeId; +#endif + void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName, StringRef PassName) { ClassToPassName.try_emplace(ClassName, PassName.str()); diff --git a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp index 5ef25c21162fe2..3b08d5889edb12 100644 --- a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp @@ -273,8 +273,6 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, llvm::any_cast(&IR)); const Loop **LPtr = llvm::any_cast(&IR); const Loop *L = LPtr ? *LPtr : nullptr; -if (!L) - L = &llvm::any_cast(IR)->getOutermostLoop(); assert(L && "Loop should be valid for printing"); // Verify the loop structure and LCSSA form before visiting the loop. diff --git a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp index 6230aed7b7119b..9aad6e3ca91255 100644 --- a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp +++ b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp @
[clang] [clang][codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC (PR #113104)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Daniil (kin4stat) Changes MSVC normally has a bunch of restrictions on returning values directly which don't apply to passing values directly. (This roughly corresponds to the definition of a C++14 aggregate.) However, these restrictions don't apply to HVAs and HFAs; make sure we check for that. Fixes llvm/llvm-project#63417 --- Full diff: https://github.com/llvm/llvm-project/pull/113104.diff 2 Files Affected: - (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+4) - (modified) clang/test/CodeGenCXX/homogeneous-aggregates.cpp (+19) ``diff diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 0b0b45ffead92f..fa5d83243f60fe 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1110,6 +1110,10 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty, isa(Base)) { return true; } + if (CGM.getTarget().getTriple().isX86() && + CGM.getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts)) { +return true; + } // We use the C++14 definition of an aggregate, so we also // check for: diff --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp index 63ffc6b5bfac84..cf8019d2f18964 100644 --- a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp +++ b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp @@ -302,3 +302,22 @@ struct test2 : base2 { test2(double); protected: double v2;}; test2 f(test2 *x) { return *x; } // WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr dead_on_unwind inreg noalias writable sret(%"struct.pr62223::test2") align 8 %{{.*}}, ptr noundef %{{.*}}) } + +namespace pr113104 { +struct HFA { + float a; + float b; +}; + +using HVA = float __attribute__((__vector_size__(16), __aligned__(16))); + +struct base_hfa { HFA v1; }; +struct test_hfa : base_hfa { test_hfa(double); protected: HFA v2;}; +test_hfa CC f(test_hfa *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hfa" @"\01_ZN8pr1131041fEPNS_8test_hfaE@@8"(ptr noundef %x) + +struct base_hva { HVA v1; }; +struct test_hva : base_hva { test_hva(double); protected: HVA v2;}; +test_hva CC f(test_hva *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hva" @"\01_ZN8pr1131041fEPNS_8test_hvaE@@8"(ptr noundef %x) +} \ No newline at end of file `` https://github.com/llvm/llvm-project/pull/113104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC (PR #113104)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Daniil (kin4stat) Changes MSVC normally has a bunch of restrictions on returning values directly which don't apply to passing values directly. (This roughly corresponds to the definition of a C++14 aggregate.) However, these restrictions don't apply to HVAs and HFAs; make sure we check for that. Fixes llvm/llvm-project#63417 --- Full diff: https://github.com/llvm/llvm-project/pull/113104.diff 2 Files Affected: - (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+4) - (modified) clang/test/CodeGenCXX/homogeneous-aggregates.cpp (+19) ``diff diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 0b0b45ffead92f..fa5d83243f60fe 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1110,6 +1110,10 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty, isa(Base)) { return true; } + if (CGM.getTarget().getTriple().isX86() && + CGM.getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts)) { +return true; + } // We use the C++14 definition of an aggregate, so we also // check for: diff --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp index 63ffc6b5bfac84..cf8019d2f18964 100644 --- a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp +++ b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp @@ -302,3 +302,22 @@ struct test2 : base2 { test2(double); protected: double v2;}; test2 f(test2 *x) { return *x; } // WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr dead_on_unwind inreg noalias writable sret(%"struct.pr62223::test2") align 8 %{{.*}}, ptr noundef %{{.*}}) } + +namespace pr113104 { +struct HFA { + float a; + float b; +}; + +using HVA = float __attribute__((__vector_size__(16), __aligned__(16))); + +struct base_hfa { HFA v1; }; +struct test_hfa : base_hfa { test_hfa(double); protected: HFA v2;}; +test_hfa CC f(test_hfa *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hfa" @"\01_ZN8pr1131041fEPNS_8test_hfaE@@8"(ptr noundef %x) + +struct base_hva { HVA v1; }; +struct test_hva : base_hva { test_hva(double); protected: HVA v2;}; +test_hva CC f(test_hva *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hva" @"\01_ZN8pr1131041fEPNS_8test_hvaE@@8"(ptr noundef %x) +} \ No newline at end of file `` https://github.com/llvm/llvm-project/pull/113104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC (PR #113104)
https://github.com/kin4stat created https://github.com/llvm/llvm-project/pull/113104 MSVC normally has a bunch of restrictions on returning values directly which don't apply to passing values directly. (This roughly corresponds to the definition of a C++14 aggregate.) However, these restrictions don't apply to HVAs and HFAs; make sure we check for that. Fixes llvm/llvm-project#63417 >From 86127708ed74db3c6a826c13f7c21b11a457c76d Mon Sep 17 00:00:00 2001 From: kin4stat Date: Sun, 20 Oct 2024 23:43:03 +0300 Subject: [PATCH] [clang codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC MSVC normally has a bunch of restrictions on returning values directly which don't apply to passing values directly. (This roughly corresponds to the definition of a C++14 aggregate.) However, these restrictions don't apply to HVAs and HFAs; make sure we check for that. Fixes llvm/llvm-project#63417 --- clang/lib/CodeGen/MicrosoftCXXABI.cpp | 4 .../CodeGenCXX/homogeneous-aggregates.cpp | 19 +++ 2 files changed, 23 insertions(+) diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 0b0b45ffead92f..fa5d83243f60fe 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1110,6 +1110,10 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty, isa(Base)) { return true; } + if (CGM.getTarget().getTriple().isX86() && + CGM.getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts)) { +return true; + } // We use the C++14 definition of an aggregate, so we also // check for: diff --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp index 63ffc6b5bfac84..cf8019d2f18964 100644 --- a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp +++ b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp @@ -302,3 +302,22 @@ struct test2 : base2 { test2(double); protected: double v2;}; test2 f(test2 *x) { return *x; } // WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr dead_on_unwind inreg noalias writable sret(%"struct.pr62223::test2") align 8 %{{.*}}, ptr noundef %{{.*}}) } + +namespace pr113104 { +struct HFA { + float a; + float b; +}; + +using HVA = float __attribute__((__vector_size__(16), __aligned__(16))); + +struct base_hfa { HFA v1; }; +struct test_hfa : base_hfa { test_hfa(double); protected: HFA v2;}; +test_hfa CC f(test_hfa *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hfa" @"\01_ZN8pr1131041fEPNS_8test_hfaE@@8"(ptr noundef %x) + +struct base_hva { HVA v1; }; +struct test_hva : base_hva { test_hva(double); protected: HVA v2;}; +test_hva CC f(test_hva *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hva" @"\01_ZN8pr1131041fEPNS_8test_hvaE@@8"(ptr noundef %x) +} \ No newline at end of file ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC (PR #113104)
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/113104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][codegen] Fix ABI for HVA/HFA returns on x86_64 MSVC (PR #113104)
https://github.com/kin4stat edited https://github.com/llvm/llvm-project/pull/113104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix working -assume-filename with .clang-format-ignore (PR #113100)
https://github.com/kakkoko created https://github.com/llvm/llvm-project/pull/113100 Fixes #113099. >From e095b552d4d7588c74f2f59951045d546e00fe6d Mon Sep 17 00:00:00 2001 From: kakkoko Date: Mon, 21 Oct 2024 03:48:13 +0900 Subject: [PATCH] [clang-format] Fix working -assume-filename with .clang-format-ignore The filename given by the `-assume-filename` option is used to search for `.clang-format` files, etc., but is not used to match the contents of the `.clang-format-ignore` file. Fixed that when the `-assume-filename` option is specified, the `.clang-format-ignore` file is processed for that filename. --- clang/test/Format/clang-format-ignore.cpp | 11 +++ clang/tools/clang-format/ClangFormat.cpp | 8 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clang/test/Format/clang-format-ignore.cpp b/clang/test/Format/clang-format-ignore.cpp index fb49fa9dd52c65..198ef3200a3845 100644 --- a/clang/test/Format/clang-format-ignore.cpp +++ b/clang/test/Format/clang-format-ignore.cpp @@ -46,5 +46,16 @@ // CHECK5-NEXT: {{Formatting \[4/5] .*foo\.c}} // CHECK5-NOT: foo.js +// RUN: echo "foo.*" > .clang-format-ignore +// RUN: touch foo.c +// RUN: echo foo | clang-format -assume-filename=foo.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK6 -allow-empty +// CHECK6-NOT: foo + +// RUN: touch bar.c +// RUN: echo foo | clang-format -assume-filename=bar.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK7 -allow-empty +// CHECK7: foo + // RUN: cd .. // RUN: rm -r %t.dir diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 108db7204aa68a..c31f3d97f17eb1 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -707,8 +707,14 @@ int main(int argc, const char **argv) { errs() << "Clang-formatting " << LineNo << " files\n"; } - if (FileNames.empty()) + if (FileNames.empty()) { +if (!AssumeFileName.empty() && isIgnored(AssumeFileName)) { + outs() << "ignored\n"; + return 0; +} +outs() << "not ignored\n"; return clang::format::format("-", FailOnIncompleteFormat); + } if (FileNames.size() > 1 && (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty())) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix working -assume-filename with .clang-format-ignore (PR #113100)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: kakkoko (kakkoko) Changes Fixes #113099. --- Full diff: https://github.com/llvm/llvm-project/pull/113100.diff 2 Files Affected: - (modified) clang/test/Format/clang-format-ignore.cpp (+11) - (modified) clang/tools/clang-format/ClangFormat.cpp (+7-1) ``diff diff --git a/clang/test/Format/clang-format-ignore.cpp b/clang/test/Format/clang-format-ignore.cpp index fb49fa9dd52c65..198ef3200a3845 100644 --- a/clang/test/Format/clang-format-ignore.cpp +++ b/clang/test/Format/clang-format-ignore.cpp @@ -46,5 +46,16 @@ // CHECK5-NEXT: {{Formatting \[4/5] .*foo\.c}} // CHECK5-NOT: foo.js +// RUN: echo "foo.*" > .clang-format-ignore +// RUN: touch foo.c +// RUN: echo foo | clang-format -assume-filename=foo.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK6 -allow-empty +// CHECK6-NOT: foo + +// RUN: touch bar.c +// RUN: echo foo | clang-format -assume-filename=bar.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK7 -allow-empty +// CHECK7: foo + // RUN: cd .. // RUN: rm -r %t.dir diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 108db7204aa68a..c31f3d97f17eb1 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -707,8 +707,14 @@ int main(int argc, const char **argv) { errs() << "Clang-formatting " << LineNo << " files\n"; } - if (FileNames.empty()) + if (FileNames.empty()) { +if (!AssumeFileName.empty() && isIgnored(AssumeFileName)) { + outs() << "ignored\n"; + return 0; +} +outs() << "not ignored\n"; return clang::format::format("-", FailOnIncompleteFormat); + } if (FileNames.size() > 1 && (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty())) { `` https://github.com/llvm/llvm-project/pull/113100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix working -assume-filename with .clang-format-ignore (PR #113100)
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/113100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix working -assume-filename with .clang-format-ignore (PR #113100)
https://github.com/kakkoko updated https://github.com/llvm/llvm-project/pull/113100 >From 7a315297c29244fb9a7358b962784c2fd984986c Mon Sep 17 00:00:00 2001 From: kakkoko Date: Mon, 21 Oct 2024 03:48:13 +0900 Subject: [PATCH] [clang-format] Fix working -assume-filename with .clang-format-ignore The filename given by the `-assume-filename` option is used to search for `.clang-format` files, etc., but is not used to match the contents of the `.clang-format-ignore` file. Fixed that when the `-assume-filename` option is specified, the `.clang-format-ignore` file is processed for that filename. --- clang/test/Format/clang-format-ignore.cpp | 11 +++ clang/tools/clang-format/ClangFormat.cpp | 6 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/clang/test/Format/clang-format-ignore.cpp b/clang/test/Format/clang-format-ignore.cpp index fb49fa9dd52c65..198ef3200a3845 100644 --- a/clang/test/Format/clang-format-ignore.cpp +++ b/clang/test/Format/clang-format-ignore.cpp @@ -46,5 +46,16 @@ // CHECK5-NEXT: {{Formatting \[4/5] .*foo\.c}} // CHECK5-NOT: foo.js +// RUN: echo "foo.*" > .clang-format-ignore +// RUN: touch foo.c +// RUN: echo foo | clang-format -assume-filename=foo.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK6 -allow-empty +// CHECK6-NOT: foo + +// RUN: touch bar.c +// RUN: echo foo | clang-format -assume-filename=bar.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK7 -allow-empty +// CHECK7: foo + // RUN: cd .. // RUN: rm -r %t.dir diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 108db7204aa68a..84eaf32cc44498 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -707,8 +707,12 @@ int main(int argc, const char **argv) { errs() << "Clang-formatting " << LineNo << " files\n"; } - if (FileNames.empty()) + if (FileNames.empty()) { +if (!AssumeFileName.empty() && isIgnored(AssumeFileName)) { + return 0; +} return clang::format::format("-", FailOnIncompleteFormat); + } if (FileNames.size() > 1 && (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty())) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix working -assume-filename with .clang-format-ignore (PR #113100)
https://github.com/kakkoko updated https://github.com/llvm/llvm-project/pull/113100 >From 7a315297c29244fb9a7358b962784c2fd984986c Mon Sep 17 00:00:00 2001 From: kakkoko Date: Mon, 21 Oct 2024 03:48:13 +0900 Subject: [PATCH] [clang-format] Fix working -assume-filename with .clang-format-ignore The filename given by the `-assume-filename` option is used to search for `.clang-format` files, etc., but is not used to match the contents of the `.clang-format-ignore` file. Fixed that when the `-assume-filename` option is specified, the `.clang-format-ignore` file is processed for that filename. --- clang/test/Format/clang-format-ignore.cpp | 11 +++ clang/tools/clang-format/ClangFormat.cpp | 6 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/clang/test/Format/clang-format-ignore.cpp b/clang/test/Format/clang-format-ignore.cpp index fb49fa9dd52c65..198ef3200a3845 100644 --- a/clang/test/Format/clang-format-ignore.cpp +++ b/clang/test/Format/clang-format-ignore.cpp @@ -46,5 +46,16 @@ // CHECK5-NEXT: {{Formatting \[4/5] .*foo\.c}} // CHECK5-NOT: foo.js +// RUN: echo "foo.*" > .clang-format-ignore +// RUN: touch foo.c +// RUN: echo foo | clang-format -assume-filename=foo.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK6 -allow-empty +// CHECK6-NOT: foo + +// RUN: touch bar.c +// RUN: echo foo | clang-format -assume-filename=bar.c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK7 -allow-empty +// CHECK7: foo + // RUN: cd .. // RUN: rm -r %t.dir diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 108db7204aa68a..84eaf32cc44498 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -707,8 +707,12 @@ int main(int argc, const char **argv) { errs() << "Clang-formatting " << LineNo << " files\n"; } - if (FileNames.empty()) + if (FileNames.empty()) { +if (!AssumeFileName.empty() && isIgnored(AssumeFileName)) { + return 0; +} return clang::format::format("-", FailOnIncompleteFormat); + } if (FileNames.size() > 1 && (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty())) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer][doc] Update Clang SA www docs index.html (PR #112833)
@@ -69,48 +69,7 @@ Clang Static Analyzer -The Clang Static Analyzer is a source code analysis tool that finds bugs in -C, C++, and Objective-C programs. - -Currently it can be run either from the command - line or if you use macOS then within Xcode. When -invoked from the command line, it is intended to be run in tandem with a build -of a codebase. - -The analyzer is 100% open source and is part of the https://clang.llvm.org";>Clang project. Like the rest of Clang, the -analyzer is implemented as a C++ library that can be used by other tools and -applications. haoNoQ wrote: The intro part can probably stay? (Except the second paragraph.) https://github.com/llvm/llvm-project/pull/112833 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- 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 +// +//===--===// +// +// This defines BoundsInformationChecker, a path-sensitive checker that +// checks that the buffer and count arguments are within the bounds of +// the source buffer. +// +//===--===// + +#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h" +#include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" + +using namespace clang; +using namespace ento; + +namespace { +class BoundsInformationChecker : public Checker { + const BugType BT_DifferentMemRegion{ + this, "std::span constructor arguments from different sources", + categories::SecurityError}; + const BugType BT_NonConstantSizeArg{ + this, + "std::span constructor for std::array has non-constant size argument", + categories::SecurityError}; + const BugType BT_OutOfBounds{ + this, + "std::span constructor for std::array uses out-of-bounds size argument", + categories::SecurityError}; + void reportBug(ExplodedNode *N, const Expr *E, CheckerContext &C, + const BugType &BT, StringRef Msg) const; + +public: + void checkPreCall(const CallEvent &Call, CheckerContext &C) const; +}; +} // end anonymous namespace + +void BoundsInformationChecker::reportBug(ExplodedNode *N, const Expr *E, + CheckerContext &C, const BugType &BT, + StringRef Msg) const { + // Generate a report for this bug. + auto R = std::make_unique(BT, Msg, N); + if (auto *CE = dyn_cast(E)) { +bugreporter::trackExpressionValue(N, CE->getArg(0), *R); +bugreporter::trackExpressionValue(N, CE->getArg(1), *R); + } + C.emitReport(std::move(R)); +} + +static const MemRegion *GetRegionOrigin(SVal SV) { + const SymExpr *Sym = SV.getAsSymbol(/*IncludeBaseRegions =*/true); + return Sym ? Sym->getOriginRegion() : nullptr; +} + +static const ValueDecl *GetExpressionOrigin(const Stmt *STMT) { + if (const DeclRefExpr *DRE = dyn_cast(STMT)) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } else if (const CXXMemberCallExpr *MCE = dyn_cast(STMT)) { +if (const DeclRefExpr *DRE = dyn_cast( +MCE->getImplicitObjectArgument()->IgnoreParenCasts())) { + if (const VarDecl *VD = dyn_cast(DRE->getDecl())) +return VD; +} else if (const MemberExpr *ME = dyn_cast( + MCE->getImplicitObjectArgument()->IgnoreParenCasts())) { + if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl())) +return FD; +} + } else if (const CXXOperatorCallExpr *OCE = + dyn_cast(STMT)) { +if (OCE->getNumArgs() >= 1) { + if (const DeclRefExpr *DRE = dyn_cast(OCE->getArg(0))) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } +} + } else if (const UnaryOperator *UnaryOp = dyn_cast(STMT)) { +if (const ArraySubscriptExpr *ASExpr = +dyn_cast(UnaryOp->getSubExpr())) { + if (const DeclRefExpr *DRE = + dyn_cast(ASExpr->getBase()->IgnoreParenCasts())) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } +} + } else if (const UnaryExprOrTypeTraitExpr *UTExpr = + dyn_cast(STMT)) { +if (const DeclRefExpr *DRE = dyn_cast( +UTExpr->getArgumentExpr()->IgnoreParenCasts())) { + if (const VarDecl *VD = dyn_cast(DRE->getDecl())) +return VD; +} + } + return nullptr; +} + +static const ValueDecl *GetConjuredSymbolOrigin(SVal SV) { + const SymExpr *Sym = SV.getAsSymbol(/*IncludeBaseRegions =*/true); + if (const SymbolConjured *SCArg = dyn_cast_or_null(Sym)) { +if (const Stmt *STMTArg = SCArg->getStmt()) + return GetExpressionOrigin(STMTArg); + } + return nullptr; +} + +void BoundsInformationChecker::checkPreCall(const CallEvent &Call, +CheckerContext &C) const { + // Return early if not std::span(IT, size_t) constructor. + // a. Check if this is a ctor for std::span. + CallDescription CD({CDM::CXXMethod, {"std", "span", "span"}}); + if (!CD.m
[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)
@@ -0,0 +1,76 @@ +// RUN: %clang %s -std=c++20 -Xclang -verify --analyze \ +// RUN: -Xclang -analyzer-checker=core,alpha.cplusplus.BoundsInformation \ +// RUN: -Xclang -analyzer-checker=debug.ExprInspection haoNoQ wrote: `ExprInspection` is probably unnecessary. (It's a checker built for the purposes of debugging/testing the engine, mostly. It reacts on magic function calls such as `clang_analyzer_eval()`. You don't have any of those magic calls in the test. See also https://clang.llvm.org/docs/analyzer/developer-docs/DebugChecks.html) https://github.com/llvm/llvm-project/pull/112784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- 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 +// +//===--===// +// +// This defines BoundsInformationChecker, a path-sensitive checker that +// checks that the buffer and count arguments are within the bounds of +// the source buffer. +// +//===--===// + +#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h" +#include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" + +using namespace clang; +using namespace ento; + +namespace { +class BoundsInformationChecker : public Checker { + const BugType BT_DifferentMemRegion{ + this, "std::span constructor arguments from different sources", + categories::SecurityError}; + const BugType BT_NonConstantSizeArg{ + this, + "std::span constructor for std::array has non-constant size argument", + categories::SecurityError}; + const BugType BT_OutOfBounds{ + this, + "std::span constructor for std::array uses out-of-bounds size argument", + categories::SecurityError}; + void reportBug(ExplodedNode *N, const Expr *E, CheckerContext &C, + const BugType &BT, StringRef Msg) const; + +public: + void checkPreCall(const CallEvent &Call, CheckerContext &C) const; +}; +} // end anonymous namespace + +void BoundsInformationChecker::reportBug(ExplodedNode *N, const Expr *E, + CheckerContext &C, const BugType &BT, + StringRef Msg) const { + // Generate a report for this bug. + auto R = std::make_unique(BT, Msg, N); + if (auto *CE = dyn_cast(E)) { +bugreporter::trackExpressionValue(N, CE->getArg(0), *R); +bugreporter::trackExpressionValue(N, CE->getArg(1), *R); + } + C.emitReport(std::move(R)); +} + +static const MemRegion *GetRegionOrigin(SVal SV) { + const SymExpr *Sym = SV.getAsSymbol(/*IncludeBaseRegions =*/true); + return Sym ? Sym->getOriginRegion() : nullptr; +} + +static const ValueDecl *GetExpressionOrigin(const Stmt *STMT) { + if (const DeclRefExpr *DRE = dyn_cast(STMT)) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } else if (const CXXMemberCallExpr *MCE = dyn_cast(STMT)) { +if (const DeclRefExpr *DRE = dyn_cast( +MCE->getImplicitObjectArgument()->IgnoreParenCasts())) { + if (const VarDecl *VD = dyn_cast(DRE->getDecl())) +return VD; +} else if (const MemberExpr *ME = dyn_cast( + MCE->getImplicitObjectArgument()->IgnoreParenCasts())) { + if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl())) +return FD; +} + } else if (const CXXOperatorCallExpr *OCE = + dyn_cast(STMT)) { +if (OCE->getNumArgs() >= 1) { + if (const DeclRefExpr *DRE = dyn_cast(OCE->getArg(0))) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } +} + } else if (const UnaryOperator *UnaryOp = dyn_cast(STMT)) { +if (const ArraySubscriptExpr *ASExpr = +dyn_cast(UnaryOp->getSubExpr())) { + if (const DeclRefExpr *DRE = + dyn_cast(ASExpr->getBase()->IgnoreParenCasts())) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } +} + } else if (const UnaryExprOrTypeTraitExpr *UTExpr = + dyn_cast(STMT)) { +if (const DeclRefExpr *DRE = dyn_cast( +UTExpr->getArgumentExpr()->IgnoreParenCasts())) { + if (const VarDecl *VD = dyn_cast(DRE->getDecl())) +return VD; +} + } + return nullptr; +} + +static const ValueDecl *GetConjuredSymbolOrigin(SVal SV) { + const SymExpr *Sym = SV.getAsSymbol(/*IncludeBaseRegions =*/true); + if (const SymbolConjured *SCArg = dyn_cast_or_null(Sym)) { +if (const Stmt *STMTArg = SCArg->getStmt()) + return GetExpressionOrigin(STMTArg); + } + return nullptr; +} + +void BoundsInformationChecker::checkPreCall(const CallEvent &Call, +CheckerContext &C) const { + // Return early if not std::span(IT, size_t) constructor. + // a. Check if this is a ctor for std::span. + CallDescription CD({CDM::CXXMethod, {"std", "span", "span"}}); + if (!CD.m
[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- 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 +// +//===--===// +// +// This defines BoundsInformationChecker, a path-sensitive checker that +// checks that the buffer and count arguments are within the bounds of +// the source buffer. +// +//===--===// + +#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h" +#include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" + +using namespace clang; +using namespace ento; + +namespace { +class BoundsInformationChecker : public Checker { + const BugType BT_DifferentMemRegion{ + this, "std::span constructor arguments from different sources", + categories::SecurityError}; + const BugType BT_NonConstantSizeArg{ + this, + "std::span constructor for std::array has non-constant size argument", + categories::SecurityError}; + const BugType BT_OutOfBounds{ + this, + "std::span constructor for std::array uses out-of-bounds size argument", + categories::SecurityError}; + void reportBug(ExplodedNode *N, const Expr *E, CheckerContext &C, + const BugType &BT, StringRef Msg) const; + +public: + void checkPreCall(const CallEvent &Call, CheckerContext &C) const; +}; +} // end anonymous namespace + +void BoundsInformationChecker::reportBug(ExplodedNode *N, const Expr *E, + CheckerContext &C, const BugType &BT, + StringRef Msg) const { + // Generate a report for this bug. + auto R = std::make_unique(BT, Msg, N); + if (auto *CE = dyn_cast(E)) { +bugreporter::trackExpressionValue(N, CE->getArg(0), *R); +bugreporter::trackExpressionValue(N, CE->getArg(1), *R); + } + C.emitReport(std::move(R)); +} + +static const MemRegion *GetRegionOrigin(SVal SV) { + const SymExpr *Sym = SV.getAsSymbol(/*IncludeBaseRegions =*/true); + return Sym ? Sym->getOriginRegion() : nullptr; +} + +static const ValueDecl *GetExpressionOrigin(const Stmt *STMT) { + if (const DeclRefExpr *DRE = dyn_cast(STMT)) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } else if (const CXXMemberCallExpr *MCE = dyn_cast(STMT)) { +if (const DeclRefExpr *DRE = dyn_cast( +MCE->getImplicitObjectArgument()->IgnoreParenCasts())) { + if (const VarDecl *VD = dyn_cast(DRE->getDecl())) +return VD; +} else if (const MemberExpr *ME = dyn_cast( + MCE->getImplicitObjectArgument()->IgnoreParenCasts())) { + if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl())) +return FD; +} + } else if (const CXXOperatorCallExpr *OCE = + dyn_cast(STMT)) { +if (OCE->getNumArgs() >= 1) { + if (const DeclRefExpr *DRE = dyn_cast(OCE->getArg(0))) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } +} + } else if (const UnaryOperator *UnaryOp = dyn_cast(STMT)) { +if (const ArraySubscriptExpr *ASExpr = +dyn_cast(UnaryOp->getSubExpr())) { + if (const DeclRefExpr *DRE = + dyn_cast(ASExpr->getBase()->IgnoreParenCasts())) { +if (const VarDecl *VD = dyn_cast(DRE->getDecl())) + return VD; + } +} + } else if (const UnaryExprOrTypeTraitExpr *UTExpr = + dyn_cast(STMT)) { +if (const DeclRefExpr *DRE = dyn_cast( +UTExpr->getArgumentExpr()->IgnoreParenCasts())) { + if (const VarDecl *VD = dyn_cast(DRE->getDecl())) +return VD; +} + } + return nullptr; +} + +static const ValueDecl *GetConjuredSymbolOrigin(SVal SV) { + const SymExpr *Sym = SV.getAsSymbol(/*IncludeBaseRegions =*/true); + if (const SymbolConjured *SCArg = dyn_cast_or_null(Sym)) { +if (const Stmt *STMTArg = SCArg->getStmt()) + return GetExpressionOrigin(STMTArg); + } + return nullptr; +} + +void BoundsInformationChecker::checkPreCall(const CallEvent &Call, +CheckerContext &C) const { + // Return early if not std::span(IT, size_t) constructor. + // a. Check if this is a ctor for std::span. + CallDescription CD({CDM::CXXMethod, {"std", "span", "span"}}); + if (!CD.m
[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)
@@ -8385,14 +8385,19 @@ TreeTransform::TransformDeclStmt(DeclStmt *S) { if (Transformed != D) DeclChanged = true; -if (LSI && isa(Transformed)) - LSI->ContainsUnexpandedParameterPack |= - getSema() - .getASTContext() - .getTypeDeclType(cast(Transformed)) - .getCanonicalType() - .getTypePtr() - ->containsUnexpandedParameterPack(); +if (LSI) { + if (auto *TD = dyn_cast(Transformed)) +LSI->ContainsUnexpandedParameterPack |= +getSema() +.getASTContext() +.getTypeDeclType(TD) +.getCanonicalType() +->containsUnexpandedParameterPack(); + + if (auto *VD = dyn_cast(Transformed)) +LSI->ContainsUnexpandedParameterPack |= +VD->getType()->containsUnexpandedParameterPack(); +} zyn0217 wrote: I'm not sure if I understand "tracking unexpanded packs lexically". Do you have a link to that context? It sounds like we need a new bit to track that in Decls, despite that flag being accessible through their QualTypes' dependencies for the status quo. In the latter regard, it looks like we just need a shortcut method for it? https://github.com/llvm/llvm-project/pull/112896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits