[clang] [llvm] [Sanitizer] Make sanitizer passes idempotent (PR #99439)
https://github.com/skc7 updated https://github.com/llvm/llvm-project/pull/99439 >From 3c7c677b7d6dc3934fddc452021dcc2c06086606 Mon Sep 17 00:00:00 2001 From: skc7 Date: Thu, 18 Jul 2024 11:49:24 +0530 Subject: [PATCH] [Sanitizer] Make sanitizer passes idempotent. --- clang/test/CodeGenObjC/no-sanitize.m | 2 +- .../include/llvm/Transforms/Instrumentation.h | 4 ++ .../Instrumentation/AddressSanitizer.cpp | 5 ++ .../Instrumentation/DataFlowSanitizer.cpp | 3 + .../Instrumentation/HWAddressSanitizer.cpp| 4 ++ .../Instrumentation/Instrumentation.cpp | 35 .../Instrumentation/MemorySanitizer.cpp | 4 ++ .../Instrumentation/ThreadSanitizer.cpp | 3 + .../AddressSanitizer/asan-pass-second-run.ll | 55 +++ .../AddressSanitizer/missing_dbg.ll | 2 +- .../dfsan-pass-second-run.ll | 17 ++ .../hwasan-pass-second-run.ll | 41 ++ .../MemorySanitizer/msan-pass-second-run.ll | 43 +++ .../ThreadSanitizer/tsan-pass-second-run.ll | 28 ++ 14 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 llvm/test/Instrumentation/AddressSanitizer/asan-pass-second-run.ll create mode 100644 llvm/test/Instrumentation/DataFlowSanitizer/dfsan-pass-second-run.ll create mode 100644 llvm/test/Instrumentation/HWAddressSanitizer/hwasan-pass-second-run.ll create mode 100644 llvm/test/Instrumentation/MemorySanitizer/msan-pass-second-run.ll create mode 100644 llvm/test/Instrumentation/ThreadSanitizer/tsan-pass-second-run.ll diff --git a/clang/test/CodeGenObjC/no-sanitize.m b/clang/test/CodeGenObjC/no-sanitize.m index abaf6fab26ab6..b5c6a5ad745f3 100644 --- a/clang/test/CodeGenObjC/no-sanitize.m +++ b/clang/test/CodeGenObjC/no-sanitize.m @@ -2,7 +2,7 @@ @interface I0 @end @implementation I0 -// CHECK-NOT: sanitize_address +// CHECK-NOT: Function Attrs: sanitize_address - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) { int (^blockName)(void) = ^int(void) { return 0; }; } diff --git a/llvm/include/llvm/Transforms/Instrumentation.h b/llvm/include/llvm/Transforms/Instrumentation.h index 969c2cd12f3f0..885d3249fb4f8 100644 --- a/llvm/include/llvm/Transforms/Instrumentation.h +++ b/llvm/include/llvm/Transforms/Instrumentation.h @@ -30,6 +30,10 @@ class Triple; class OptimizationRemarkEmitter; class Comdat; class CallBase; +class Module; + +/// Check if module has flag attached, if not add the flag. +bool checkIfAlreadyInstrumented(Module &M, StringRef Flag); /// Instrumentation passes often insert conditional checks into entry blocks. /// Call this function before splitting the entry block to move instructions diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 9fb1df7ab2b79..9416c8d87dd9d 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1251,6 +1251,11 @@ AddressSanitizerPass::AddressSanitizerPass( PreservedAnalyses AddressSanitizerPass::run(Module &M, ModuleAnalysisManager &MAM) { + // Return early if nosanitize_address module flag is present for the module. + // This implies that asan pass has already run before. + if (checkIfAlreadyInstrumented(M, "nosanitize_address")) +return PreservedAnalyses::all(); + ModuleAddressSanitizer ModuleSanitizer( M, Options.InsertVersionCheck, Options.CompileKernel, Options.Recover, UseGlobalGC, UseOdrIndicator, DestructorKind, ConstructorKind); diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index 113d39b4f2af7..b4b5f67d2e62d 100644 --- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -3473,6 +3473,9 @@ void DFSanVisitor::visitPHINode(PHINode &PN) { PreservedAnalyses DataFlowSanitizerPass::run(Module &M, ModuleAnalysisManager &AM) { + // Return early if nosanitize_dataflow module flag is present for the module. + if (checkIfAlreadyInstrumented(M, "nosanitize_dataflow")) +return PreservedAnalyses::all(); auto GetTLI = [&](Function &F) -> TargetLibraryInfo & { auto &FAM = AM.getResult(M).getManager(); diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index 812874ff3c173..95433a216b168 100644 --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -57,6 +57,7 @@ #include "llvm/Support/RandomNumberGenerator.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Triple.h" +#include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Instrumenta
[clang] [Clang][Sema][OpenMP] Allow `num_teams` to accept multiple expressions (PR #99732)
@@ -11357,8 +11358,13 @@ void OMPClauseReader::VisitOMPAllocateClause(OMPAllocateClause *C) { void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) { VisitOMPClauseWithPreInit(C); - C->setNumTeams(Record.readSubExpr()); C->setLParenLoc(Record.readSourceLocation()); + unsigned NumVars = C->varlist_size(); + SmallVector Vars; + Vars.reserve(NumVars); + for ([[maybe_unused]] unsigned I : llvm::seq(NumVars)) jdoerfert wrote: Looks to me like it works fine in C++: https://cxx.godbolt.org/z/7W5zxs1ME https://github.com/llvm/llvm-project/pull/99732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)
@@ -1185,6 +1189,9 @@ Currently, only the following parameter attributes are defined: value should be sign-extended to the extent required by the target's ABI (which is usually 32-bits) by the caller (for a parameter) or the callee (for a return value). +``noext`` This indicates to the code generator that the parameter or return +value has the high bits undefined, as for a struct in register, and +therefore does not need to be sign or zero extended. JonPsson1 wrote: > Can we do IR verifier for ABI illegal cases instead? In previous discussions it has been agreed to generally let the target decide on how to act on the argument extensions attributes. So we decided to keep the check for these in the (SystemZ) backend. Per my understanding, this is related to the target platform ABI - some targets like SystemZ has specific extension requirements of arguments. Others do not and can therefore ignore these attributes. Therefore, having a general IR verifier for this doesn't quite make sense - unless one would add a new hook as well to check with the target that it depends on valid argument extension attributes. > My suggestion is to introduce ABI verification code for each target in the IR > verifier... I agree this would make sense, but think this could be a follow-up patch once we have the needed parts this patch provides. > The goal is to get some sort of error from code like that, instead of an > obscure miscompile. Yes, if the front-end or an instrumentation pass forgets to add the extension, it could lead to wrong-code that is hard to track down. This is especially treacherous since somebody might work on a target that do not care about this at all and introduce a problem on another target that depends on it. In such a case it would be great if e.g. the SystemZ buildbot would fail by detecting the case with no extension attribute. https://github.com/llvm/llvm-project/pull/100757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)
https://github.com/martinboehme requested changes to this pull request. Sorry - I only noticed now after your rebase that this had been sitting in my review queue for quite a while. * I would suggest rewording the option name. The "ignore" (`IgnoreNonDerefSmartPtrs`) reads like a negation, which makes it harder to reason about what the option does. How about `AllowMovedSmartPtrUse`? (I think maybe the "non-deref" can be omitted from the option name -- I think it's sufficient that it's explained in the documentation). * In https://github.com/llvm/llvm-project/issues/90174, I suggested that if we wanted to change the default behavior, we should survey users to see what their opinions / preferences are. Have you done this? If not, I think the default behavior (when the option is not set) should remain unchanged. https://github.com/llvm/llvm-project/pull/94869 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][AVX10.2] Support AVX10.2 VNNI FP16/INT8/INT16 new instructions (PR #101783)
https://github.com/KanRobert approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/101783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Handle CXXInheritedCtorInitExpr in ResultObjectVisitor. (PR #99616)
martinboehme wrote: @haoNoQ Thank you for going to the trouble to explain all of this in detail! > I'm very open to changes in `ConstructionContext` to accommodate your needs, > like provide extra information that we didn't need but you did, or provide it > in a different way. I haven't looked in detail yet, but I think all of the information we need is there. The main thing I'm wondering is whether we can make it so there are fewer case distinctions that the code in `FlowSensitive` would need to perform -- i.e. so that we wouldn't need to handle all of the possible cases in `ConstructionContext::Kind` individually. As far as I can tell, the various "intermediate" classes in the class hierarchy look as if they provide a mechanism for this. I.e. instead of distinguishing between all of the possible leaf classes, we would merely handle `VariableConstructionContext`, `ConstructorInitializerConstructionContext`, `TemporaryObjectConstructionContext`, and `ReturnedValueConstructionContext`. I _think_ that for our purposes (i.e. identifying the result object that a record prvalue initializes), these intermediate classes should provide all of the information we need. (I believe the finer-grained information is only necessary for the additional analysis that you do, e.g. for temporary destructors, as you explain.) Does this sound right? If you agree that this works, then the main question to me is how we make sure that we make sure we update our code if more cases are added to `ConstructionContext`. This is easy to do with a switch-case over `ConstructionContext::Kind`, as the compiler will warn if any of the cases are not handled, but we don't get any such warning when doing a series of `dyn_cast`s over the various "intermediate" classes in the hierarchy (i.e. `VariableConstructionContext` and so on). We could, of course, still use a switch case but then cast to the appropriate intermediate class. I see that you also do in this in some places in the code, e.g. in [ExprEngineCXX.cpp](https://github.com/llvm/llvm-project/blob/86f7374078288e2b3d3d0fd66428f7752e2319e6/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp#L132). Is this the approach that you would recommend? https://github.com/llvm/llvm-project/pull/99616 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix potential null pointer dereferences in Sema::AddInitializerToDecl (PR #94368)
https://github.com/cor3ntin requested changes to this pull request. Do you have any test that crashes without this change? I agree with @feg208, we should assert Init is not null there (rather that silently return). If there are cases where init could in fact be null, we should add a test for it. Thanks! https://github.com/llvm/llvm-project/pull/94368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix potential null pointer dereferences in Sema::AddInitializerToDecl (PR #94368)
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/94368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Add GCS support for AArch64 (PR #99335)
tru wrote: > Though having said all this, I marked this for LLVM 19 as my reading of > https://discourse.llvm.org/t/update-on-llvm-19-x-releases/80511 was that new > features are still ok before RC2, but re-reading it it's a bit ambiguous: it > says "New features will have to wait until LLVM 20 at this point" and my > reading of that was that "this point" means RC2, so new features before RC2 > is fine, but if "this point" meant "right now" that means new features aren't > OK. If that's the case the it's reasonable for this to not go in RC2. I am fine with it going into RC2 if it's part of a on-going work as you explained and that it doesn't create any big issues. Unfortunately with nico's latest comment it seems like this is breaking some build configurations and I am cutting RC2 now, I don't feel comfortable to merge it before that has been investigated. I can probably be convinced to take it in RC3 if it's really helpful to do so and it have been working without any problems. https://github.com/llvm/llvm-project/pull/99335 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7536ebf - [Clang][SemaCXX] Fix bug where unexpanded lambda captures where assumed to have size 1 (#101385)
Author: Mital Ashok Date: 2024-08-05T16:16:55+08:00 New Revision: 7536ebf0ea8e2d09f47ee77e0d60470b5eeb2743 URL: https://github.com/llvm/llvm-project/commit/7536ebf0ea8e2d09f47ee77e0d60470b5eeb2743 DIFF: https://github.com/llvm/llvm-project/commit/7536ebf0ea8e2d09f47ee77e0d60470b5eeb2743.diff LOG: [Clang][SemaCXX] Fix bug where unexpanded lambda captures where assumed to have size 1 (#101385) Fixes #63677 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/TreeTransform.h clang/test/SemaCXX/lambda-pack-expansion.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 17696ee9ca484..6f50ab07f1fc0 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -185,6 +185,7 @@ Bug Fixes to C++ Support - Clang now correctly recognizes the correct context for parameter substitutions in concepts, so it doesn't incorrectly complain of missing module imports in those situations. (#GH60336) +- Fix init-capture packs having a size of one before being instantiated. (#GH63677) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 8995d461362d7..de470739ab78e 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1447,7 +1447,8 @@ namespace { } void transformedLocalDecl(Decl *Old, ArrayRef NewDecls) { - if (Old->isParameterPack()) { + if (Old->isParameterPack() && + (NewDecls.size() != 1 || !NewDecls.front()->isParameterPack())) { SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Old); for (auto *New : NewDecls) SemaRef.CurrentInstantiationScope->InstantiatedLocalPackArg( diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 8d3e1edf7a45d..540e1e0cb8df0 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -14340,14 +14340,14 @@ TreeTransform::TransformLambdaExpr(LambdaExpr *E) { OldVD->getInit()->getSourceRange(), Unexpanded, Expand, RetainExpansion, NumExpansions)) return ExprError(); + assert(!RetainExpansion && "Should not need to retain expansion after a " + "capture since it cannot be extended"); if (Expand) { for (unsigned I = 0; I != *NumExpansions; ++I) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); SubstInitCapture(SourceLocation(), std::nullopt); } - } - if (!Expand || RetainExpansion) { -ForgetPartiallySubstitutedPackRAII Forget(getDerived()); + } else { SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions); Result.EllipsisLoc = ExpansionTL.getEllipsisLoc(); } diff --git a/clang/test/SemaCXX/lambda-pack-expansion.cpp b/clang/test/SemaCXX/lambda-pack-expansion.cpp index 221d1d01a06ae..77b2e244753a9 100644 --- a/clang/test/SemaCXX/lambda-pack-expansion.cpp +++ b/clang/test/SemaCXX/lambda-pack-expansion.cpp @@ -41,3 +41,30 @@ int h(Ts... ts) { } } + +namespace GH63677 { + +template +void f() { + []() -> void { +[...us = Ts{}]{ + (Ts(us), ...); +}; + }.template operator()(); +} + +template void f(); + +template +inline constexpr auto fun = + [](Ts... ts) { +return [... us = (Ts&&) ts](Fun&& fn) mutable { + return static_cast(fn)(static_cast(us)...); +}; + }; + +void f() { + [[maybe_unused]] auto s = fun(1, 2, 3, 4); +} + +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][SemaCXX] Fix bug where unexpanded lambda captures where assumed to have size 1 (PR #101385)
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/101385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Handle Pointer::toAPValue() for expr bases (PR #101937)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/101937 No reason to return early for them anymore. >From 3b8a063c42f92faf6eac8b254b208d8d48013046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 5 Aug 2024 09:18:23 +0200 Subject: [PATCH] [clang][Interp] Handle Pointer::toAPValue() for expr bases No reason to return early for them anymore. --- clang/lib/AST/Interp/Pointer.cpp | 29 clang/test/AST/Interp/codegen.cpp| 10 ++ clang/test/AST/Interp/new-delete.cpp | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/Interp/Pointer.cpp b/clang/lib/AST/Interp/Pointer.cpp index f86be1214826d..2b1f8b460510c 100644 --- a/clang/lib/AST/Interp/Pointer.cpp +++ b/clang/lib/AST/Interp/Pointer.cpp @@ -16,6 +16,7 @@ #include "MemberPointer.h" #include "PrimType.h" #include "Record.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/RecordLayout.h" using namespace clang; @@ -155,12 +156,32 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { APValue::LValueBase Base; if (const auto *VD = Desc->asValueDecl()) Base = VD; - else if (const auto *E = Desc->asExpr()) -Base = E; - else + else if (const auto *E = Desc->asExpr()) { +// Create a DynamicAlloc base of the right type. +if (const auto *NewExpr = dyn_cast(E)) { + QualType AllocatedType; + if (NewExpr->isArray()) { +assert(Desc->isArray()); +APInt ArraySize(64, static_cast(Desc->getNumElems()), +/*IsSigned=*/false); +AllocatedType = +ASTCtx.getConstantArrayType(NewExpr->getAllocatedType(), ArraySize, +nullptr, ArraySizeModifier::Normal, 0); + } else { +AllocatedType = NewExpr->getAllocatedType(); + } + // FIXME: Suboptimal counting of dynamic allocations. Move this to Context + // or InterpState? + static int ReportedDynamicAllocs = 0; + DynamicAllocLValue DA(ReportedDynamicAllocs++); + Base = APValue::LValueBase::getDynamicAlloc(DA, AllocatedType); +} else { + Base = E; +} + } else llvm_unreachable("Invalid allocation type"); - if (isUnknownSizeArray() || Desc->asExpr()) + if (isUnknownSizeArray()) return APValue(Base, CharUnits::Zero(), Path, /*IsOnePastEnd=*/isOnePastEnd(), /*IsNullPtr=*/false); diff --git a/clang/test/AST/Interp/codegen.cpp b/clang/test/AST/Interp/codegen.cpp index f1f0a33673a5b..42d98a079e120 100644 --- a/clang/test/AST/Interp/codegen.cpp +++ b/clang/test/AST/Interp/codegen.cpp @@ -32,6 +32,16 @@ namespace BaseClassOffsets { B* b = &c; } +namespace ExprBase { + struct A { int n; }; + struct B { int n; }; + struct C : A, B {}; + + extern const int &&t = ((B&&)C{}).n; + // CHECK: @_ZGRN8ExprBase1tE_ = internal global {{.*}} zeroinitializer, + // CHECK: @_ZN8ExprBase1tE = constant ptr {{.*}} @_ZGRN8ExprBase1tE_, {{.*}} 8 +} + namespace reinterpretcast { const unsigned int n = 1234; extern const int &s = reinterpret_cast(n); diff --git a/clang/test/AST/Interp/new-delete.cpp b/clang/test/AST/Interp/new-delete.cpp index ddf91005c61d9..325ce27c6d51d 100644 --- a/clang/test/AST/Interp/new-delete.cpp +++ b/clang/test/AST/Interp/new-delete.cpp @@ -358,7 +358,7 @@ namespace delete_random_things { // both-note {{delete of pointer to subobject }} static_assert((delete (new int + 1), true)); // both-error {{}} \ // ref-note {{delete of pointer '&{*new int#0} + 1' that does not point to complete object}} \ - // expected-note {{delete of pointer '&new int + 1' that does not point to complete object}} + // expected-note {{delete of pointer '&{*new int#1} + 1' that does not point to complete object}} static_assert((delete[] (new int[3] + 1), true)); // both-error {{}} \ // both-note {{delete of pointer to subobject}} static_assert((delete &(int&)(int&&)0, true)); // both-error {{}} \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Handle Pointer::toAPValue() for expr bases (PR #101937)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes No reason to return early for them anymore. --- Full diff: https://github.com/llvm/llvm-project/pull/101937.diff 3 Files Affected: - (modified) clang/lib/AST/Interp/Pointer.cpp (+25-4) - (modified) clang/test/AST/Interp/codegen.cpp (+10) - (modified) clang/test/AST/Interp/new-delete.cpp (+1-1) ``diff diff --git a/clang/lib/AST/Interp/Pointer.cpp b/clang/lib/AST/Interp/Pointer.cpp index f86be1214826d..2b1f8b460510c 100644 --- a/clang/lib/AST/Interp/Pointer.cpp +++ b/clang/lib/AST/Interp/Pointer.cpp @@ -16,6 +16,7 @@ #include "MemberPointer.h" #include "PrimType.h" #include "Record.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/RecordLayout.h" using namespace clang; @@ -155,12 +156,32 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { APValue::LValueBase Base; if (const auto *VD = Desc->asValueDecl()) Base = VD; - else if (const auto *E = Desc->asExpr()) -Base = E; - else + else if (const auto *E = Desc->asExpr()) { +// Create a DynamicAlloc base of the right type. +if (const auto *NewExpr = dyn_cast(E)) { + QualType AllocatedType; + if (NewExpr->isArray()) { +assert(Desc->isArray()); +APInt ArraySize(64, static_cast(Desc->getNumElems()), +/*IsSigned=*/false); +AllocatedType = +ASTCtx.getConstantArrayType(NewExpr->getAllocatedType(), ArraySize, +nullptr, ArraySizeModifier::Normal, 0); + } else { +AllocatedType = NewExpr->getAllocatedType(); + } + // FIXME: Suboptimal counting of dynamic allocations. Move this to Context + // or InterpState? + static int ReportedDynamicAllocs = 0; + DynamicAllocLValue DA(ReportedDynamicAllocs++); + Base = APValue::LValueBase::getDynamicAlloc(DA, AllocatedType); +} else { + Base = E; +} + } else llvm_unreachable("Invalid allocation type"); - if (isUnknownSizeArray() || Desc->asExpr()) + if (isUnknownSizeArray()) return APValue(Base, CharUnits::Zero(), Path, /*IsOnePastEnd=*/isOnePastEnd(), /*IsNullPtr=*/false); diff --git a/clang/test/AST/Interp/codegen.cpp b/clang/test/AST/Interp/codegen.cpp index f1f0a33673a5b..42d98a079e120 100644 --- a/clang/test/AST/Interp/codegen.cpp +++ b/clang/test/AST/Interp/codegen.cpp @@ -32,6 +32,16 @@ namespace BaseClassOffsets { B* b = &c; } +namespace ExprBase { + struct A { int n; }; + struct B { int n; }; + struct C : A, B {}; + + extern const int &&t = ((B&&)C{}).n; + // CHECK: @_ZGRN8ExprBase1tE_ = internal global {{.*}} zeroinitializer, + // CHECK: @_ZN8ExprBase1tE = constant ptr {{.*}} @_ZGRN8ExprBase1tE_, {{.*}} 8 +} + namespace reinterpretcast { const unsigned int n = 1234; extern const int &s = reinterpret_cast(n); diff --git a/clang/test/AST/Interp/new-delete.cpp b/clang/test/AST/Interp/new-delete.cpp index ddf91005c61d9..325ce27c6d51d 100644 --- a/clang/test/AST/Interp/new-delete.cpp +++ b/clang/test/AST/Interp/new-delete.cpp @@ -358,7 +358,7 @@ namespace delete_random_things { // both-note {{delete of pointer to subobject }} static_assert((delete (new int + 1), true)); // both-error {{}} \ // ref-note {{delete of pointer '&{*new int#0} + 1' that does not point to complete object}} \ - // expected-note {{delete of pointer '&new int + 1' that does not point to complete object}} + // expected-note {{delete of pointer '&{*new int#1} + 1' that does not point to complete object}} static_assert((delete[] (new int[3] + 1), true)); // both-error {{}} \ // both-note {{delete of pointer to subobject}} static_assert((delete &(int&)(int&&)0, true)); // both-error {{}} \ `` https://github.com/llvm/llvm-project/pull/101937 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
https://github.com/MitalAshok edited https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -12370,6 +12379,17 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { } } +bool Sema::CheckLinkageSpecification(DeclContext *DC, Decl *D) { + // [basic.start.main] p2 + // The main function shall not be declared with a linkage-specification. + if (DC->isExternCContext()) { +Diag(D->getLocation(), diag::err_main_invalid_linkage_specification); +D->setInvalidDecl(); +return true; + } + return false; +} MitalAshok wrote: Does this need a separate member function? It seems like this would be good as a static helper function https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
https://github.com/MitalAshok requested changes to this pull request. You can put some of the tests in `clang/test/CXX/basic/basic.start/basic.start.main/p3.cpp` You lost the check for `extern "C++" int main() {}` at global scope. To recap: ```c++ // These are disallowed by [basic.start.main]p3 // The main function shall not be declared with a linkage-specification. // We only want a pedantic warning for these extern "C++" { int main(); } extern "C" { int main(); } // These are disallowed by [basic.start.main]p(3.4) // We want a hard error namespace X { extern "C" int main; } extern "C" { namespace Y { int main; } namespace Z { void main(); } } // These are allowed namespace W { extern "C++" int main(); extern "C" { extern "C++" { int main(void*); } } } ``` (You should add a test for `extern "C" { namespace namespace_name { int main; } }` too) Did you try doing it like https://github.com/llvm/llvm-project/issues/101512#issuecomment-2263650171 , checking `Decl->getLanguageLinkage()` rather than checking the DeclContext it's declared in? https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -7353,6 +7353,15 @@ void emitReadOnlyPlacementAttrWarning(Sema &S, const VarDecl *VD) { } } +static bool isMainVar(DeclarationName Name, VarDecl *VD) { + if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo()->isStr("main") && + !VD->getDescribedVarTemplate()) { +const DeclContext *DC = VD->getDeclContext(); +return DC->getRedeclContext()->isTranslationUnit() || DC->isLinkageSpec(); MitalAshok wrote: This doesn't seem to catch `extern "C" { namespace NS { int main; } }` ```suggestion return DC->getRedeclContext()->isTranslationUnit() || VD->getLanguageLinkage() == CLanguageLinkage; ``` https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -3292,11 +3292,9 @@ bool FunctionDecl::isImmediateFunction() const { } bool FunctionDecl::isMain() const { - const TranslationUnitDecl *tunit = -dyn_cast(getDeclContext()->getRedeclContext()); - return tunit && - !tunit->getASTContext().getLangOpts().Freestanding && - isNamed(this, "main"); + const DeclContext *DC = getDeclContext(); + return isNamed(this, "main") && !getLangOpts().Freestanding && MitalAshok wrote: This is slightly changed from `tunit->getASTContext()->getLangOpts().FreeStanding` to `getLangOpts().Freestanding`. Is there any reason for this change? I don't know if these can have different values, but better safe than sorry https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -990,6 +990,8 @@ def warn_main_redefined : Warning<"variable named 'main' with external linkage " "has undefined behavior">, InGroup; def ext_main_used : Extension< "referring to 'main' within an expression is a Clang extension">, InGroup; +def err_main_invalid_linkage_specification : ExtWarn< MitalAshok wrote: ```suggestion def ext_main_invalid_linkage_specification : ExtWarn< ``` https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)
https://github.com/TsXor created https://github.com/llvm/llvm-project/pull/101941 This is part 1 as described in #101784. I moved `LibclangExports`, `LibclangError` and modified `Config` class to a new file: `binder.py`. It can now be used by `cindex.py` with a simple `from .binder import Config`. This PR doesn't modify any existing files, so it is safe to merge. However, @DeinAlptraum will need to manually delete `functionList`, `Config` class and `LibclangError` and add `from .binder import Config` to utilize its typing benefits. Note: compared to #101784, I added a check that prevents `ctyped` from importing `WINFUNCTYPE` when not on windows, which should fix failing linux tests. >From 3e12ffd4afa52126e5fd162d62f832626bfb8578 Mon Sep 17 00:00:00 2001 From: TsXor Date: Mon, 5 Aug 2024 16:20:40 +0800 Subject: [PATCH] Introduce ctyped in an independent manner. --- clang/bindings/python/clang/binder.py | 804 ++ clang/bindings/python/clang/ctyped.py | 433 ++ .../bindings/python/tests/ctyped/__init__.py | 0 .../tests/ctyped/test_stub_conversion.py | 357 4 files changed, 1594 insertions(+) create mode 100644 clang/bindings/python/clang/binder.py create mode 100644 clang/bindings/python/clang/ctyped.py create mode 100644 clang/bindings/python/tests/ctyped/__init__.py create mode 100644 clang/bindings/python/tests/ctyped/test_stub_conversion.py diff --git a/clang/bindings/python/clang/binder.py b/clang/bindings/python/clang/binder.py new file mode 100644 index 0..8cc661a097cb2 --- /dev/null +++ b/clang/bindings/python/clang/binder.py @@ -0,0 +1,804 @@ +# pyright: reportPrivateUsage=false + +# Enable delayed evaluation of function annotations. +from __future__ import annotations + +import os +from ctypes import cdll +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union + +from typing_extensions import Annotated + +from .ctyped import * +from .ctyped import (ANNO_PARAMETER, ANNO_RESULT, ANNO_RESULT_CONVERTER, + generate_metadata) + +if TYPE_CHECKING: +from ctypes import CDLL +from types import EllipsisType + +from .cindex import (CCRStructure, CodeCompletionResults, + CompilationDatabase, CompileCommands, Cursor, + CursorKind, Diagnostic, File, FileInclusion, Index, + Rewriter, SourceLocation, SourceRange, StrPath, + TemplateArgumentKind, Token, TranslationUnit) +from .cindex import Type as ASTType +from .cindex import _CXString, _CXUnsavedFile +else: +EllipsisType = type(Ellipsis) + + +# delayed imports, a list of import name and their alias +# if alias is same as name, use `...` +CINDEX_DELAYED_IMPORTS: List[Tuple[str, Union[str, EllipsisType]]] = [ +('CCRStructure', ...), +('CodeCompletionResults', ...), +('CompilationDatabase', ...), +('CompileCommands', ...), +('Cursor', ...), +('CursorKind', ...), +('Diagnostic', ...), +('File', ...), +('FileInclusion', ...), +('Index', ...), +('Rewriter', ...), +('SourceLocation', ...), +('SourceRange', ...), +('TemplateArgumentKind', ...), +('Token', ...), +('TranslationUnit', ...), +('Type', 'ASTType'), +('_CXString', ...), +('_CXUnsavedFile', ...), +('c_interop_string', ...), +] + +def load_cindex_types() -> None: +cindex_imports: Dict[str, Any] = {} +from . import cindex +for name, alias in CINDEX_DELAYED_IMPORTS: +if isinstance(alias, EllipsisType): alias = name +cindex_imports[alias] = getattr(cindex, name) +globals().update(cindex_imports) + + +# ctypes doesn't implicitly convert c_void_p to the appropriate wrapper +# object. This is a problem, because it means that from_parameter will see an +# integer and pass the wrong value on platforms where int != void*. Work around +# this by marshalling object arguments as void**. +CObjectP = CPointer[c_void_p] +c_object_p: Type[CObjectP] = convert_annotation(CObjectP) + + +# Register callback types +TranslationUnitIncludesCallback = Annotated[CFuncPointer, None, c_object_p, CPointer['SourceLocation'], c_uint, py_object] +CursorVisitCallback = Annotated[CFuncPointer, c_int, 'Cursor', 'Cursor', py_object] +FieldsVisitCallback = Annotated[CFuncPointer, c_int, 'Cursor', py_object] + +# TODO: these lines should replace the definition in cindex.py +#translation_unit_includes_callback: Type[CFuncPointer] = convert_annotation(TranslationUnitIncludesCallback, globals()) +#cursor_visit_callback: Type[CFuncPointer] = convert_annotation(CursorVisitCallback, globals()) +#fields_visit_callback: Type[CFuncPointer] = convert_annotation(FieldsVisitCallback, globals()) + + +# Misc object param/result types +# A type may only have param type or result type, this is normal. +ASTTypeResult = Annotated['ASTType', ANNO_RESULT, 'ASTType', 'ASTType.from_result'] + +CInteropStri
[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)
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/101941 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)
cor3ntin wrote: I might be stupid but i still do not get why fold expressions are special, they should not be. Can you add tests for ```cpp void f(auto...); template void foo() { []() { f([]() requires (!C) {}()...); }.template operator()(); } ``` other interesting expansions might be ```cpp f<[]() requires (!C) {}()...>(); // f({+[]() requires (!C) {}()}); // [ ...fs = +[]() requires (!C) {}()]() { (fs(),...); } } https://github.com/llvm/llvm-project/pull/86265 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 98e4413a38f286147b863a6ead9625228ab0ec7d...3e12ffd4afa52126e5fd162d62f832626bfb8578 clang/bindings/python/clang/binder.py clang/bindings/python/clang/ctyped.py clang/bindings/python/tests/ctyped/__init__.py clang/bindings/python/tests/ctyped/test_stub_conversion.py `` View the diff from darker here. ``diff --- clang/binder.py 2024-08-05 08:20:40.00 + +++ clang/binder.py 2024-08-05 08:55:22.365631 + @@ -8,58 +8,79 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union from typing_extensions import Annotated from .ctyped import * -from .ctyped import (ANNO_PARAMETER, ANNO_RESULT, ANNO_RESULT_CONVERTER, - generate_metadata) +from .ctyped import ( +ANNO_PARAMETER, +ANNO_RESULT, +ANNO_RESULT_CONVERTER, +generate_metadata, +) if TYPE_CHECKING: from ctypes import CDLL from types import EllipsisType -from .cindex import (CCRStructure, CodeCompletionResults, - CompilationDatabase, CompileCommands, Cursor, - CursorKind, Diagnostic, File, FileInclusion, Index, - Rewriter, SourceLocation, SourceRange, StrPath, - TemplateArgumentKind, Token, TranslationUnit) +from .cindex import ( +CCRStructure, +CodeCompletionResults, +CompilationDatabase, +CompileCommands, +Cursor, +CursorKind, +Diagnostic, +File, +FileInclusion, +Index, +Rewriter, +SourceLocation, +SourceRange, +StrPath, +TemplateArgumentKind, +Token, +TranslationUnit, +) from .cindex import Type as ASTType from .cindex import _CXString, _CXUnsavedFile else: EllipsisType = type(Ellipsis) # delayed imports, a list of import name and their alias # if alias is same as name, use `...` CINDEX_DELAYED_IMPORTS: List[Tuple[str, Union[str, EllipsisType]]] = [ -('CCRStructure', ...), -('CodeCompletionResults', ...), -('CompilationDatabase', ...), -('CompileCommands', ...), -('Cursor', ...), -('CursorKind', ...), -('Diagnostic', ...), -('File', ...), -('FileInclusion', ...), -('Index', ...), -('Rewriter', ...), -('SourceLocation', ...), -('SourceRange', ...), -('TemplateArgumentKind', ...), -('Token', ...), -('TranslationUnit', ...), -('Type', 'ASTType'), -('_CXString', ...), -('_CXUnsavedFile', ...), -('c_interop_string', ...), +("CCRStructure", ...), +("CodeCompletionResults", ...), +("CompilationDatabase", ...), +("CompileCommands", ...), +("Cursor", ...), +("CursorKind", ...), +("Diagnostic", ...), +("File", ...), +("FileInclusion", ...), +("Index", ...), +("Rewriter", ...), +("SourceLocation", ...), +("SourceRange", ...), +("TemplateArgumentKind", ...), +("Token", ...), +("TranslationUnit", ...), +("Type", "ASTType"), +("_CXString", ...), +("_CXUnsavedFile", ...), +("c_interop_string", ...), ] + def load_cindex_types() -> None: cindex_imports: Dict[str, Any] = {} from . import cindex + for name, alias in CINDEX_DELAYED_IMPORTS: -if isinstance(alias, EllipsisType): alias = name +if isinstance(alias, EllipsisType): +alias = name cindex_imports[alias] = getattr(cindex, name) globals().update(cindex_imports) # ctypes doesn't implicitly convert c_void_p to the appropriate wrapper @@ -69,79 +90,111 @@ CObjectP = CPointer[c_void_p] c_object_p: Type[CObjectP] = convert_annotation(CObjectP) # Register callback types -TranslationUnitIncludesCallback = Annotated[CFuncPointer, None, c_object_p, CPointer['SourceLocation'], c_uint, py_object] -CursorVisitCallback = Annotated[CFuncPointer, c_int, 'Cursor', 'Cursor', py_object] -FieldsVisitCallback = Annotated[CFuncPointer, c_int, 'Cursor', py_object] +TranslationUnitIncludesCallback = Annotated[ +CFuncPointer, None, c_object_p, CPointer["SourceLocation"], c_uint, py_object +] +CursorVisitCallback = Annotated[CFuncPointer, c_int, "Cursor", "Cursor", py_object] +FieldsVisitCallback = Annotated[CFuncPointer, c_int, "Cursor", py_object] # TODO: these lines should replace the definition in cindex.py -#translation_unit_includes_callback: Type[CFuncPointer] = convert_annotation(TranslationUnitIncludesCallback, globals()) -#cursor_visit_callback: Type[CFuncPointer] = convert_annotation(CursorVisitCallback, globals()) -#fields_visit_callback: Type[CFuncPointer] = convert_annotation(FieldsVisitCallback, globals()) +# translation_unit_includes_callback: Type[CFuncPointer] = convert_annotation(TranslationUnit
[clang] #101784 part 1: introduce ctyped in an independent manner (PR #101941)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (TsXor) Changes This is part 1 as described in #101784. I moved `LibclangExports`, `LibclangError` and modified `Config` class to a new file: `binder.py`. It can now be used by `cindex.py` with a simple `from .binder import Config`. This PR doesn't modify any existing files, so it is safe to merge. However, @DeinAlptraum will need to manually delete `functionList`, `Config` class and `LibclangError` and add `from .binder import Config` to utilize its typing benefits. Note: compared to #101784, I added a check that prevents `ctyped` from importing `WINFUNCTYPE` when not on windows, which should fix failing linux tests. --- Patch is 63.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/101941.diff 4 Files Affected: - (added) clang/bindings/python/clang/binder.py (+804) - (added) clang/bindings/python/clang/ctyped.py (+433) - (added) clang/bindings/python/tests/ctyped/__init__.py () - (added) clang/bindings/python/tests/ctyped/test_stub_conversion.py (+357) ``diff diff --git a/clang/bindings/python/clang/binder.py b/clang/bindings/python/clang/binder.py new file mode 100644 index 0..8cc661a097cb2 --- /dev/null +++ b/clang/bindings/python/clang/binder.py @@ -0,0 +1,804 @@ +# pyright: reportPrivateUsage=false + +# Enable delayed evaluation of function annotations. +from __future__ import annotations + +import os +from ctypes import cdll +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union + +from typing_extensions import Annotated + +from .ctyped import * +from .ctyped import (ANNO_PARAMETER, ANNO_RESULT, ANNO_RESULT_CONVERTER, + generate_metadata) + +if TYPE_CHECKING: +from ctypes import CDLL +from types import EllipsisType + +from .cindex import (CCRStructure, CodeCompletionResults, + CompilationDatabase, CompileCommands, Cursor, + CursorKind, Diagnostic, File, FileInclusion, Index, + Rewriter, SourceLocation, SourceRange, StrPath, + TemplateArgumentKind, Token, TranslationUnit) +from .cindex import Type as ASTType +from .cindex import _CXString, _CXUnsavedFile +else: +EllipsisType = type(Ellipsis) + + +# delayed imports, a list of import name and their alias +# if alias is same as name, use `...` +CINDEX_DELAYED_IMPORTS: List[Tuple[str, Union[str, EllipsisType]]] = [ +('CCRStructure', ...), +('CodeCompletionResults', ...), +('CompilationDatabase', ...), +('CompileCommands', ...), +('Cursor', ...), +('CursorKind', ...), +('Diagnostic', ...), +('File', ...), +('FileInclusion', ...), +('Index', ...), +('Rewriter', ...), +('SourceLocation', ...), +('SourceRange', ...), +('TemplateArgumentKind', ...), +('Token', ...), +('TranslationUnit', ...), +('Type', 'ASTType'), +('_CXString', ...), +('_CXUnsavedFile', ...), +('c_interop_string', ...), +] + +def load_cindex_types() -> None: +cindex_imports: Dict[str, Any] = {} +from . import cindex +for name, alias in CINDEX_DELAYED_IMPORTS: +if isinstance(alias, EllipsisType): alias = name +cindex_imports[alias] = getattr(cindex, name) +globals().update(cindex_imports) + + +# ctypes doesn't implicitly convert c_void_p to the appropriate wrapper +# object. This is a problem, because it means that from_parameter will see an +# integer and pass the wrong value on platforms where int != void*. Work around +# this by marshalling object arguments as void**. +CObjectP = CPointer[c_void_p] +c_object_p: Type[CObjectP] = convert_annotation(CObjectP) + + +# Register callback types +TranslationUnitIncludesCallback = Annotated[CFuncPointer, None, c_object_p, CPointer['SourceLocation'], c_uint, py_object] +CursorVisitCallback = Annotated[CFuncPointer, c_int, 'Cursor', 'Cursor', py_object] +FieldsVisitCallback = Annotated[CFuncPointer, c_int, 'Cursor', py_object] + +# TODO: these lines should replace the definition in cindex.py +#translation_unit_includes_callback: Type[CFuncPointer] = convert_annotation(TranslationUnitIncludesCallback, globals()) +#cursor_visit_callback: Type[CFuncPointer] = convert_annotation(CursorVisitCallback, globals()) +#fields_visit_callback: Type[CFuncPointer] = convert_annotation(FieldsVisitCallback, globals()) + + +# Misc object param/result types +# A type may only have param type or result type, this is normal. +ASTTypeResult = Annotated['ASTType', ANNO_RESULT, 'ASTType', 'ASTType.from_result'] + +CInteropStringParam = Annotated[Union[str, bytes, None], ANNO_PARAMETER, 'c_interop_string'] +CInteropStringResult = Annotated[Optional[str], ANNO_RESULT, 'c_interop_string', 'c_interop_string.to_python_string'] + +CXStringResult = Annotated[str, ANNO_RESULT, '_CXString', '_CXString.from_result'] + +CompilationDatabaseParam = Annotated['C
[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)
@@ -2,7 +2,7 @@ ; PR933 JonPsson1 wrote: Handling of these tests here: https://github.com/llvm/llvm-project/pull/101944. https://github.com/llvm/llvm-project/pull/100757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1fec981 - [C++20] [Modules] Skip ODR checks in implicit global modules
Author: Chuanqi Xu Date: 2024-08-05T17:01:24+08:00 New Revision: 1fec981b67ac57abd4d8defd73beb5a9433c602f URL: https://github.com/llvm/llvm-project/commit/1fec981b67ac57abd4d8defd73beb5a9433c602f DIFF: https://github.com/llvm/llvm-project/commit/1fec981b67ac57abd4d8defd73beb5a9433c602f.diff LOG: [C++20] [Modules] Skip ODR checks in implicit global modules Previously we skipped the ODR checks in explicit global modules. And due to similar reasons, we should skip the ODR checks in implicit global modules too. Added: Modified: clang/include/clang/AST/DeclBase.h clang/include/clang/Serialization/ASTReader.h clang/lib/AST/DeclBase.cpp clang/test/Modules/skip-odr-check-in-gmf.cppm Removed: diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 40f01abf384e9..58f0aaba93b71 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -673,6 +673,9 @@ class alignas(8) Decl { /// Whether this declaration comes from explicit global module. bool isFromExplicitGlobalModule() const; + /// Whether this declaration comes from global module. + bool isFromGlobalModule() const; + /// Whether this declaration comes from a named module. bool isInNamedModule() const; diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 76e51ac7ab979..1ae1bf8ec7957 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -2478,7 +2478,7 @@ class BitsUnpacker { inline bool shouldSkipCheckingODR(const Decl *D) { return D->getASTContext().getLangOpts().SkipODRCheckInGMF && - D->isFromExplicitGlobalModule(); + D->isFromGlobalModule(); } } // namespace clang diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index a1f70546bde42..98a7746b7d997 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1144,6 +1144,10 @@ bool Decl::isFromExplicitGlobalModule() const { return getOwningModule() && getOwningModule()->isExplicitGlobalModule(); } +bool Decl::isFromGlobalModule() const { + return getOwningModule() && getOwningModule()->isGlobalModule(); +} + bool Decl::isInNamedModule() const { return getOwningModule() && getOwningModule()->isNamedModule(); } diff --git a/clang/test/Modules/skip-odr-check-in-gmf.cppm b/clang/test/Modules/skip-odr-check-in-gmf.cppm index 3ee7d09224bfa..4a6003287a39a 100644 --- a/clang/test/Modules/skip-odr-check-in-gmf.cppm +++ b/clang/test/Modules/skip-odr-check-in-gmf.cppm @@ -35,17 +35,21 @@ module; export module a; export using ::func; +export extern "C++" bool func1() { return true; } + //--- b.cppm module; #include "func2.h" export module b; export using ::func; +export extern "C++" bool func1() { return false; } + //--- test.cc import a; import b; bool test() { -return func(1, 2); +return func(1, 2) && func1(); } #ifdef IGNORE_ODR_VIOLATION @@ -53,4 +57,6 @@ bool test() { #else // expected-error@func2.h:1 {{'func' has diff erent definitions in diff erent modules;}} // expected-note@func1.h:1 {{but in 'a.' found a diff erent body}} +// expected-er...@b.cppm:6 {{'func1' has diff erent definitions in diff erent modules; definition in module 'b.' first diff erence is function body}} +// expected-n...@a.cppm:6 {{but in 'a.' found a diff erent body}} #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Handle Pointer::toAPValue() for expr bases (PR #101937)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/101937 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 72fb188 - [clang][Interp] Handle Pointer::toAPValue() for expr bases (#101937)
Author: Timm Baeder Date: 2024-08-05T11:10:56+02:00 New Revision: 72fb1889424fc371ef7d630009e4e579d18b9247 URL: https://github.com/llvm/llvm-project/commit/72fb1889424fc371ef7d630009e4e579d18b9247 DIFF: https://github.com/llvm/llvm-project/commit/72fb1889424fc371ef7d630009e4e579d18b9247.diff LOG: [clang][Interp] Handle Pointer::toAPValue() for expr bases (#101937) No reason to return early for them anymore. Added: Modified: clang/lib/AST/Interp/Pointer.cpp clang/test/AST/Interp/codegen.cpp clang/test/AST/Interp/new-delete.cpp Removed: diff --git a/clang/lib/AST/Interp/Pointer.cpp b/clang/lib/AST/Interp/Pointer.cpp index f86be1214826d..2b1f8b460510c 100644 --- a/clang/lib/AST/Interp/Pointer.cpp +++ b/clang/lib/AST/Interp/Pointer.cpp @@ -16,6 +16,7 @@ #include "MemberPointer.h" #include "PrimType.h" #include "Record.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/RecordLayout.h" using namespace clang; @@ -155,12 +156,32 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { APValue::LValueBase Base; if (const auto *VD = Desc->asValueDecl()) Base = VD; - else if (const auto *E = Desc->asExpr()) -Base = E; - else + else if (const auto *E = Desc->asExpr()) { +// Create a DynamicAlloc base of the right type. +if (const auto *NewExpr = dyn_cast(E)) { + QualType AllocatedType; + if (NewExpr->isArray()) { +assert(Desc->isArray()); +APInt ArraySize(64, static_cast(Desc->getNumElems()), +/*IsSigned=*/false); +AllocatedType = +ASTCtx.getConstantArrayType(NewExpr->getAllocatedType(), ArraySize, +nullptr, ArraySizeModifier::Normal, 0); + } else { +AllocatedType = NewExpr->getAllocatedType(); + } + // FIXME: Suboptimal counting of dynamic allocations. Move this to Context + // or InterpState? + static int ReportedDynamicAllocs = 0; + DynamicAllocLValue DA(ReportedDynamicAllocs++); + Base = APValue::LValueBase::getDynamicAlloc(DA, AllocatedType); +} else { + Base = E; +} + } else llvm_unreachable("Invalid allocation type"); - if (isUnknownSizeArray() || Desc->asExpr()) + if (isUnknownSizeArray()) return APValue(Base, CharUnits::Zero(), Path, /*IsOnePastEnd=*/isOnePastEnd(), /*IsNullPtr=*/false); diff --git a/clang/test/AST/Interp/codegen.cpp b/clang/test/AST/Interp/codegen.cpp index f1f0a33673a5b..42d98a079e120 100644 --- a/clang/test/AST/Interp/codegen.cpp +++ b/clang/test/AST/Interp/codegen.cpp @@ -32,6 +32,16 @@ namespace BaseClassOffsets { B* b = &c; } +namespace ExprBase { + struct A { int n; }; + struct B { int n; }; + struct C : A, B {}; + + extern const int &&t = ((B&&)C{}).n; + // CHECK: @_ZGRN8ExprBase1tE_ = internal global {{.*}} zeroinitializer, + // CHECK: @_ZN8ExprBase1tE = constant ptr {{.*}} @_ZGRN8ExprBase1tE_, {{.*}} 8 +} + namespace reinterpretcast { const unsigned int n = 1234; extern const int &s = reinterpret_cast(n); diff --git a/clang/test/AST/Interp/new-delete.cpp b/clang/test/AST/Interp/new-delete.cpp index ddf91005c61d9..325ce27c6d51d 100644 --- a/clang/test/AST/Interp/new-delete.cpp +++ b/clang/test/AST/Interp/new-delete.cpp @@ -358,7 +358,7 @@ namespace delete_random_things { // both-note {{delete of pointer to subobject }} static_assert((delete (new int + 1), true)); // both-error {{}} \ // ref-note {{delete of pointer '&{*new int#0} + 1' that does not point to complete object}} \ - // expected-note {{delete of pointer '&new int + 1' that does not point to complete object}} + // expected-note {{delete of pointer '&{*new int#1} + 1' that does not point to complete object}} static_assert((delete[] (new int[3] + 1), true)); // both-error {{}} \ // both-note {{delete of pointer to subobject}} static_assert((delete &(int&)(int&&)0, true)); // both-error {{}} \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 710590e - [libunwind] Undefined behaviour pointer arithmetic with null pointer (#98648)
Author: Daniel Kiss Date: 2024-08-05T11:16:51+02:00 New Revision: 710590e33d19649f08c716d827eb465e3a132d23 URL: https://github.com/llvm/llvm-project/commit/710590e33d19649f08c716d827eb465e3a132d23 DIFF: https://github.com/llvm/llvm-project/commit/710590e33d19649f08c716d827eb465e3a132d23.diff LOG: [libunwind] Undefined behaviour pointer arithmetic with null pointer (#98648) Fixes #91144 Added: Modified: libunwind/src/UnwindCursor.hpp Removed: diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 06e654197351d..ce6dced535e78 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -230,8 +230,8 @@ void DwarfFDECache::iterateCacheEntries(void (*func)( } #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) - -#define arrayoffsetof(type, index, field) ((size_t)(&((type *)0)[index].field)) +#define arrayoffsetof(type, index, field) \ + (sizeof(type) * (index) + offsetof(type, field)) #if defined(_LIBUNWIND_SUPPORT_COMPACT_UNWIND) template class UnwindSectionHeader { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Undefined behaviour pointer arithmetic with null pointer (PR #98648)
https://github.com/DanielKristofKiss closed https://github.com/llvm/llvm-project/pull/98648 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
https://github.com/Sirraide requested changes to this pull request. This needs some cleanup I think, but it’s going in the right direction. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -3292,11 +3292,9 @@ bool FunctionDecl::isImmediateFunction() const { } bool FunctionDecl::isMain() const { - const TranslationUnitDecl *tunit = -dyn_cast(getDeclContext()->getRedeclContext()); - return tunit && - !tunit->getASTContext().getLangOpts().Freestanding && - isNamed(this, "main"); + const DeclContext *DC = getDeclContext(); + return isNamed(this, "main") && !getLangOpts().Freestanding && + (DC->getRedeclContext()->isTranslationUnit() || DC->isLinkageSpec()); Sirraide wrote: ```suggestion (DC->getRedeclContext()->isTranslationUnit() || isExternC()); ``` I think this should do the trick. Also please add a test for ```c++ namespace foo { extern "C++" void main() {} } ``` which is horrible, but valid. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -145,6 +145,8 @@ Improvements to Clang's diagnostics - -Wdangling-assignment-gsl is enabled by default. +- Clang now diagnoses the use of `main` in `extern` context as invalid according to [basic.start.main] p2. Fixes #GH101512. Sirraide wrote: ```suggestion - Clang now diagnoses the use of `main` in an `extern "C"` context as invalid according to [basic.start.main] p2. Fixes #GH101512. ``` https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s + Sirraide wrote: I think this was already pointed out, but some tests w/ `extern "C++"` would be nice, as well as tests for when a namespace is contained in a linkage-spec-decl. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -8052,15 +8061,13 @@ NamedDecl *Sema::ActOnVariableDeclarator( } // Special handling of variable named 'main'. - if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo()->isStr("main") && - NewVD->getDeclContext()->getRedeclContext()->isTranslationUnit() && - !getLangOpts().Freestanding && !NewVD->getDescribedVarTemplate()) { - + if (isMainVar(Name, NewVD) && !getLangOpts().Freestanding) { // C++ [basic.start.main]p3 // A program that declares a variable main at global scope is ill-formed. -if (getLangOpts().CPlusPlus) - Diag(D.getBeginLoc(), diag::err_main_global_variable); - +if (getLangOpts().CPlusPlus) { + if (!CheckLinkageSpecification(DC, NewVD)) Sirraide wrote: ```suggestion ``` This shouldn’t be here. Unlike with functions, it doesn’t matter whether the variable is `extern "C"` or not: a variable at the global scope that is named `main` is invalid regardless. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -3292,11 +3292,9 @@ bool FunctionDecl::isImmediateFunction() const { } bool FunctionDecl::isMain() const { - const TranslationUnitDecl *tunit = -dyn_cast(getDeclContext()->getRedeclContext()); - return tunit && - !tunit->getASTContext().getLangOpts().Freestanding && - isNamed(this, "main"); + const DeclContext *DC = getDeclContext(); + return isNamed(this, "main") && !getLangOpts().Freestanding && Sirraide wrote: I don’t see how they couldn’t be the same seeing as `Decl`’s `getLangOpts()` just gets them from the `ASTContext` either way. I think this change is fine. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -7353,6 +7353,15 @@ void emitReadOnlyPlacementAttrWarning(Sema &S, const VarDecl *VD) { } } +static bool isMainVar(DeclarationName Name, VarDecl *VD) { + if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo()->isStr("main") && + !VD->getDescribedVarTemplate()) { +const DeclContext *DC = VD->getDeclContext(); +return DC->getRedeclContext()->isTranslationUnit() || DC->isLinkageSpec(); Sirraide wrote: Just `VD->isExternC()` instead of `VD->getLanguageLinkage() == CLanguageLinkage` should be enough. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -990,6 +990,8 @@ def warn_main_redefined : Warning<"variable named 'main' with external linkage " "has undefined behavior">, InGroup; def ext_main_used : Extension< "referring to 'main' within an expression is a Clang extension">, InGroup; +def err_main_invalid_linkage_specification : ExtWarn< + "'main' cannot have linkage specification 'extern \"C\"'">, InGroup; Sirraide wrote: ```suggestion "'main' should not be extern \"C\"">, InGroup; ``` I think something like this would be better imo; I don’t like ‘cannot’ since we still accept the code, so it’s not technically correct that it *cannot* have a linkage specification (it can’t according to the standard, but only EDG currently diagnoses this, and even then it’s just a warning), it just really *shouldn’t*. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -2156,6 +2156,8 @@ class DeclContext { return getDeclKind() == Decl::TranslationUnit; } + bool isLinkageSpec() const { return getDeclKind() == Decl::LinkageSpec; } Sirraide wrote: I don’t think we need this. The place where this is used can just do `isa(D)` or sth like that https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -3585,8 +3585,9 @@ class Sema final : public SemaBase { /// \param OldT The portion of the type of the old declaration to check. bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, QualType NewT, QualType OldT); - void CheckMain(FunctionDecl *FD, const DeclSpec &D); + void CheckMain(FunctionDecl *FD, DeclContext *DC, const DeclSpec &D); Sirraide wrote: You can get the decl context from the function decl, so I don’t think this change is necessary. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s + Sirraide wrote: Also add a test for this (at the top level w/o any linkage-spec-decl) if we don’t already have one: ``` int main; ``` which is also invalid; probably in a separate file so it doesn’t complain about redeclarations https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -12370,6 +12379,17 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { } } +bool Sema::CheckLinkageSpecification(DeclContext *DC, Decl *D) { + // [basic.start.main] p2 + // The main function shall not be declared with a linkage-specification. + if (DC->isExternCContext()) { +Diag(D->getLocation(), diag::err_main_invalid_linkage_specification); +D->setInvalidDecl(); +return true; + } + return false; +} Sirraide wrote: Currently, it’s only used in one place (the use where we check variable declarations should not be there I think), so I’d just inline it. https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
@@ -8052,15 +8061,13 @@ NamedDecl *Sema::ActOnVariableDeclarator( } // Special handling of variable named 'main'. - if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo()->isStr("main") && - NewVD->getDeclContext()->getRedeclContext()->isTranslationUnit() && - !getLangOpts().Freestanding && !NewVD->getDescribedVarTemplate()) { - + if (isMainVar(Name, NewVD) && !getLangOpts().Freestanding) { // C++ [basic.start.main]p3 // A program that declares a variable main at global scope is ill-formed. -if (getLangOpts().CPlusPlus) - Diag(D.getBeginLoc(), diag::err_main_global_variable); - +if (getLangOpts().CPlusPlus) { + if (!CheckLinkageSpecification(DC, NewVD)) Sirraide wrote: [[basic.start.main]p1](https://eel.is/c++draft/basic.start.main#3.1): > a variable `main` that belongs to the global scope, or https://github.com/llvm/llvm-project/pull/101853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)
nikic wrote: Could you please post an RFC on discourse for this (or link it if it already exists)? https://github.com/llvm/llvm-project/pull/100757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)
@@ -2,7 +2,7 @@ ; PR933 JonPsson1 wrote: (committed now) https://github.com/llvm/llvm-project/pull/100757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer][NFC] Eliminate a dyn_cast (PR #100719)
https://github.com/Szelethus updated https://github.com/llvm/llvm-project/pull/100719 From d176b03b211144dadaa1efb4b7da959110d7725c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Umann?= Date: Fri, 26 Jul 2024 11:01:41 +0200 Subject: [PATCH 1/2] [analyzer][NFC] Eliminate a dyn_cast --- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 5 ++--- clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.h | 2 +- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index fe202c79ed620..39e5c7c014a2a 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -796,14 +796,13 @@ class NoMemOwnershipChangeVisitor final : public NoOwnershipChangeVisitor { /// done syntactically, because we are trying to argue about alternative /// paths of execution, and as a consequence we don't have path-sensitive /// information. - bool doesFnIntendToHandleOwnership(const Decl *Callee, + bool doesFnIntendToHandleOwnership(const FunctionDecl *Callee, ASTContext &ACtx) final { using namespace clang::ast_matchers; -const FunctionDecl *FD = dyn_cast(Callee); auto Matches = match(findAll(stmt(anyOf(cxxDeleteExpr().bind("delete"), callExpr().bind("call", - *FD->getBody(), ACtx); + Callee->getBody(), ACtx); for (BoundNodes Match : Matches) { if (Match.getNodeAs("delete")) return true; diff --git a/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.h b/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.h index 027f1a156a7c0..7be74860d863b 100644 --- a/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.h +++ b/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.h @@ -26,7 +26,7 @@ class NoOwnershipChangeVisitor : public NoStateChangeFuncVisitor { /// is done syntactically, because we are trying to argue about alternative /// paths of execution, and as a consequence we don't have path-sensitive /// information. - virtual bool doesFnIntendToHandleOwnership(const Decl *Callee, + virtual bool doesFnIntendToHandleOwnership(const FunctionDecl *Callee, ASTContext &ACtx) = 0; virtual bool hasResourceStateChanged(ProgramStateRef CallEnterState, diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp index 9aee7f952ad2d..41187ee9b5cdf 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -746,13 +746,12 @@ class NoStreamStateChangeVisitor final : public NoOwnershipChangeVisitor { return StreamChk->FCloseDesc.matchesAsWritten(Call); } - bool doesFnIntendToHandleOwnership(const Decl *Callee, + bool doesFnIntendToHandleOwnership(const FunctionDecl *Callee, ASTContext &ACtx) final { using namespace clang::ast_matchers; -const FunctionDecl *FD = dyn_cast(Callee); auto Matches = -match(findAll(callExpr().bind("call")), *FD->getBody(), ACtx); +match(findAll(callExpr().bind("call")), Callee->getBody(), ACtx); for (BoundNodes Match : Matches) { if (const auto *Call = Match.getNodeAs("call")) if (isClosingCallAsWritten(*Call)) From f96c21c018029bd314fefdbca7ea868490cb6992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Umann?= Date: Mon, 5 Aug 2024 12:08:11 +0200 Subject: [PATCH 2/2] Make users responsible for parsing Callee instead --- .../lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 14 -- .../Checkers/NoOwnershipChangeVisitor.cpp | 10 -- .../Checkers/NoOwnershipChangeVisitor.h| 2 +- .../lib/StaticAnalyzer/Checkers/StreamChecker.cpp | 14 -- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 39e5c7c014a2a..3a13b45d9c440 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -796,13 +796,23 @@ class NoMemOwnershipChangeVisitor final : public NoOwnershipChangeVisitor { /// done syntactically, because we are trying to argue about alternative /// paths of execution, and as a consequence we don't have path-sensitive /// information. - bool doesFnIntendToHandleOwnership(const FunctionDecl *Callee, + bool doesFnIntendToHandleOwnership(const Decl *Callee, ASTContext &ACtx) final { +const FunctionDecl *FD = dyn_cast(Callee); + +// Given that the stack
[clang] [Clang] Implement C++26’s P2893R3 ‘Variadic friends’ (PR #101448)
@@ -1442,8 +1442,49 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) { if (D->isUnsupportedFriend()) { InstTy = Ty; } else { - InstTy = SemaRef.SubstType(Ty, TemplateArgs, - D->getLocation(), DeclarationName()); + if (D->isVariadic()) { +SmallVector Unexpanded; +SemaRef.collectUnexpandedParameterPacks(Ty->getTypeLoc(), Unexpanded); +assert(!Unexpanded.empty() && "Pack expansion without packs"); + +bool ShouldExpand = true; +bool RetainExpansion = false; +std::optional NumExpansions; +if (SemaRef.CheckParameterPacksForExpansion( +D->getEllipsisLoc(), D->getSourceRange(), Unexpanded, +TemplateArgs, ShouldExpand, RetainExpansion, NumExpansions)) + return nullptr; + +assert(!RetainExpansion && + "should never retain an expansion for a FriendPackDecl"); + +if (ShouldExpand) { + SmallVector Decls; + for (unsigned I = 0; I != *NumExpansions; I++) { +Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I); +TypeSourceInfo *TSI = SemaRef.SubstType( +Ty, TemplateArgs, D->getEllipsisLoc(), DeclarationName()); +if (!TSI) + return nullptr; + +auto FD = +FriendDecl::Create(SemaRef.Context, Owner, D->getLocation(), + TSI, D->getFriendLoc()); + +FD->setAccess(AS_public); +Owner->addDecl(FD); Sirraide wrote: We don’t do that when we instantiate `FriendDecl`s below, which is why I didn’t add it here. https://github.com/llvm/llvm-project/pull/101448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement C++26’s P2893R3 ‘Variadic friends’ (PR #101448)
Sirraide wrote: > Looks generally good from a cursory review. I think we want to add tests for > modules / in the test/PCH directory. We already have tests for PCHs, but I can add some more for modules. > We probably want that as an extension indeed, no reason not to We allow `friend` type declarations in all language modes, so I’ll do that too. > We probably want a separate PR to add the pack indexing macro. I did not add > it initially because i was concerned the implementation was not mature > enough, but i think we fond most of the bugs. > > I think it's fine to set the feature macro for that now with the assumption > that we will find all the bugs in the next 6 months. I’ll open an NFC pr for that. > There seem to be some missing components, like the json node printer. I always forget about something when I add an AST node... https://github.com/llvm/llvm-project/pull/101448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Define __cpp_pack_indexing (PR #101956)
https://github.com/Sirraide created https://github.com/llvm/llvm-project/pull/101956 Following the discussion on [#101448](https://github.com/llvm/llvm-project/pull/101448#pullrequestreview-2217511926), this defines `__cpp_pack_indexing`. Since pack indexing is currently supported in all language modes, the feature test macro is also defined in all language modes. >From eb93820676ab6c6683a76399910c692d76f86b53 Mon Sep 17 00:00:00 2001 From: Sirraide Date: Mon, 5 Aug 2024 12:29:24 +0200 Subject: [PATCH] [Clang] Define __cpp_pack_indexing --- clang/docs/LanguageExtensions.rst | 1 + clang/lib/Frontend/InitPreprocessor.cpp | 1 + clang/test/Lexer/cxx-features.cpp | 4 3 files changed, 6 insertions(+) diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 9dcb4ac9b75ca..be07f81cc41b0 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -1503,6 +1503,7 @@ Conditional ``explicit`` __cpp_conditional_explicit C+ ``static operator()``__cpp_static_call_operator C++23 C++03 Attributes on Lambda-Expressions C++23 C++11 Attributes on Structured Bindings__cpp_structured_bindings C++26 C++03 +Pack Indexing__cpp_pack_indexing C++26 C++03 ``= delete ("should have a reason");`` __cpp_deleted_function C++26 C++03 - - Designated initializers (N494) C99 C89 diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 17b9ca7cb9910..8e62461d8a181 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -763,6 +763,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_placeholder_variables", "202306L"); // C++26 features supported in earlier language modes. + Builder.defineMacro("__cpp_pack_indexing", "202311L"); Builder.defineMacro("__cpp_deleted_function", "202403L"); if (LangOpts.Char8) diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp index 4c2aa3ae2c544..08b732132228b 100644 --- a/clang/test/Lexer/cxx-features.cpp +++ b/clang/test/Lexer/cxx-features.cpp @@ -38,6 +38,10 @@ #error "wrong value for __cpp_deleted_function" #endif +#if check(pack_indexing, 202311, 202311, 202311, 202311, 202311, 202311, 202311) +#error "wrong value for __cpp_pack_indexing" +#endif + #if check(placeholder_variables, 202306, 202306, 202306, 202306, 202306, 202306, 202306) #error "wrong value for __cpp_placeholder_variables" #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Define __cpp_pack_indexing (PR #101956)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (Sirraide) Changes Following the discussion on [#101448](https://github.com/llvm/llvm-project/pull/101448#pullrequestreview-2217511926), this defines `__cpp_pack_indexing`. Since pack indexing is currently supported in all language modes, the feature test macro is also defined in all language modes. --- Full diff: https://github.com/llvm/llvm-project/pull/101956.diff 3 Files Affected: - (modified) clang/docs/LanguageExtensions.rst (+1) - (modified) clang/lib/Frontend/InitPreprocessor.cpp (+1) - (modified) clang/test/Lexer/cxx-features.cpp (+4) ``diff diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 9dcb4ac9b75ca..be07f81cc41b0 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -1503,6 +1503,7 @@ Conditional ``explicit`` __cpp_conditional_explicit C+ ``static operator()``__cpp_static_call_operator C++23 C++03 Attributes on Lambda-Expressions C++23 C++11 Attributes on Structured Bindings__cpp_structured_bindings C++26 C++03 +Pack Indexing__cpp_pack_indexing C++26 C++03 ``= delete ("should have a reason");`` __cpp_deleted_function C++26 C++03 - - Designated initializers (N494) C99 C89 diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 17b9ca7cb9910..8e62461d8a181 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -763,6 +763,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_placeholder_variables", "202306L"); // C++26 features supported in earlier language modes. + Builder.defineMacro("__cpp_pack_indexing", "202311L"); Builder.defineMacro("__cpp_deleted_function", "202403L"); if (LangOpts.Char8) diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp index 4c2aa3ae2c544..08b732132228b 100644 --- a/clang/test/Lexer/cxx-features.cpp +++ b/clang/test/Lexer/cxx-features.cpp @@ -38,6 +38,10 @@ #error "wrong value for __cpp_deleted_function" #endif +#if check(pack_indexing, 202311, 202311, 202311, 202311, 202311, 202311, 202311) +#error "wrong value for __cpp_pack_indexing" +#endif + #if check(placeholder_variables, 202306, 202306, 202306, 202306, 202306, 202306, 202306) #error "wrong value for __cpp_placeholder_variables" #endif `` https://github.com/llvm/llvm-project/pull/101956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [IncludeCleaner] display overview (PR #93932)
https://github.com/TheHillBright updated https://github.com/llvm/llvm-project/pull/93932 >From e803c635a64ed3c2ad0381e82ca308f63dcf4604 Mon Sep 17 00:00:00 2001 From: TheHillBright <150074496+thehillbri...@users.noreply.github.com> Date: Fri, 31 May 2024 15:00:37 +0800 Subject: [PATCH] IncludeCleaner: display overview --- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 3bc449b0152bb..788ad87b1d4e8 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -279,7 +279,7 @@ int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); auto OptionsParser = - clang::tooling::CommonOptionsParser::create(argc, argv, IncludeCleaner); + clang::tooling::CommonOptionsParser::create(argc, argv, IncludeCleaner, cl::OneOrMore, Overview); if (!OptionsParser) { llvm::errs() << toString(OptionsParser.takeError()); return 1; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver][clang-cl] Support `--precompile` and `-fmodule-*` options in Clang-CL (PR #98761)
sharadhr wrote: @ChuanqiXu9, do make a re-review when you can, thanks! https://github.com/llvm/llvm-project/pull/98761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 77011b0 - [Clang] Fix path-sensitivity in ubsan-bool.m test (NFC)
Author: Nikita Popov Date: 2024-08-05T12:56:33+02:00 New Revision: 77011b00ad5f7f1789e788e85aed1babeb540213 URL: https://github.com/llvm/llvm-project/commit/77011b00ad5f7f1789e788e85aed1babeb540213 DIFF: https://github.com/llvm/llvm-project/commit/77011b00ad5f7f1789e788e85aed1babeb540213.diff LOG: [Clang] Fix path-sensitivity in ubsan-bool.m test (NFC) This test was failing whenever the path contained the string "f1", e.g. as part of a commit hash. Double-fix the issue by both not embedding the path in the IR at all, and making the CHECK-LABELs more specific. Added: Modified: clang/test/CodeGenObjC/ubsan-bool.m Removed: diff --git a/clang/test/CodeGenObjC/ubsan-bool.m b/clang/test/CodeGenObjC/ubsan-bool.m index fa5883c01cf4f..e33e3e0ef4963 100644 --- a/clang/test/CodeGenObjC/ubsan-bool.m +++ b/clang/test/CodeGenObjC/ubsan-bool.m @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -no-enable-noundef-analysis -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - -w | FileCheck %s -check-prefixes=SHARED,OBJC -// RUN: %clang_cc1 -no-enable-noundef-analysis -x objective-c++ -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - -w | FileCheck %s -check-prefixes=SHARED,OBJC -// RUN: %clang_cc1 -no-enable-noundef-analysis -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,C +// RUN: %clang_cc1 -no-enable-noundef-analysis -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool -o - -w < %s | FileCheck %s -check-prefixes=SHARED,OBJC +// RUN: %clang_cc1 -no-enable-noundef-analysis -x objective-c++ -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool -o - -w < %s | FileCheck %s -check-prefixes=SHARED,OBJC +// RUN: %clang_cc1 -no-enable-noundef-analysis -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool -o - < %s | FileCheck %s -check-prefixes=SHARED,C typedef signed char BOOL; -// SHARED-LABEL: f1 +// SHARED-LABEL: define{{.*}}f1 BOOL f1(void) { // OBJC: call void @__ubsan_handle_load_invalid_value // C-NOT: call void @__ubsan_handle_load_invalid_value @@ -17,7 +17,7 @@ BOOL f1(void) { BOOL b1 : 1; }; -// SHARED-LABEL: f2 +// SHARED-LABEL: define{{.*}}f2 BOOL f2(struct S1 *s) { // OBJC: [[LOAD:%.*]] = load i8, ptr {{.*}} // OBJC: [[SHL:%.*]] = shl i8 [[LOAD]], 7 @@ -52,7 +52,7 @@ @implementation I1 // OBJC: call void @__ubsan_handle_load_invalid_value // Also check direct accesses to the ivar. -// OBJC-LABEL: f3 +// OBJC-LABEL: define{{.*}}f3 BOOL f3(I1 *i) { // OBJC: [[LOAD:%.*]] = load i8, ptr {{.*}} // OBJC: [[SHL:%.*]] = shl i8 [[LOAD]], 7 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][AVX10.2] Support AVX10.2 VNNI FP16/INT8/INT16 new instructions (PR #101783)
https://github.com/phoebewang closed https://github.com/llvm/llvm-project/pull/101783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)
JonPsson1 wrote: > Could you please post an RFC on discourse for this (or link it if it already > exists)? Made an attempt here: https://discourse.llvm.org/t/target-abi-improve-call-parameters-extensions-handling/80553. https://github.com/llvm/llvm-project/pull/100757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Map][NFC] improve map chain. (PR #101903)
https://github.com/alexey-bataev approved this pull request. LG https://github.com/llvm/llvm-project/pull/101903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema][OpenMP] Allow `num_teams` to accept multiple expressions (PR #99732)
@@ -13004,13 +13004,34 @@ StmtResult SemaOpenMP::ActOnOpenMPTargetUpdateDirective( Clauses, AStmt); } +// This checks whether num_teams clause only has one expression. alexey-bataev wrote: Use `///` style of comment here https://github.com/llvm/llvm-project/pull/99732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC] Emit a jump table size section (PR #101962)
https://github.com/omern1 created https://github.com/llvm/llvm-project/pull/101962 This patch will make LLVM emit a jump table size section containing tuples of (jump table address, entry count) in object files. This section is useful for tools that need to statically reconstruct the control flow of executables. The name of the new section is .debug_llvm_jump_table_sizes because that makes both llvm-strip and GNU strip remove it. At the moment this is only enabled by default for the PS5 target. >From 14f3cb82f0d7e69261bd7e1317bd66392e9a2c2b Mon Sep 17 00:00:00 2001 From: Nabeel Omer Date: Mon, 5 Aug 2024 11:50:18 +0100 Subject: [PATCH] [MC] Emit a jump table size section This patch will make LLVM emit a jump table size section containing tuples of (jump table address, entry count) in object files. This section is useful for tools that need to statically reconstruct the control flow of executables. The name of the new section is .debug_llvm_jump_table_sizes because that makes both llvm-strip and GNU strip remove it. At the moment this is only enabled by default for the PS5 target. --- clang/lib/Driver/ToolChains/PS4CPU.cpp| 8 ++ clang/test/Driver/ps4-ps5-toolchain.c | 5 + llvm/docs/Extensions.rst | 6 ++ llvm/include/llvm/BinaryFormat/ELF.h | 1 + llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 26 + llvm/lib/MC/MCParser/ELFAsmParser.cpp | 2 + llvm/lib/MC/MCSectionELF.cpp | 2 + llvm/lib/Object/ELF.cpp | 1 + .../CodeGen/X86/jump-table-size-section.ll| 97 +++ 9 files changed, 148 insertions(+) create mode 100644 llvm/test/CodeGen/X86/jump-table-size-section.ll diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index a9e612c44da06..f9a9e995fff8e 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -265,6 +265,8 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(D.getLTOMode() == LTOK_Thin ? "--lto=thin" : "--lto=full"); + AddLTOFlag("-emit-jump-table-sizes-section"); + if (UseJMC) AddLTOFlag("-enable-jmc-instrument"); @@ -483,6 +485,12 @@ void toolchains::PS4PS5Base::addClangTargetOptions( else CC1Args.push_back("-fvisibility-externs-nodllstorageclass=keep"); } + + // Enable jump table sizes section for PS5. + if (getTriple().isPS5()) { +CC1Args.push_back("-mllvm"); +CC1Args.push_back("-emit-jump-table-sizes-section"); + } } // PS4 toolchain. diff --git a/clang/test/Driver/ps4-ps5-toolchain.c b/clang/test/Driver/ps4-ps5-toolchain.c index 444e9df24714b..c9987c2b5758b 100644 --- a/clang/test/Driver/ps4-ps5-toolchain.c +++ b/clang/test/Driver/ps4-ps5-toolchain.c @@ -11,3 +11,8 @@ // RUN: %clang %s -### -target x86_64-sie-ps5 -flto 2>&1 | FileCheck %s --check-prefix=LTO // LTO-NOT: error: // LTO-NOT: unable to pass LLVM bit-code + +// Verify that the jump table sizes section is enabled. +// RUN: %clang %s -target x86_64-sie-ps5 -### 2>&1 | FileCheck -check-prefix=JUMPTABLESIZES %s +// JUMPTABLESIZES: "-mllvm" "-emit-jump-table-sizes-section" +// JUMPTABLESIZES: "-plugin-opt=-emit-jump-table-sizes-section" diff --git a/llvm/docs/Extensions.rst b/llvm/docs/Extensions.rst index 74ca8cb0aa687..0e209f3fe5cc0 100644 --- a/llvm/docs/Extensions.rst +++ b/llvm/docs/Extensions.rst @@ -554,6 +554,12 @@ time. This section is generated when the compiler enables fat LTO. This section has the ``SHF_EXCLUDE`` flag so that it is stripped from the final executable or shared library. +``SHT_LLVM_JT_SIZES`` Section (Jump table addresses and sizes) +^^^ +This section stores pairs of (jump table address, number of entries). +This information is useful for tools that need to statically reconstruct +the control flow of executables. + CodeView-Dependent -- diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h index fb39bb4b10b37..7bec01688783d 100644 --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -1121,6 +1121,7 @@ enum : unsigned { SHT_LLVM_BB_ADDR_MAP = 0x6fff4c0a,// LLVM Basic Block Address Map. SHT_LLVM_OFFLOADING = 0x6fff4c0b, // LLVM device offloading data. SHT_LLVM_LTO = 0x6fff4c0c,// .llvm.lto for fat LTO. + SHT_LLVM_JT_SIZES = 0x6fff4c0d, // LLVM jump tables sizes. // Android's experimental support for SHT_RELR sections. // https://android.googlesource.com/platform/bionic/+/b7feec74547f84559a1467aca02708ff61346d2a/libc/include/elf.h#512 SHT_ANDROID_RELR = 0x6f00, // Relocation entries; only offsets. diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b64fe83959eb1..05624d2728bf
[clang] [llvm] [X86][AVX10.2] Support AVX10.2-SATCVT new instructions. (PR #101599)
@@ -0,0 +1,327 @@ +/*===-- avx10_2_512satcvtintrin.h - AVX10_2_512SATCVT intrinsics ---=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===---=== + */ +#ifndef __IMMINTRIN_H +#error \ +"Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AVX10_2_512SATCVTINTRIN_H +#define __AVX10_2_512SATCVTINTRIN_H + +#define _mm512_ipcvtnebf16_epi8(A) \ RKSimon wrote: Any chance we can get the doxygen comments added to these please? https://github.com/llvm/llvm-project/pull/101599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC] Emit a jump table size section (PR #101962)
llvmbot wrote: @llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-llvm-binary-utilities Author: Nabeel Omer (omern1) Changes This patch will make LLVM emit a jump table size section containing tuples of (jump table address, entry count) in object files. This section is useful for tools that need to statically reconstruct the control flow of executables. The name of the new section is .debug_llvm_jump_table_sizes because that makes both llvm-strip and GNU strip remove it. At the moment this is only enabled by default for the PS5 target. --- Full diff: https://github.com/llvm/llvm-project/pull/101962.diff 9 Files Affected: - (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+8) - (modified) clang/test/Driver/ps4-ps5-toolchain.c (+5) - (modified) llvm/docs/Extensions.rst (+6) - (modified) llvm/include/llvm/BinaryFormat/ELF.h (+1) - (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+26) - (modified) llvm/lib/MC/MCParser/ELFAsmParser.cpp (+2) - (modified) llvm/lib/MC/MCSectionELF.cpp (+2) - (modified) llvm/lib/Object/ELF.cpp (+1) - (added) llvm/test/CodeGen/X86/jump-table-size-section.ll (+97) ``diff diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index a9e612c44da06..f9a9e995fff8e 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -265,6 +265,8 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(D.getLTOMode() == LTOK_Thin ? "--lto=thin" : "--lto=full"); + AddLTOFlag("-emit-jump-table-sizes-section"); + if (UseJMC) AddLTOFlag("-enable-jmc-instrument"); @@ -483,6 +485,12 @@ void toolchains::PS4PS5Base::addClangTargetOptions( else CC1Args.push_back("-fvisibility-externs-nodllstorageclass=keep"); } + + // Enable jump table sizes section for PS5. + if (getTriple().isPS5()) { +CC1Args.push_back("-mllvm"); +CC1Args.push_back("-emit-jump-table-sizes-section"); + } } // PS4 toolchain. diff --git a/clang/test/Driver/ps4-ps5-toolchain.c b/clang/test/Driver/ps4-ps5-toolchain.c index 444e9df24714b..c9987c2b5758b 100644 --- a/clang/test/Driver/ps4-ps5-toolchain.c +++ b/clang/test/Driver/ps4-ps5-toolchain.c @@ -11,3 +11,8 @@ // RUN: %clang %s -### -target x86_64-sie-ps5 -flto 2>&1 | FileCheck %s --check-prefix=LTO // LTO-NOT: error: // LTO-NOT: unable to pass LLVM bit-code + +// Verify that the jump table sizes section is enabled. +// RUN: %clang %s -target x86_64-sie-ps5 -### 2>&1 | FileCheck -check-prefix=JUMPTABLESIZES %s +// JUMPTABLESIZES: "-mllvm" "-emit-jump-table-sizes-section" +// JUMPTABLESIZES: "-plugin-opt=-emit-jump-table-sizes-section" diff --git a/llvm/docs/Extensions.rst b/llvm/docs/Extensions.rst index 74ca8cb0aa687..0e209f3fe5cc0 100644 --- a/llvm/docs/Extensions.rst +++ b/llvm/docs/Extensions.rst @@ -554,6 +554,12 @@ time. This section is generated when the compiler enables fat LTO. This section has the ``SHF_EXCLUDE`` flag so that it is stripped from the final executable or shared library. +``SHT_LLVM_JT_SIZES`` Section (Jump table addresses and sizes) +^^^ +This section stores pairs of (jump table address, number of entries). +This information is useful for tools that need to statically reconstruct +the control flow of executables. + CodeView-Dependent -- diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h index fb39bb4b10b37..7bec01688783d 100644 --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -1121,6 +1121,7 @@ enum : unsigned { SHT_LLVM_BB_ADDR_MAP = 0x6fff4c0a,// LLVM Basic Block Address Map. SHT_LLVM_OFFLOADING = 0x6fff4c0b, // LLVM device offloading data. SHT_LLVM_LTO = 0x6fff4c0c,// .llvm.lto for fat LTO. + SHT_LLVM_JT_SIZES = 0x6fff4c0d, // LLVM jump tables sizes. // Android's experimental support for SHT_RELR sections. // https://android.googlesource.com/platform/bionic/+/b7feec74547f84559a1467aca02708ff61346d2a/libc/include/elf.h#512 SHT_ANDROID_RELR = 0x6f00, // Relocation entries; only offsets. diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b64fe83959eb1..05624d2728bfd 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -107,6 +107,7 @@ #include "llvm/Pass.h" #include "llvm/Remarks/RemarkStreamer.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -155,6 +156,11 @@ static cl::bits PgoAnalysisMapFeatures( "Enable extended information within the SHT_LLVM_BB_ADDR_MAP that is " "extracted from PGO related analysis."
[clang] [llvm] [MC] Emit a jump table size section (PR #101962)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Nabeel Omer (omern1) Changes This patch will make LLVM emit a jump table size section containing tuples of (jump table address, entry count) in object files. This section is useful for tools that need to statically reconstruct the control flow of executables. The name of the new section is .debug_llvm_jump_table_sizes because that makes both llvm-strip and GNU strip remove it. At the moment this is only enabled by default for the PS5 target. --- Full diff: https://github.com/llvm/llvm-project/pull/101962.diff 9 Files Affected: - (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+8) - (modified) clang/test/Driver/ps4-ps5-toolchain.c (+5) - (modified) llvm/docs/Extensions.rst (+6) - (modified) llvm/include/llvm/BinaryFormat/ELF.h (+1) - (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+26) - (modified) llvm/lib/MC/MCParser/ELFAsmParser.cpp (+2) - (modified) llvm/lib/MC/MCSectionELF.cpp (+2) - (modified) llvm/lib/Object/ELF.cpp (+1) - (added) llvm/test/CodeGen/X86/jump-table-size-section.ll (+97) ``diff diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index a9e612c44da06..f9a9e995fff8e 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -265,6 +265,8 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(D.getLTOMode() == LTOK_Thin ? "--lto=thin" : "--lto=full"); + AddLTOFlag("-emit-jump-table-sizes-section"); + if (UseJMC) AddLTOFlag("-enable-jmc-instrument"); @@ -483,6 +485,12 @@ void toolchains::PS4PS5Base::addClangTargetOptions( else CC1Args.push_back("-fvisibility-externs-nodllstorageclass=keep"); } + + // Enable jump table sizes section for PS5. + if (getTriple().isPS5()) { +CC1Args.push_back("-mllvm"); +CC1Args.push_back("-emit-jump-table-sizes-section"); + } } // PS4 toolchain. diff --git a/clang/test/Driver/ps4-ps5-toolchain.c b/clang/test/Driver/ps4-ps5-toolchain.c index 444e9df24714b..c9987c2b5758b 100644 --- a/clang/test/Driver/ps4-ps5-toolchain.c +++ b/clang/test/Driver/ps4-ps5-toolchain.c @@ -11,3 +11,8 @@ // RUN: %clang %s -### -target x86_64-sie-ps5 -flto 2>&1 | FileCheck %s --check-prefix=LTO // LTO-NOT: error: // LTO-NOT: unable to pass LLVM bit-code + +// Verify that the jump table sizes section is enabled. +// RUN: %clang %s -target x86_64-sie-ps5 -### 2>&1 | FileCheck -check-prefix=JUMPTABLESIZES %s +// JUMPTABLESIZES: "-mllvm" "-emit-jump-table-sizes-section" +// JUMPTABLESIZES: "-plugin-opt=-emit-jump-table-sizes-section" diff --git a/llvm/docs/Extensions.rst b/llvm/docs/Extensions.rst index 74ca8cb0aa687..0e209f3fe5cc0 100644 --- a/llvm/docs/Extensions.rst +++ b/llvm/docs/Extensions.rst @@ -554,6 +554,12 @@ time. This section is generated when the compiler enables fat LTO. This section has the ``SHF_EXCLUDE`` flag so that it is stripped from the final executable or shared library. +``SHT_LLVM_JT_SIZES`` Section (Jump table addresses and sizes) +^^^ +This section stores pairs of (jump table address, number of entries). +This information is useful for tools that need to statically reconstruct +the control flow of executables. + CodeView-Dependent -- diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h index fb39bb4b10b37..7bec01688783d 100644 --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -1121,6 +1121,7 @@ enum : unsigned { SHT_LLVM_BB_ADDR_MAP = 0x6fff4c0a,// LLVM Basic Block Address Map. SHT_LLVM_OFFLOADING = 0x6fff4c0b, // LLVM device offloading data. SHT_LLVM_LTO = 0x6fff4c0c,// .llvm.lto for fat LTO. + SHT_LLVM_JT_SIZES = 0x6fff4c0d, // LLVM jump tables sizes. // Android's experimental support for SHT_RELR sections. // https://android.googlesource.com/platform/bionic/+/b7feec74547f84559a1467aca02708ff61346d2a/libc/include/elf.h#512 SHT_ANDROID_RELR = 0x6f00, // Relocation entries; only offsets. diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b64fe83959eb1..05624d2728bfd 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -107,6 +107,7 @@ #include "llvm/Pass.h" #include "llvm/Remarks/RemarkStreamer.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -155,6 +156,11 @@ static cl::bits PgoAnalysisMapFeatures( "Enable extended information within the SHT_LLVM_BB_ADDR_MAP that is " "extracted from PGO related analysis.")); +static cl::opt EmitJumpTableSizesSect
[clang] 8370ba4 - [analyzer][NFC] Eliminate a dyn_cast (#100719)
Author: Kristóf Umann Date: 2024-08-05T13:25:31+02:00 New Revision: 8370ba4d15c6726ed82bcd0d42a3ea9c94cc56b0 URL: https://github.com/llvm/llvm-project/commit/8370ba4d15c6726ed82bcd0d42a3ea9c94cc56b0 DIFF: https://github.com/llvm/llvm-project/commit/8370ba4d15c6726ed82bcd0d42a3ea9c94cc56b0.diff LOG: [analyzer][NFC] Eliminate a dyn_cast (#100719) Response to the catch in this comment: https://github.com/llvm/llvm-project/pull/94357/files/07f6daf2cf0f5d5bd4fc9950f2585a3f52b4ad2f#r1692084074 Added: Modified: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.cpp clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 95ec28bfd20da..3ddcb7e94ae5d 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -832,9 +832,18 @@ class NoMemOwnershipChangeVisitor final : public NoOwnershipChangeVisitor { /// information. bool doesFnIntendToHandleOwnership(const Decl *Callee, ASTContext &ACtx) final { -using namespace clang::ast_matchers; const FunctionDecl *FD = dyn_cast(Callee); +// Given that the stack frame was entered, the body should always be +// theoretically obtainable. In case of body farms, the synthesized body +// is not attached to declaration, thus triggering the '!FD->hasBody()' +// branch. That said, would a synthesized body ever intend to handle +// ownership? As of today they don't. And if they did, how would we +// put notes inside it, given that it doesn't match any source locations? +if (!FD || !FD->hasBody()) + return false; +using namespace clang::ast_matchers; + auto Matches = match(findAll(stmt(anyOf(cxxDeleteExpr().bind("delete"), callExpr().bind("call", *FD->getBody(), ACtx); diff --git a/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.cpp b/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.cpp index 22b5ebfd6fab0..91f4ca371aa98 100644 --- a/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.cpp @@ -72,16 +72,6 @@ bool NoOwnershipChangeVisitor::wasModifiedInFunction( const ExplodedNode *CallEnterN, const ExplodedNode *CallExitEndN) { const Decl *Callee = CallExitEndN->getFirstPred()->getLocationContext()->getDecl(); - const FunctionDecl *FD = dyn_cast(Callee); - - // Given that the stack frame was entered, the body should always be - // theoretically obtainable. In case of body farms, the synthesized body - // is not attached to declaration, thus triggering the '!FD->hasBody()' - // branch. That said, would a synthesized body ever intend to handle - // ownership? As of today they don't. And if they did, how would we - // put notes inside it, given that it doesn't match any source locations? - if (!FD || !FD->hasBody()) -return false; if (!doesFnIntendToHandleOwnership( Callee, CallExitEndN->getState()->getAnalysisManager().getASTContext())) diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp index 4454f30630e27..22061373c4b39 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -755,9 +755,18 @@ class NoStreamStateChangeVisitor final : public NoOwnershipChangeVisitor { bool doesFnIntendToHandleOwnership(const Decl *Callee, ASTContext &ACtx) final { -using namespace clang::ast_matchers; const FunctionDecl *FD = dyn_cast(Callee); +// Given that the stack frame was entered, the body should always be +// theoretically obtainable. In case of body farms, the synthesized body +// is not attached to declaration, thus triggering the '!FD->hasBody()' +// branch. That said, would a synthesized body ever intend to handle +// ownership? As of today they don't. And if they did, how would we +// put notes inside it, given that it doesn't match any source locations? +if (!FD || !FD->hasBody()) + return false; +using namespace clang::ast_matchers; + auto Matches = match(findAll(callExpr().bind("call")), *FD->getBody(), ACtx); for (BoundNodes Match : Matches) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer][NFC] Eliminate a dyn_cast (PR #100719)
https://github.com/Szelethus closed https://github.com/llvm/llvm-project/pull/100719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC] Emit a jump table size section (PR #101962)
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 832203545d4e2157ca29f99b18e3360ffa180183 14f3cb82f0d7e69261bd7e1317bd66392e9a2c2b --extensions h,cpp,c -- clang/lib/Driver/ToolChains/PS4CPU.cpp clang/test/Driver/ps4-ps5-toolchain.c llvm/include/llvm/BinaryFormat/ELF.h llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/lib/MC/MCParser/ELFAsmParser.cpp llvm/lib/MC/MCSectionELF.cpp llvm/lib/Object/ELF.cpp `` View the diff from clang-format here. ``diff diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 05624d2728..50a89bc70a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2777,8 +2777,8 @@ void AsmPrinter::emitJumpTableInfo() { StringRef GroupName = F.hasComdat() ? F.getComdat()->getName() : ""; MCSection *JumpTableSizesSection = OutContext.getELFSection( -".debug_llvm_jump_table_sizes", ELF::SHT_LLVM_JT_SIZES, Flags, 0, GroupName, -F.hasComdat(), MCSection::NonUniqueID, LinkedToSym); +".debug_llvm_jump_table_sizes", ELF::SHT_LLVM_JT_SIZES, Flags, 0, +GroupName, F.hasComdat(), MCSection::NonUniqueID, LinkedToSym); OutStreamer->switchSection(JumpTableSizesSection); `` https://github.com/llvm/llvm-project/pull/101962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC] Emit a jump table size section (PR #101962)
https://github.com/omern1 updated https://github.com/llvm/llvm-project/pull/101962 >From 14f3cb82f0d7e69261bd7e1317bd66392e9a2c2b Mon Sep 17 00:00:00 2001 From: Nabeel Omer Date: Mon, 5 Aug 2024 11:50:18 +0100 Subject: [PATCH 1/2] [MC] Emit a jump table size section This patch will make LLVM emit a jump table size section containing tuples of (jump table address, entry count) in object files. This section is useful for tools that need to statically reconstruct the control flow of executables. The name of the new section is .debug_llvm_jump_table_sizes because that makes both llvm-strip and GNU strip remove it. At the moment this is only enabled by default for the PS5 target. --- clang/lib/Driver/ToolChains/PS4CPU.cpp| 8 ++ clang/test/Driver/ps4-ps5-toolchain.c | 5 + llvm/docs/Extensions.rst | 6 ++ llvm/include/llvm/BinaryFormat/ELF.h | 1 + llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 26 + llvm/lib/MC/MCParser/ELFAsmParser.cpp | 2 + llvm/lib/MC/MCSectionELF.cpp | 2 + llvm/lib/Object/ELF.cpp | 1 + .../CodeGen/X86/jump-table-size-section.ll| 97 +++ 9 files changed, 148 insertions(+) create mode 100644 llvm/test/CodeGen/X86/jump-table-size-section.ll diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index a9e612c44da06..f9a9e995fff8e 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -265,6 +265,8 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(D.getLTOMode() == LTOK_Thin ? "--lto=thin" : "--lto=full"); + AddLTOFlag("-emit-jump-table-sizes-section"); + if (UseJMC) AddLTOFlag("-enable-jmc-instrument"); @@ -483,6 +485,12 @@ void toolchains::PS4PS5Base::addClangTargetOptions( else CC1Args.push_back("-fvisibility-externs-nodllstorageclass=keep"); } + + // Enable jump table sizes section for PS5. + if (getTriple().isPS5()) { +CC1Args.push_back("-mllvm"); +CC1Args.push_back("-emit-jump-table-sizes-section"); + } } // PS4 toolchain. diff --git a/clang/test/Driver/ps4-ps5-toolchain.c b/clang/test/Driver/ps4-ps5-toolchain.c index 444e9df24714b..c9987c2b5758b 100644 --- a/clang/test/Driver/ps4-ps5-toolchain.c +++ b/clang/test/Driver/ps4-ps5-toolchain.c @@ -11,3 +11,8 @@ // RUN: %clang %s -### -target x86_64-sie-ps5 -flto 2>&1 | FileCheck %s --check-prefix=LTO // LTO-NOT: error: // LTO-NOT: unable to pass LLVM bit-code + +// Verify that the jump table sizes section is enabled. +// RUN: %clang %s -target x86_64-sie-ps5 -### 2>&1 | FileCheck -check-prefix=JUMPTABLESIZES %s +// JUMPTABLESIZES: "-mllvm" "-emit-jump-table-sizes-section" +// JUMPTABLESIZES: "-plugin-opt=-emit-jump-table-sizes-section" diff --git a/llvm/docs/Extensions.rst b/llvm/docs/Extensions.rst index 74ca8cb0aa687..0e209f3fe5cc0 100644 --- a/llvm/docs/Extensions.rst +++ b/llvm/docs/Extensions.rst @@ -554,6 +554,12 @@ time. This section is generated when the compiler enables fat LTO. This section has the ``SHF_EXCLUDE`` flag so that it is stripped from the final executable or shared library. +``SHT_LLVM_JT_SIZES`` Section (Jump table addresses and sizes) +^^^ +This section stores pairs of (jump table address, number of entries). +This information is useful for tools that need to statically reconstruct +the control flow of executables. + CodeView-Dependent -- diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h index fb39bb4b10b37..7bec01688783d 100644 --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -1121,6 +1121,7 @@ enum : unsigned { SHT_LLVM_BB_ADDR_MAP = 0x6fff4c0a,// LLVM Basic Block Address Map. SHT_LLVM_OFFLOADING = 0x6fff4c0b, // LLVM device offloading data. SHT_LLVM_LTO = 0x6fff4c0c,// .llvm.lto for fat LTO. + SHT_LLVM_JT_SIZES = 0x6fff4c0d, // LLVM jump tables sizes. // Android's experimental support for SHT_RELR sections. // https://android.googlesource.com/platform/bionic/+/b7feec74547f84559a1467aca02708ff61346d2a/libc/include/elf.h#512 SHT_ANDROID_RELR = 0x6f00, // Relocation entries; only offsets. diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b64fe83959eb1..05624d2728bfd 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -107,6 +107,7 @@ #include "llvm/Pass.h" #include "llvm/Remarks/RemarkStreamer.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -155,6 +156,11 @@ static cl::bits
[clang] [analyzer] Assert Callee is FunctionDecl in doesFnIntendToHandleOwnership() (PR #101066)
Szelethus wrote: Just landed the patch, sorry for the slack! https://github.com/llvm/llvm-project/pull/101066 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fix issue: [Clang][OpenMP] Implicit conversion with `pragma omp taskloop` #100536 (PR #101812)
alexey-bataev wrote: Again, I doubt this is the right fix. I assume the proper fix should properly cast expressions to the required type before using them in the expressions. This patch not fixes the issues, but hides it. https://github.com/llvm/llvm-project/pull/101812 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a42e515 - [OpenMP] OpenMP 5.1 "assume" directive parsing support (#92731)
Author: Julian Brown Date: 2024-08-05T07:37:07-04:00 New Revision: a42e515e3a9f3bb4e44389c097b89104d95b9b29 URL: https://github.com/llvm/llvm-project/commit/a42e515e3a9f3bb4e44389c097b89104d95b9b29 DIFF: https://github.com/llvm/llvm-project/commit/a42e515e3a9f3bb4e44389c097b89104d95b9b29.diff LOG: [OpenMP] OpenMP 5.1 "assume" directive parsing support (#92731) This is a minimal patch to support parsing for "omp assume" directives. These are meant to be hints to a compiler's optimisers: as such, it is legitimate (if not very useful) to ignore them. The patch builds on top of the existing support for "omp assumes" directives (note spelling!). Unlike the "omp [begin/end] assumes" directives, "omp assume" is associated with a compound statement, i.e. it can appear within a function. The "holds" assumption could (theoretically) be mapped onto the existing builtin "__builtin_assume", though the latter applies to a single point in the program, and the former to a range (i.e. the whole of the associated compound statement). This patch fixes sollve's OpenMP 5.1 "omp assume"-based tests. Added: clang/test/OpenMP/assume_lambda.cpp clang/test/OpenMP/assume_messages.c clang/test/OpenMP/assume_messages_attr.c clang/test/OpenMP/assume_nesting.cpp clang/test/OpenMP/assume_nesting_tmpl.cpp clang/test/OpenMP/assume_serialize_deserialize.cpp clang/test/OpenMP/assume_serialize_deserialize_tmpl.cpp clang/test/OpenMP/assume_template.cpp Modified: clang/docs/OpenMPSupport.rst clang/docs/ReleaseNotes.rst clang/include/clang-c/Index.h clang/include/clang/AST/OpenMPClause.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/AST/StmtOpenMP.h clang/include/clang/Basic/OpenMPKinds.h clang/include/clang/Basic/StmtNodes.td clang/include/clang/Parse/Parser.h clang/include/clang/Sema/SemaOpenMP.h clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/OpenMPClause.cpp clang/lib/AST/StmtOpenMP.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/tools/libclang/CIndex.cpp llvm/include/llvm/Frontend/OpenMP/OMP.td Removed: diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index da25c3880970a..0e72b3c6e09c9 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -314,7 +314,7 @@ implementation. +--+--+--+---+ | misc | assumes directives | :part:`worked on`| | +--+--+--+---+ -| misc | assume directive | :part:`worked on`| | +| misc | assume directive | :good:`done` | | +--+--+--+---+ | misc | nothing directive | :good:`done` | D123286 | +--+--+--+---+ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6f50ab07f1fc0..0f1a4c1851911 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -323,6 +323,7 @@ Python Binding Changes OpenMP Support -- +- Added support for 'omp assume' directive. Improvements diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 115f5ab090f96..4b4adbfb236e7 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/incl
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
https://github.com/alexey-bataev closed https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
github-actions[bot] wrote: @jtb20 Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][AVX10.2] Support AVX10.2-SATCVT new instructions. (PR #101599)
@@ -417,3 +417,173 @@ defm VMINMAXSH : avx10_minmax_scalar<"vminmaxsh", v8f16x_info, X86vminmaxs, X86v AVX512PSIi8Base, VEX_LIG, EVEX, , EVEX_CD8<16, CD8VT1>, TA; defm VMINMAXSS : avx10_minmax_scalar<"vminmaxss", v4f32x_info, X86vminmaxs, X86vminmaxsSae>, AVX512AIi8Base, VEX_LIG, EVEX, , EVEX_CD8<32, CD8VT1>; + +//- +// AVX10 SATCVT instructions +//- + +multiclass avx10_sat_cvt_rmb Opc, string OpStr, X86FoldableSchedWrite sched, + X86VectorVTInfo DestInfo, + X86VectorVTInfo SrcInfo, + SDNode MaskNode> { + defm rr: AVX512_maskable, Sched<[sched]>; + defm rm: AVX512_maskable, + Sched<[sched.Folded, sched.ReadAfterFold]>; + defm rmb: AVX512_maskable, EVEX_B, + Sched<[sched.Folded, sched.ReadAfterFold]>; +} + +// Conversion with rounding control (RC) +multiclass avx10_sat_cvt_rc Opc, string OpStr, X86SchedWriteWidths sched, + AVX512VLVectorVTInfo DestInfo, AVX512VLVectorVTInfo SrcInfo, + SDNode MaskNode> { +let Uses = [MXCSR] in +defm Zrrb : AVX512_maskable, + Sched<[sched.ZMM]>, EVEX, EVEX_RC, EVEX_B; +let Predicates = [HasAVX10_2], hasEVEX_U = 1 in { +defm Z256rrb : AVX512_maskable, + Sched<[sched.YMM]>, EVEX, EVEX_RC, EVEX_B; +} +} + +// Conversion with SAE +multiclass +avx10_sat_cvt_sae Opc, string OpStr, X86SchedWriteWidths sched, + AVX512VLVectorVTInfo DestInfo, AVX512VLVectorVTInfo SrcInfo, + SDNode Node> { +let Uses = [MXCSR] in +defm Zrrb : AVX512_maskable, + Sched<[sched.ZMM]>, EVEX, EVEX_B; +let Predicates = [HasAVX10_2], hasEVEX_U = 1 in { +defm Z256rrb : AVX512_maskable, + Sched<[sched.YMM]>, EVEX, EVEX_B; +} +} + +multiclass avx10_sat_cvt_base Opc, string OpStr, X86SchedWriteWidths sched, + SDNode MaskNode, AVX512VLVectorVTInfo DestInfo, + AVX512VLVectorVTInfo SrcInfo> { + let Predicates = [HasAVX10_2_512] in + defm Z : avx10_sat_cvt_rmb, + EVEX, EVEX_V512; + let Predicates = [HasAVX10_2] in { +defm Z256 +: avx10_sat_cvt_rmb, + EVEX, EVEX_V256; +defm Z128 +: avx10_sat_cvt_rmb, + EVEX, EVEX_V128; + } +} + +defm VCVTNEBF162IBS : avx10_sat_cvt_base<0x69, "vcvtnebf162ibs", + SchedWriteVecIMul, X86vcvtnebf162ibs, + avx512vl_i16_info, avx512vl_bf16_info>, + AVX512XDIi8Base, T_MAP5, EVEX_CD8<16, CD8VF>; +defm VCVTNEBF162IUBS : avx10_sat_cvt_base<0x6b, "vcvtnebf162iubs", + SchedWriteVecIMul, X86vcvtnebf162iubs, + avx512vl_i16_info, avx512vl_bf16_info>, + AVX512XDIi8Base, T_MAP5, EVEX_CD8<16, CD8VF>; FreddyLeaf wrote: how to extra `U` to `defm VCVTNEBF162IBS`? https://github.com/llvm/llvm-project/pull/101599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement C++26’s P2893R3 ‘Variadic friends’ (PR #101448)
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/101448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Restrict Ofast deprecation help message to Clang (PR #101682)
https://github.com/kiranchandramohan milestoned https://github.com/llvm/llvm-project/pull/101682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e60ee1f - [Driver] Restrict Ofast deprecation help message to Clang (#101682)
Author: Kiran Chandramohan Date: 2024-08-05T12:43:37+01:00 New Revision: e60ee1f2d70bdb0ac87b09ae685d669d8543b7bd URL: https://github.com/llvm/llvm-project/commit/e60ee1f2d70bdb0ac87b09ae685d669d8543b7bd DIFF: https://github.com/llvm/llvm-project/commit/e60ee1f2d70bdb0ac87b09ae685d669d8543b7bd.diff LOG: [Driver] Restrict Ofast deprecation help message to Clang (#101682) The discussion about this in Flang (https://discourse.llvm.org/t/rfc-deprecate-ofast-in-flang/80243) has not concluded hence restricting the deprecation only to Clang. Added: Modified: clang/include/clang/Driver/Options.td Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 312e4e6d139bd..8471b89d0af39 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -932,8 +932,9 @@ def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>, Alias, AliasArgs<["1"]>; def Ofast : Joined<["-"], "Ofast">, Group, Visibility<[ClangOption, CC1Option, FlangOption]>, - HelpText<"Deprecated; use '-O3 -ffast-math' for the same behavior," - " or '-O3' to enable only conforming optimizations">; + HelpTextForVariants<[ClangOption, CC1Option], + "Deprecated; use '-O3 -ffast-math' for the same behavior," + " or '-O3' to enable only conforming optimizations">; def P : Flag<["-"], "P">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, Group, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Restrict Ofast deprecation help message to Clang (PR #101682)
https://github.com/kiranchandramohan closed https://github.com/llvm/llvm-project/pull/101682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Restrict Ofast deprecation help message to Clang (PR #101682)
kiranchandramohan wrote: /cherry-pick e60ee1f https://github.com/llvm/llvm-project/pull/101682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][AVX10.2] Support AVX10.2-SATCVT new instructions. (PR #101599)
@@ -821,6 +821,88 @@ def X86vpdpbuuds : SDNode<"X86ISD::VPDPBUUDS", SDTVnni>; def X86Vmpsadbw : SDNode<"X86ISD::MPSADBW", SDTX86PSADBW>; +def SDTAVX10SATCVT_BF162I : SDTypeProfile<1, 1, [ + SDTCVecEltisVT<0, i16>, SDTCVecEltisVT<1, bf16> +]>; + +def SDTAVX10SATCVT_PH2I : SDTypeProfile<1, 1, [ + SDTCVecEltisVT<0, i16>, SDTCVecEltisVT<1, f16> +]>; + +def SDTAVX10SATCVT_PS2I : SDTypeProfile<1, 1, [ + SDTCVecEltisVT<0, i32>, SDTCVecEltisVT<1, f32> +]>; FreddyLeaf wrote: VCVTNEBF162IBSZrr: (X86vcvtnebf162ibs:{ *:[v32i16] } VR512:{ *:[v32f16 v32bf16 v16f32 v8f64] }:$src)\ error: In VCVTNEBF162IBSZrr: Could not infer all types in pattern! https://github.com/llvm/llvm-project/pull/101599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/77732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)
https://github.com/AaronBallman commented: I'm wondering why the GNU-compatible behavior is not on by default, especially when in GNU mode (e.g., `-std=gnu17`)? Also, the changes should come with a release note in `clang/docs/ReleaseNotes.rst` so users know about the new functionality. https://github.com/llvm/llvm-project/pull/77732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)
@@ -1654,6 +1654,10 @@ void CompilerInvocationBase::GenerateCodeGenArgs(const CodeGenOptions &Opts, GenerateArg(Consumer, Opt); } + if (T.isPPC32() && Opts.ComplexInRegABI == CodeGenOptions::CMPLX_InGPR) { +GenerateArg(Consumer, OPT_fcomplex_ppc_gnu_abi); + } + AaronBallman wrote: ```suggestion if (T.isPPC32() && Opts.ComplexInRegABI == CodeGenOptions::CMPLX_InGPR) GenerateArg(Consumer, OPT_fcomplex_ppc_gnu_abi); ``` https://github.com/llvm/llvm-project/pull/77732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)
@@ -2028,6 +2032,10 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, } } + if (Args.getLastArg(OPT_fcomplex_ppc_gnu_abi)) { +Opts.setComplexInRegABI(CodeGenOptions::CMPLX_InGPR); + } AaronBallman wrote: ```suggestion if (Args.getLastArg(OPT_fcomplex_ppc_gnu_abi)) Opts.setComplexInRegABI(CodeGenOptions::CMPLX_InGPR); ``` https://github.com/llvm/llvm-project/pull/77732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)
@@ -0,0 +1,9 @@ +// RUN: %clang -c --target=ppc32 -fcomplex-ppc-gnu-abi %s 2>&1 AaronBallman wrote: It'd be nice for this to check `-###` output to ensure that it's passing along the correct `-cc1` option. https://github.com/llvm/llvm-project/pull/77732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Restrict Ofast deprecation help message to Clang (PR #101682)
llvmbot wrote: /pull-request llvm/llvm-project#101963 https://github.com/llvm/llvm-project/pull/101682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][AVX10.2] Support AVX10.2-SATCVT new instructions. (PR #101599)
https://github.com/FreddyLeaf edited https://github.com/llvm/llvm-project/pull/101599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Define __cpp_pack_indexing (PR #101956)
https://github.com/cor3ntin approved this pull request. LGTM. I think we should backport to Clang 19. WDYT? https://github.com/llvm/llvm-project/pull/101956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][AVX10.2] Support AVX10.2-SATCVT new instructions. (PR #101599)
@@ -821,6 +821,88 @@ def X86vpdpbuuds : SDNode<"X86ISD::VPDPBUUDS", SDTVnni>; def X86Vmpsadbw : SDNode<"X86ISD::MPSADBW", SDTX86PSADBW>; +def SDTAVX10SATCVT_BF162I : SDTypeProfile<1, 1, [ + SDTCVecEltisVT<0, i16>, SDTCVecEltisVT<1, bf16> +]>; + +def SDTAVX10SATCVT_PH2I : SDTypeProfile<1, 1, [ + SDTCVecEltisVT<0, i16>, SDTCVecEltisVT<1, f16> +]>; + +def SDTAVX10SATCVT_PS2I : SDTypeProfile<1, 1, [ + SDTCVecEltisVT<0, i32>, SDTCVecEltisVT<1, f32> +]>; + +def SDTAVX10SATCVT_PH2I_ROUND : SDTypeProfile<1, 2, [ + SDTCVecEltisVT<0, i16>, SDTCVecEltisVT<1, f16>, SDTCisInt<2> +]>; + +def SDTAVX10SATCVT_PS2I_RND : SDTypeProfile<1, 2, [ + SDTCVecEltisVT<0, i32>, SDTCVecEltisVT<1, f32>, SDTCisInt<2> +]>; + +def SDTAVX10SATCVT_PH2I_SAE : SDTypeProfile<1, 1, [ + SDTCVecEltisVT<0, i16>, SDTCVecEltisVT<1, f16>, + SDTCisSameNumEltsAs<0, 1> +]>; + +def SDTAVX10SATCVT_PS2I_SAE : SDTypeProfile<1, 1, [ + SDTCVecEltisVT<0, i32>, SDTCVecEltisVT<1, f32>, + SDTCisSameNumEltsAs<0, 1> +]>; + +def X86vcvtnebf162ibs +: SDNode<"X86ISD::VCVTNEBF162IBS", SDTAVX10SATCVT_BF162I>; + +def X86vcvtnebf162iubs +: SDNode<"X86ISD::VCVTNEBF162IUBS", SDTAVX10SATCVT_BF162I>; + +def X86vcvtph2ibs : SDNode<"X86ISD::VCVTPH2IBS", SDTAVX10SATCVT_PH2I>; + +def X86vcvtph2ibsRnd +: SDNode<"X86ISD::VCVTPH2IBS_RND", SDTAVX10SATCVT_PH2I_ROUND>; + +def X86vcvtph2iubs : SDNode<"X86ISD::VCVTPH2IUBS", SDTAVX10SATCVT_PH2I>; + +def X86vcvtph2iubsRnd +: SDNode<"X86ISD::VCVTPH2IUBS_RND", SDTAVX10SATCVT_PH2I_ROUND>; + +def X86vcvtps2ibs : SDNode<"X86ISD::VCVTPS2IBS", SDTAVX10SATCVT_PS2I>; + +def X86vcvtps2ibsRnd +: SDNode<"X86ISD::VCVTPS2IBS_RND", SDTAVX10SATCVT_PS2I_RND>; + +def X86vcvtps2iubs : SDNode<"X86ISD::VCVTPS2IUBS", SDTAVX10SATCVT_PS2I>; + +def X86vcvtps2iubsRnd +: SDNode<"X86ISD::VCVTPS2IUBS_RND", SDTAVX10SATCVT_PS2I_RND>; FreddyLeaf wrote: Sorry, I don't understand. Then how to define different patterns for different instructions if sharing same SDNode? https://github.com/llvm/llvm-project/pull/101599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c65afad - [Clang] Define __cpp_pack_indexing (#101956)
Author: Sirraide Date: 2024-08-05T14:02:15+02:00 New Revision: c65afad9c58474a784633314e945c874ed06584a URL: https://github.com/llvm/llvm-project/commit/c65afad9c58474a784633314e945c874ed06584a DIFF: https://github.com/llvm/llvm-project/commit/c65afad9c58474a784633314e945c874ed06584a.diff LOG: [Clang] Define __cpp_pack_indexing (#101956) Following the discussion on #101448 this defines `__cpp_pack_indexing`. Since pack indexing is currently supported in all language modes, the feature test macro is also defined in all language modes. Added: Modified: clang/docs/LanguageExtensions.rst clang/lib/Frontend/InitPreprocessor.cpp clang/test/Lexer/cxx-features.cpp Removed: diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 9dcb4ac9b75ca..be07f81cc41b0 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -1503,6 +1503,7 @@ Conditional ``explicit`` __cpp_conditional_explicit C+ ``static operator()``__cpp_static_call_operator C++23 C++03 Attributes on Lambda-Expressions C++23 C++11 Attributes on Structured Bindings__cpp_structured_bindings C++26 C++03 +Pack Indexing__cpp_pack_indexing C++26 C++03 ``= delete ("should have a reason");`` __cpp_deleted_function C++26 C++03 - - Designated initializers (N494) C99 C89 diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 17b9ca7cb9910..8e62461d8a181 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -763,6 +763,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_placeholder_variables", "202306L"); // C++26 features supported in earlier language modes. + Builder.defineMacro("__cpp_pack_indexing", "202311L"); Builder.defineMacro("__cpp_deleted_function", "202403L"); if (LangOpts.Char8) diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp index 4c2aa3ae2c544..08b732132228b 100644 --- a/clang/test/Lexer/cxx-features.cpp +++ b/clang/test/Lexer/cxx-features.cpp @@ -38,6 +38,10 @@ #error "wrong value for __cpp_deleted_function" #endif +#if check(pack_indexing, 202311, 202311, 202311, 202311, 202311, 202311, 202311) +#error "wrong value for __cpp_pack_indexing" +#endif + #if check(placeholder_variables, 202306, 202306, 202306, 202306, 202306, 202306, 202306) #error "wrong value for __cpp_placeholder_variables" #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Define __cpp_pack_indexing (PR #101956)
https://github.com/Sirraide closed https://github.com/llvm/llvm-project/pull/101956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Define __cpp_pack_indexing (PR #101956)
Sirraide wrote: > I think we should backport to Clang 19. WDYT? That makes a lot of sense to me imo: the feature is already in Clang 19, this just makes it so we claim to support it too. https://github.com/llvm/llvm-project/pull/101956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Define __cpp_pack_indexing (PR #101956)
https://github.com/Sirraide milestoned https://github.com/llvm/llvm-project/pull/101956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Define __cpp_pack_indexing (PR #101956)
Sirraide wrote: /cherry-pick https://github.com/llvm/llvm-project/commit/c65afad9c58474a784633314e945c874ed06584a https://github.com/llvm/llvm-project/pull/101956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 31bb759 - Fix an unused variable and -Wswitch warning after a42e515e3a9f3bb4e44389c097b89104d95b9b29
Author: Haojian Wu Date: 2024-08-05T14:05:14+02:00 New Revision: 31bb759d78576bec4c5b844edd52686eb6cc9fc3 URL: https://github.com/llvm/llvm-project/commit/31bb759d78576bec4c5b844edd52686eb6cc9fc3 DIFF: https://github.com/llvm/llvm-project/commit/31bb759d78576bec4c5b844edd52686eb6cc9fc3.diff LOG: Fix an unused variable and -Wswitch warning after a42e515e3a9f3bb4e44389c097b89104d95b9b29 Added: Modified: clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaExceptionSpec.cpp Removed: diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 0602d884c..d4dc06dcb9c26 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2584,7 +2584,6 @@ StmtResult Parser::ParseOpenMPInformationalDirective( "Unexpected directive category"); bool HasAssociatedStatement = true; - Association Assoc = getDirectiveAssociation(DKind); SmallVector Clauses; llvm::SmallBitVector SeenClauses(llvm::omp::Clause_enumSize + 1); diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index 427ffd9061ef3..c4481250f345a 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -1431,6 +1431,7 @@ CanThrowResult Sema::canThrow(const Stmt *S) { case Stmt::ObjCAutoreleasePoolStmtClass: case Stmt::ObjCForCollectionStmtClass: case Stmt::OMPAtomicDirectiveClass: + case Stmt::OMPAssumeDirectiveClass: case Stmt::OMPBarrierDirectiveClass: case Stmt::OMPCancelDirectiveClass: case Stmt::OMPCancellationPointDirectiveClass: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Define __cpp_pack_indexing (PR #101956)
llvmbot wrote: /pull-request llvm/llvm-project#101965 https://github.com/llvm/llvm-project/pull/101956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC] Emit a jump table size section (PR #101962)
https://github.com/omern1 updated https://github.com/llvm/llvm-project/pull/101962 >From 14f3cb82f0d7e69261bd7e1317bd66392e9a2c2b Mon Sep 17 00:00:00 2001 From: Nabeel Omer Date: Mon, 5 Aug 2024 11:50:18 +0100 Subject: [PATCH 1/3] [MC] Emit a jump table size section This patch will make LLVM emit a jump table size section containing tuples of (jump table address, entry count) in object files. This section is useful for tools that need to statically reconstruct the control flow of executables. The name of the new section is .debug_llvm_jump_table_sizes because that makes both llvm-strip and GNU strip remove it. At the moment this is only enabled by default for the PS5 target. --- clang/lib/Driver/ToolChains/PS4CPU.cpp| 8 ++ clang/test/Driver/ps4-ps5-toolchain.c | 5 + llvm/docs/Extensions.rst | 6 ++ llvm/include/llvm/BinaryFormat/ELF.h | 1 + llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 26 + llvm/lib/MC/MCParser/ELFAsmParser.cpp | 2 + llvm/lib/MC/MCSectionELF.cpp | 2 + llvm/lib/Object/ELF.cpp | 1 + .../CodeGen/X86/jump-table-size-section.ll| 97 +++ 9 files changed, 148 insertions(+) create mode 100644 llvm/test/CodeGen/X86/jump-table-size-section.ll diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index a9e612c44da06..f9a9e995fff8e 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -265,6 +265,8 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(D.getLTOMode() == LTOK_Thin ? "--lto=thin" : "--lto=full"); + AddLTOFlag("-emit-jump-table-sizes-section"); + if (UseJMC) AddLTOFlag("-enable-jmc-instrument"); @@ -483,6 +485,12 @@ void toolchains::PS4PS5Base::addClangTargetOptions( else CC1Args.push_back("-fvisibility-externs-nodllstorageclass=keep"); } + + // Enable jump table sizes section for PS5. + if (getTriple().isPS5()) { +CC1Args.push_back("-mllvm"); +CC1Args.push_back("-emit-jump-table-sizes-section"); + } } // PS4 toolchain. diff --git a/clang/test/Driver/ps4-ps5-toolchain.c b/clang/test/Driver/ps4-ps5-toolchain.c index 444e9df24714b..c9987c2b5758b 100644 --- a/clang/test/Driver/ps4-ps5-toolchain.c +++ b/clang/test/Driver/ps4-ps5-toolchain.c @@ -11,3 +11,8 @@ // RUN: %clang %s -### -target x86_64-sie-ps5 -flto 2>&1 | FileCheck %s --check-prefix=LTO // LTO-NOT: error: // LTO-NOT: unable to pass LLVM bit-code + +// Verify that the jump table sizes section is enabled. +// RUN: %clang %s -target x86_64-sie-ps5 -### 2>&1 | FileCheck -check-prefix=JUMPTABLESIZES %s +// JUMPTABLESIZES: "-mllvm" "-emit-jump-table-sizes-section" +// JUMPTABLESIZES: "-plugin-opt=-emit-jump-table-sizes-section" diff --git a/llvm/docs/Extensions.rst b/llvm/docs/Extensions.rst index 74ca8cb0aa687..0e209f3fe5cc0 100644 --- a/llvm/docs/Extensions.rst +++ b/llvm/docs/Extensions.rst @@ -554,6 +554,12 @@ time. This section is generated when the compiler enables fat LTO. This section has the ``SHF_EXCLUDE`` flag so that it is stripped from the final executable or shared library. +``SHT_LLVM_JT_SIZES`` Section (Jump table addresses and sizes) +^^^ +This section stores pairs of (jump table address, number of entries). +This information is useful for tools that need to statically reconstruct +the control flow of executables. + CodeView-Dependent -- diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h index fb39bb4b10b37..7bec01688783d 100644 --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -1121,6 +1121,7 @@ enum : unsigned { SHT_LLVM_BB_ADDR_MAP = 0x6fff4c0a,// LLVM Basic Block Address Map. SHT_LLVM_OFFLOADING = 0x6fff4c0b, // LLVM device offloading data. SHT_LLVM_LTO = 0x6fff4c0c,// .llvm.lto for fat LTO. + SHT_LLVM_JT_SIZES = 0x6fff4c0d, // LLVM jump tables sizes. // Android's experimental support for SHT_RELR sections. // https://android.googlesource.com/platform/bionic/+/b7feec74547f84559a1467aca02708ff61346d2a/libc/include/elf.h#512 SHT_ANDROID_RELR = 0x6f00, // Relocation entries; only offsets. diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b64fe83959eb1..05624d2728bfd 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -107,6 +107,7 @@ #include "llvm/Pass.h" #include "llvm/Remarks/RemarkStreamer.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -155,6 +156,11 @@ static cl::bits
[clang] [Clang] SFINAE on mismatching pack length during constraint satisfaction checking (PR #101879)
https://github.com/AaronBallman approved this pull request. LGTM! This should be backported, thank you for the quick fix! https://github.com/llvm/llvm-project/pull/101879 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [PAC][AArch64] Support init/fini array signing (PR #96478)
kovdan01 wrote: Ping: this PR blocks merging already approved #96159 (see https://github.com/llvm/llvm-project/pull/96159#issuecomment-2211411440), which transitively also blocks merging already approved dependent #96164. Would be glad to see feedback on the changes from those who are interested. https://github.com/llvm/llvm-project/pull/96478 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 69c6a3f - More -Wswitch warning fixes for a42e515e3a9f3bb4e44389c097b89104d95b9b29
Author: Haojian Wu Date: 2024-08-05T14:21:34+02:00 New Revision: 69c6a3faafe8fa3fa8d7554e0ebe64aae3c3d10b URL: https://github.com/llvm/llvm-project/commit/69c6a3faafe8fa3fa8d7554e0ebe64aae3c3d10b DIFF: https://github.com/llvm/llvm-project/commit/69c6a3faafe8fa3fa8d7554e0ebe64aae3c3d10b.diff LOG: More -Wswitch warning fixes for a42e515e3a9f3bb4e44389c097b89104d95b9b29 Added: Modified: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp clang/tools/libclang/CIndex.cpp clang/tools/libclang/CXCursor.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 62a240ecbc600..686310d38ebd5 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1776,6 +1776,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred, case Stmt::OMPScanDirectiveClass: case Stmt::OMPOrderedDirectiveClass: case Stmt::OMPAtomicDirectiveClass: +case Stmt::OMPAssumeDirectiveClass: case Stmt::OMPTargetDirectiveClass: case Stmt::OMPTargetDataDirectiveClass: case Stmt::OMPTargetEnterDataDirectiveClass: diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 40c74d49e41e9..c00cad1ad65af 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -3326,7 +3326,7 @@ void EnqueueVisitor::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *D) { } void EnqueueVisitor::VisitOMPAssumeDirective(const OMPAssumeDirective *D) { - VisitOMPAssumeDirective(D); + VisitOMPExecutableDirective(D); } void EnqueueVisitor::VisitOMPErrorDirective(const OMPErrorDirective *D) { diff --git a/clang/tools/libclang/CXCursor.cpp b/clang/tools/libclang/CXCursor.cpp index 782c0c243ef1f..d87eb95761ed7 100644 --- a/clang/tools/libclang/CXCursor.cpp +++ b/clang/tools/libclang/CXCursor.cpp @@ -888,6 +888,10 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent, break; case Stmt::BuiltinBitCastExprClass: K = CXCursor_BuiltinBitCastExpr; +break; + case Stmt::OMPAssumeDirectiveClass: +K = CXCursor_OMPAssumeDirective; +break; } CXCursor C = {K, 0, {Parent, S, TU}}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] da380b2 - [Clang] SFINAE on mismatching pack length during constraint satisfaction checking (#101879)
Author: cor3ntin Date: 2024-08-05T14:22:07+02:00 New Revision: da380b26e4748ade5a8dba85b7df5e1c4eded8bc URL: https://github.com/llvm/llvm-project/commit/da380b26e4748ade5a8dba85b7df5e1c4eded8bc DIFF: https://github.com/llvm/llvm-project/commit/da380b26e4748ade5a8dba85b7df5e1c4eded8bc.diff LOG: [Clang] SFINAE on mismatching pack length during constraint satisfaction checking (#101879) If a fold expanded constraint would expand packs of different size, it is not a valid pack expansion and it is not satisfied. This should not produce an error. Fixes #99430 Added: Modified: clang/lib/Sema/SemaConcept.cpp clang/test/SemaCXX/cxx2c-fold-exprs.cpp Removed: diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 75ccefa2a487e..d4c9d044985e3 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -532,6 +532,10 @@ static ExprResult calculateConstraintSatisfaction( std::optional EvaluateFoldExpandedConstraintSize(const CXXFoldExpr *FE) const { + + // We should ignore errors in the presence of packs of diff erent size. + Sema::SFINAETrap Trap(S); + Expr *Pattern = FE->getPattern(); SmallVector Unexpanded; diff --git a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp index 1e0bc7bcfb4e7..0674135aac483 100644 --- a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp +++ b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp @@ -275,3 +275,33 @@ static_assert(S::g() == 2); // expected-error {{call to 'g' is ambiguo } + +namespace GH99430 { + +template +using _Synth_three_way_result = int; + +template +class tuple; + +template +struct tuple_element; + +template +struct _Three_way_comparison_result_with_tuple_like { + using type = int; +}; + +template + requires(requires { +typename _Synth_three_way_result<_TTypes, tuple_element<_Indices>>; + } && ...) + +struct _Three_way_comparison_result_with_tuple_like, _Indices...>{ +using type = long; +}; + +static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like, 0, 1>::type, int)); +static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like, 0>::type, long)); + +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] SFINAE on mismatching pack length during constraint satisfaction checking (PR #101879)
https://github.com/cor3ntin closed https://github.com/llvm/llvm-project/pull/101879 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits