[clang] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic` (PR #137849)
@@ -4238,7 +4238,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF, else elemTy = CGF.ConvertTypeForMem(elementType); - if (CGF.getLangOpts().PointerOverflowDefined) + if (CGF.getLangOpts().PointerOverflowDefined || + CGF.isUnderlyingBasePointerConstantNull(pointerOperand)) nikic wrote: An important difference is that isNullPointerArithmeticExtension() uses inttoptr, which means we get back a pointer with provenance, while this case only drops the inbounds, but still keeps the gep null, resulting in a pointer with nullary provenance, so any loads/stores on it are UB. (Using inttoptr is of course only possible if we know for sure that the base pointer is null, it doesn't work for the "we have a select where the result might be null" case.) https://github.com/llvm/llvm-project/pull/137849 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ASTImporter] Fix AST import if anonymous namespaces are merged (PR #128735)
balazske wrote: I am now not really sure what happens, if there is a single anonymous namespace for a TU or there are separate ones for the anonymous namespaces in for example `extern "C"` blocks (and how it should work according to the C++ standard). Probably adding more tests where there is a name conflict will show what happens. The ideal solution looks like to separate the imported anonymous namespace from the existing one but this may be difficult to implement. https://github.com/llvm/llvm-project/pull/128735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)
@@ -1,105 +1,33 @@ -// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s -// expected-no-diagnostics - +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -DOMP52 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s ravurvi20 wrote: In this case, I’ve only changed the printed spelling from default to otherwise for OpenMP metadirective. This is purely a printing change — no new AST nodes or data structures were introduced or modified. The existing AST structure remains unchanged. The `metadirective_ast_print.c` test case includes all relevant checks to verify the updated `-ast-print` output. https://github.com/llvm/llvm-project/pull/128640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)
@@ -1660,6 +1660,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">; def err_omp_missing_comma : Error< "missing ',' after %0">; def err_omp_expected_context_selector : Error<"expected valid context selector in %0">; +def err_omp_unknown_clause +: Error<"expected an OpenMP clause">; +def warn_omp_default_deprecated : Warning<"'default' clause for" ravurvi20 wrote: I agree that consolidating into a single message with arguments would be a cleaner approach. For now, I’d appreciate it if we could proceed with this version, and I’ll take up the refactoring in a follow-up patch. https://github.com/llvm/llvm-project/pull/128640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix UEFI Target info (PR #127290)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/127290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro (PR #137851)
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/137851 >From f1db3a540ec1383451955efab62b64ed8d180349 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Wed, 30 Apr 2025 01:26:41 +0800 Subject: [PATCH 1/4] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic` --- clang/lib/CodeGen/CGExprScalar.cpp | 3 ++- .../test/CodeGen/catch-nullptr-and-nonzero-offset.c | 12 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 8dbbcdaef25d8..d214d2af52563 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -4238,7 +4238,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF, else elemTy = CGF.ConvertTypeForMem(elementType); - if (CGF.getLangOpts().PointerOverflowDefined) + if (CGF.getLangOpts().PointerOverflowDefined || + CGF.isUnderlyingBasePointerConstantNull(pointerOperand)) return CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr"); return CGF.EmitCheckedInBoundsGEP( diff --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c index 63b6db2c2adeb..c5ae3f8bcc368 100644 --- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c +++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c @@ -431,6 +431,18 @@ char *void_ptr(void *base, unsigned long offset) { return base + offset; } +int *constant_null_add(long offset) { + // CHECK: define{{.*}} ptr @constant_null_add(i64 noundef %[[OFFSET:.*]]) + // CHECK-NEXT: [[ENTRY:.*]]: + // CHECK-NEXT: %[[OFFSET_ADDR:.*]] = alloca i64, align 8 + // CHECK-NEXT: store i64 %[[OFFSET]], ptr %[[OFFSET_ADDR]], align 8 + // CHECK-NEXT: %[[OFFSET_RELOADED:.*]] = load i64, ptr %[[OFFSET_ADDR]], align 8 + // CHECK-NEXT: %[[ADD_PTR:.*]] = getelementptr i32, ptr null, i64 %[[OFFSET_RELOADED]] + // CHECK-NEXT: ret ptr %[[ADD_PTR]] +#line 1800 + return (int *)0 + offset; +} + #ifdef __cplusplus } #endif >From 630ce89088ef4978eafe884766712279a0d8fd56 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Wed, 30 Apr 2025 01:47:45 +0800 Subject: [PATCH 2/4] [Clang][CodeGen] Add pre-commit tests. NFC. --- clang/test/CodeGen/glibc_ptr_align.c | 17 + 1 file changed, 17 insertions(+) create mode 100644 clang/test/CodeGen/glibc_ptr_align.c diff --git a/clang/test/CodeGen/glibc_ptr_align.c b/clang/test/CodeGen/glibc_ptr_align.c new file mode 100644 index 0..ebdb53cf7b53d --- /dev/null +++ b/clang/test/CodeGen/glibc_ptr_align.c @@ -0,0 +1,17 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -O3 -o - -emit-llvm %s | FileCheck %s + +// Make sure that we do not set inbounds flag if the base pointer may be a constant null. + +// CHECK-LABEL: define dso_local noalias noundef ptr @glibc_ptr_align( +// CHECK-SAME: ptr noundef readnone captures(none) [[BASE:%.*]], ptr noundef readnone captures(none) [[POINTER:%.*]], i64 noundef [[ALIGN_MASK:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT:ret ptr null +// +char *glibc_ptr_align(char *base, char *pointer, long align_mask) { + return (sizeof(long int) < sizeof(void *) ? (base) : (char *)0) + + (((pointer) - + (sizeof(long int) < sizeof(void *) ? (base) : (char *)0) + + (align_mask)) & + ~(align_mask)); +} >From ff88c23843d07a1c3142294a3d7c0894f0267a48 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Wed, 30 Apr 2025 01:49:10 +0800 Subject: [PATCH 3/4] [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro --- clang/lib/CodeGen/CGExpr.cpp | 3 +++ clang/test/CodeGen/glibc_ptr_align.c | 11 --- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index bba7d1e805f3f..e9e22321e2634 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -4820,6 +4820,9 @@ bool CodeGenFunction::isUnderlyingBasePointerConstantNull(const Expr *E) { const Expr *UnderlyingBaseExpr = E->IgnoreParens(); while (auto *BaseMemberExpr = dyn_cast(UnderlyingBaseExpr)) UnderlyingBaseExpr = BaseMemberExpr->getBase()->IgnoreParens(); + if (auto *Select = dyn_cast(UnderlyingBaseExpr)) +return isUnderlyingBasePointerConstantNull(Select->getTrueExpr()) || + isUnderlyingBasePointerConstantNull(Select->getFalseExpr()); return getContext().isSentinelNullExpr(UnderlyingBaseExpr); } diff --git a/clang/test/CodeGen/glibc_ptr_align.c b/clang/test/CodeGen/glibc_ptr_align.c index ebdb53cf7b53d..14968a8326509 100644 --- a/clang/test/CodeGen/glibc_ptr_align.c +++ b/clang/test/CodeGen/glibc_ptr_align.c @@ -3,10 +3,15 @@ // Make sure that we do not set inbounds flag i
[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)
https://github.com/melver edited https://github.com/llvm/llvm-project/pull/137133 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro (PR #137851)
@@ -4820,6 +4820,9 @@ bool CodeGenFunction::isUnderlyingBasePointerConstantNull(const Expr *E) { const Expr *UnderlyingBaseExpr = E->IgnoreParens(); while (auto *BaseMemberExpr = dyn_cast(UnderlyingBaseExpr)) UnderlyingBaseExpr = BaseMemberExpr->getBase()->IgnoreParens(); + if (auto *Select = dyn_cast(UnderlyingBaseExpr)) dtcxzyw wrote: Done. https://github.com/llvm/llvm-project/pull/137851 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)
https://github.com/melver updated https://github.com/llvm/llvm-project/pull/137133 >From a8319028f08192ca6140beed7f27a83a829c6d84 Mon Sep 17 00:00:00 2001 From: Marco Elver Date: Wed, 23 Apr 2025 11:31:25 +0200 Subject: [PATCH 1/2] Thread Safety Analysis: Convert CapabilityExpr::CapExpr to hold flags Rather than holding a single bool, switch it to contain flags, which is both more descriptive and simplifies adding more flags in subsequent changes. NFC. --- .../clang/Analysis/Analyses/ThreadSafetyCommon.h | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h index e99c5b2466334..6e46a2d721463 100644 --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h @@ -271,26 +271,28 @@ class CFGWalker { // translateAttrExpr needs it, but that should be moved too. class CapabilityExpr { private: - /// The capability expression and whether it's negated. - llvm::PointerIntPair CapExpr; + static constexpr unsigned FlagNegative = 1u << 0; + + /// The capability expression and flags. + llvm::PointerIntPair CapExpr; /// The kind of capability as specified by @ref CapabilityAttr::getName. StringRef CapKind; public: - CapabilityExpr() : CapExpr(nullptr, false) {} + CapabilityExpr() : CapExpr(nullptr, 0) {} CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg) - : CapExpr(E, Neg), CapKind(Kind) {} + : CapExpr(E, Neg ? FlagNegative : 0), CapKind(Kind) {} // Don't allow implicitly-constructed StringRefs since we'll capture them. template CapabilityExpr(const til::SExpr *, T, bool) = delete; const til::SExpr *sexpr() const { return CapExpr.getPointer(); } StringRef getKind() const { return CapKind; } - bool negative() const { return CapExpr.getInt(); } + bool negative() const { return CapExpr.getInt() & FlagNegative; } CapabilityExpr operator!() const { -return CapabilityExpr(CapExpr.getPointer(), CapKind, !CapExpr.getInt()); +return CapabilityExpr(CapExpr.getPointer(), CapKind, !negative()); } bool equals(const CapabilityExpr &other) const { >From 427dcd2c396fbd454129abb3d3f2d572f87eadbc Mon Sep 17 00:00:00 2001 From: Marco Elver Date: Thu, 24 Apr 2025 09:02:08 +0200 Subject: [PATCH 2/2] Thread Safety Analysis: Support reentrant capabilities Introduce the `reentrant_capability` attribute, which may be specified alongside the `capability(..)` attribute to denote that the defined capability type is reentrant. Marking a capability as reentrant means that acquiring the same capability multiple times is safe, and does not produce warnings on attempted re-acquisition. The most significant changes required are plumbing to propagate if the attribute is present to a CapabilityExpr, and then introducing a ReentrancyCount to FactEntry that can be incremented while a fact remains in the FactSet. Care was taken to avoid increasing the size of both CapabilityExpr and FactEntry by carefully allocating free bits of CapabilityExpr::CapExpr and the bitset respectively. --- clang/docs/ReleaseNotes.rst | 1 + clang/docs/ThreadSafetyAnalysis.rst | 18 + .../clang/Analysis/Analyses/ThreadSafety.h| 13 +- .../Analysis/Analyses/ThreadSafetyCommon.h| 21 +- clang/include/clang/Basic/Attr.td | 7 + .../clang/Basic/DiagnosticSemaKinds.td| 6 + clang/lib/Analysis/ThreadSafety.cpp | 134 +-- clang/lib/Analysis/ThreadSafetyCommon.cpp | 66 ++-- clang/lib/Sema/AnalysisBasedWarnings.cpp | 3 + clang/lib/Sema/SemaDeclAttr.cpp | 10 + ...a-attribute-supported-attributes-list.test | 1 + clang/test/Sema/warn-thread-safety-analysis.c | 20 + .../test/SemaCXX/thread-safety-annotations.h | 1 + .../SemaCXX/warn-thread-safety-analysis.cpp | 356 ++ .../SemaCXX/warn-thread-safety-parsing.cpp| 7 + clang/unittests/AST/ASTImporterTest.cpp | 9 + 16 files changed, 598 insertions(+), 75 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 80399e458aec3..2a6565e37e256 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -369,6 +369,7 @@ Improvements to Clang's diagnostics as function arguments or return value respectively. Note that :doc:`ThreadSafetyAnalysis` still does not perform alias analysis. The feature will be default-enabled with ``-Wthread-safety`` in a future release. +- The :doc:`ThreadSafetyAnalysis` now supports reentrant capabilities. - Clang will now do a better job producing common nested names, when producing common types for ternary operator, template argument deduction and multiple return auto deduction. - The ``-Wsign-compare`` warning now treats expressions with bitwise not(~) and minus(-) as signed integers diff --g
[clang] f62f36b - [clang][NFC] Avoid a duplicate variable in SemaExprCXX.cpp (#137464)
Author: Mariya Podchishchaeva Date: 2025-04-30T10:30:08+02:00 New Revision: f62f36b91de684ddfe129532e3a5086009b16f34 URL: https://github.com/llvm/llvm-project/commit/f62f36b91de684ddfe129532e3a5086009b16f34 DIFF: https://github.com/llvm/llvm-project/commit/f62f36b91de684ddfe129532e3a5086009b16f34.diff LOG: [clang][NFC] Avoid a duplicate variable in SemaExprCXX.cpp (#137464) Added: Modified: clang/lib/Sema/SemaExprCXX.cpp Removed: diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e6c6f57e6648b..73be4080ff90f 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3596,9 +3596,8 @@ FunctionDecl *Sema::FindDeallocationFunctionForDestructor(SourceLocation Loc, // If there's no class-specific operator delete, look up the global // non-array delete. - QualType RecordType = Context.getRecordType(RD); - IDP.PassAlignment = - alignedAllocationModeFromBool(hasNewExtendedAlignment(*this, RecordType)); + IDP.PassAlignment = alignedAllocationModeFromBool( + hasNewExtendedAlignment(*this, DeallocType)); IDP.PassSize = SizedDeallocationMode::Yes; return FindUsualDeallocationFunction(Loc, IDP, Name); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Avoid a duplicate variable in SemaExprCXX.cpp (PR #137464)
https://github.com/Fznamznon closed https://github.com/llvm/llvm-project/pull/137464 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV] Fix generation of DWARF info for vector segmented types (PR #137941)
https://github.com/wangpc-pp edited https://github.com/llvm/llvm-project/pull/137941 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch (PR #137932)
@@ -9,15 +9,31 @@ #define __CLC_DST_ADDR_SPACE local #define __CLC_SRC_ADDR_SPACE global #define __CLC_BODY -#include +#include +#undef __CLC_DST_ADDR_SPACE frasercrmck wrote: We probably don't need to `undef` and re-`define` here, when `local/global` isn't changing. Obviously we do when we swap them further down. https://github.com/llvm/llvm-project/pull/137932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch (PR #137932)
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/137932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch (PR #137932)
https://github.com/frasercrmck approved this pull request. Thanks. We could probably come up with some kind of combined `gentype.inc` that does them both at once (though both currently `undef` `__CLC_BODY` after they finish so we'd need to be able to stop that, or preserve `__CLC_BODY` across gentypes). Come to think of it, we do a lot of unnecessary `undef __CLC_BODY` around the codebase. I will try to clean that up in a separate PR. https://github.com/llvm/llvm-project/pull/137932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] ownership_returns attribute takes no more than 2 arguments (PR #137897)
https://github.com/el-ev approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/137897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7752e0a - Revert "[clang-format] Add OneLineFormatOffRegex option (#137577)"
Author: Owen Pan Date: 2025-04-30T00:12:41-07:00 New Revision: 7752e0a10b25da2f2eadbed10606bd5454dbca05 URL: https://github.com/llvm/llvm-project/commit/7752e0a10b25da2f2eadbed10606bd5454dbca05 DIFF: https://github.com/llvm/llvm-project/commit/7752e0a10b25da2f2eadbed10606bd5454dbca05.diff LOG: Revert "[clang-format] Add OneLineFormatOffRegex option (#137577)" This reverts commit b8bb1ccb4f9126d1bc9817be24e17f186a75a08b which triggered an assertion failure in CodeGenTest.TestNonAlterTest. Added: Modified: clang/docs/ClangFormatStyleOptions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Format/Format.h clang/lib/Format/Format.cpp clang/lib/Format/FormatTokenLexer.cpp clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTest.cpp Removed: diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index b47291599649d..3f8a5f49313b2 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -5195,29 +5195,6 @@ the configuration (without a prefix: ``Auto``). Add a space in front of an Objective-C protocol list, i.e. use ``Foo `` instead of ``Foo``. -.. _OneLineFormatOffRegex: - -**OneLineFormatOffRegex** (``String``) :versionbadge:`clang-format 21` :ref:`¶ ` - A regular expression that describes markers for turning formatting off for - one line. If it matches a comment that is the only token of a line, - clang-format skips the comment and the next line. Otherwise, clang-format - skips lines containing a matched token. - - .. code-block:: c++ - - // OneLineFormatOffRegex: ^(// NOLINT|logger$) - // results in the output below: - int a; - int b ; // NOLINT - int c; - // NOLINTNEXTLINE - int d ; - int e; - s = "// NOLINT"; - logger() ; - logger2(); - my_logger(); - .. _PPIndentWidth: **PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13` :ref:`¶ ` diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 80399e458aec3..bc68bb8b70b3d 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -720,7 +720,6 @@ clang-format top of the file. - Add ``EnumTrailingComma`` option for inserting/removing commas at the end of ``enum`` enumerator lists. -- Add ``OneLineFormatOffRegex`` option for turning formatting off for one line. libclang diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 7fe41d800ccb3..f6ceef08b46da 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -3654,27 +3654,6 @@ struct FormatStyle { /// \version 3.7 bool ObjCSpaceBeforeProtocolList; - /// A regular expression that describes markers for turning formatting off for - /// one line. If it matches a comment that is the only token of a line, - /// clang-format skips the comment and the next line. Otherwise, clang-format - /// skips lines containing a matched token. - /// \code - ///// OneLineFormatOffRegex: ^(// NOLINT|logger$) - ///// results in the output below: - ///int a; - ///int b ; // NOLINT - ///int c; - /// // NOLINTNEXTLINE - ///int d ; - ///int e; - ///s = "// NOLINT"; - /// logger() ; - ///logger2(); - ///my_logger(); - /// \endcode - /// \version 21 - std::string OneLineFormatOffRegex; - /// Different ways to try to fit all constructor initializers on a line. enum PackConstructorInitializersStyle : int8_t { /// Always put each constructor initializer on its own line. @@ -5420,7 +5399,6 @@ struct FormatStyle { ObjCPropertyAttributeOrder == R.ObjCPropertyAttributeOrder && ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty && ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList && - OneLineFormatOffRegex == R.OneLineFormatOffRegex && PackConstructorInitializers == R.PackConstructorInitializers && PenaltyBreakAssignment == R.PenaltyBreakAssignment && PenaltyBreakBeforeFirstCallParameter == diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 2f4b64ef4f5fe..5a1c3f556b331 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1100,7 +1100,6 @@ template <> struct MappingTraits { IO.mapOptional("ObjCSpaceAfterProperty", Style.ObjCSpaceAfterProperty); IO.mapOptional("ObjCSpaceBeforeProtocolList", Style.ObjCSpaceBeforeProtocolList); -IO.mapOptional("OneLineFormatOffRegex", Style.OneLineFormatOffRegex); IO.mapOptional("PackConstructorInitializers", Style.PackConstructorInitializers); IO.mapOptional("PenaltyBreakAssignment", Style.PenaltyBreakAssignment); diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/li
[clang] [ARM, AArch64] Fix ABI bugs with over-sized bitfields (PR #126774)
ostannard wrote: That looks like the expected consequence of this change: * Previously, the anonymous bitfield was erroneously given a 64-bit container, so it occupied 7 copies of the container type, starting at byte 8 of the struct and ending at 64. * Now, it is given a 128-bit container, as required by AAPCS64, so it needs 4 copies of the container type, starting at byte 16 and ending at 80. GCC also gives this struct a size of 80 bytes. https://github.com/llvm/llvm-project/pull/126774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Store documentation when indexing standard library (PR #133681)
@@ -223,33 +226,26 @@ SymbolSlab indexStandardLibrary(llvm::StringRef HeaderSources, return Symbols; } - SymbolCollector::Options IndexOpts; - IndexOpts.Origin = SymbolOrigin::StdLib; - IndexOpts.CollectMainFileSymbols = false; - IndexOpts.CollectMainFileRefs = false; - IndexOpts.CollectMacro = true; - IndexOpts.StoreAllDocumentation = true; - // Sadly we can't use IndexOpts.FileFilter to restrict indexing scope. - // Files from outside the StdLibLocation may define true std symbols anyway. - // We end up "blessing" such headers, and can only do that by indexing - // everything first. - - // Refs, relations, include graph in the stdlib mostly aren't useful. - auto Action = createStaticIndexingAction( - IndexOpts, [&](SymbolSlab S) { Symbols = std::move(S); }, nullptr, - nullptr, nullptr); - - if (!Action->BeginSourceFile(*Clang, Input)) { + SyntaxOnlyAction Action; + + if (!Action.BeginSourceFile(*Clang, Input)) { elog("Standard Library Index: BeginSourceFile() failed"); return Symbols; } - if (llvm::Error Err = Action->Execute()) { + if (llvm::Error Err = Action.Execute()) { elog("Standard Library Index: Execute failed: {0}", std::move(Err)); return Symbols; } - Action->EndSourceFile(); + // We don't care about include graph for stdlib headers, so provide a no-op + // PI. + include_cleaner::PragmaIncludes PI; + auto Slabs = + indexHeaderSymbols("", Clang->getASTContext(), Clang->getPreprocessor(), + PI, SymbolOrigin::StdLib); + Symbols = std::move(std::get<0>(Slabs)); + Action.EndSourceFile(); HighCommander4 wrote: Added https://github.com/llvm/llvm-project/pull/133681 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Store documentation when indexing standard library (PR #133681)
https://github.com/HighCommander4 updated https://github.com/llvm/llvm-project/pull/133681 >From 451a88947bda87daa5934cc5c2d55f9e57a5cfda Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Mon, 31 Mar 2025 02:25:45 -0400 Subject: [PATCH] [clangd] Store documentation when indexing standard library Fixes https://github.com/clangd/clangd/issues/2344 --- clang-tools-extra/clangd/ClangdServer.h | 3 ++ clang-tools-extra/clangd/index/FileIndex.cpp | 21 ++- clang-tools-extra/clangd/index/FileIndex.h| 3 +- clang-tools-extra/clangd/index/StdLib.cpp | 37 +-- .../clangd/unittests/StdLibTests.cpp | 37 +++ clang-tools-extra/clangd/unittests/TestTU.cpp | 3 +- 6 files changed, 73 insertions(+), 31 deletions(-) diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h index 1e612e2ba618e..4a149688fa494 100644 --- a/clang-tools-extra/clangd/ClangdServer.h +++ b/clang-tools-extra/clangd/ClangdServer.h @@ -466,6 +466,9 @@ class ClangdServer { [[nodiscard]] bool blockUntilIdleForTest(std::optional TimeoutSeconds = 10); + // Expose the (combined) index for test use. + const SymbolIndex *getIndexForTest() { return Index; } + /// Builds a nested representation of memory used by components. void profile(MemoryTree &MT) const; diff --git a/clang-tools-extra/clangd/index/FileIndex.cpp b/clang-tools-extra/clangd/index/FileIndex.cpp index aa573e312a756..de88edd0c7a0b 100644 --- a/clang-tools-extra/clangd/index/FileIndex.cpp +++ b/clang-tools-extra/clangd/index/FileIndex.cpp @@ -48,13 +48,12 @@ SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP, const MainFileMacros *MacroRefsToIndex, const include_cleaner::PragmaIncludes &PI, bool IsIndexMainAST, llvm::StringRef Version, - bool CollectMainFileRefs) { + bool CollectMainFileRefs, SymbolOrigin Origin) { SymbolCollector::Options CollectorOpts; CollectorOpts.CollectIncludePath = true; CollectorOpts.PragmaIncludes = &PI; CollectorOpts.CountReferences = false; - CollectorOpts.Origin = - IsIndexMainAST ? SymbolOrigin::Open : SymbolOrigin::Preamble; + CollectorOpts.Origin = Origin; CollectorOpts.CollectMainFileRefs = CollectMainFileRefs; // We want stdlib implementation details in the index only if we've opened the // file in question. This does means xrefs won't work, though. @@ -221,22 +220,24 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const { } SlabTuple indexMainDecls(ParsedAST &AST) { - return indexSymbols( - AST.getASTContext(), AST.getPreprocessor(), AST.getLocalTopLevelDecls(), - &AST.getMacros(), AST.getPragmaIncludes(), - /*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true); + return indexSymbols(AST.getASTContext(), AST.getPreprocessor(), + AST.getLocalTopLevelDecls(), &AST.getMacros(), + AST.getPragmaIncludes(), + /*IsIndexMainAST=*/true, AST.version(), + /*CollectMainFileRefs=*/true, SymbolOrigin::Open); } SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST, Preprocessor &PP, - const include_cleaner::PragmaIncludes &PI) { + const include_cleaner::PragmaIncludes &PI, + SymbolOrigin Origin) { std::vector DeclsToIndex( AST.getTranslationUnitDecl()->decls().begin(), AST.getTranslationUnitDecl()->decls().end()); return indexSymbols(AST, PP, DeclsToIndex, /*MainFileMacros=*/nullptr, PI, /*IsIndexMainAST=*/false, Version, - /*CollectMainFileRefs=*/false); + /*CollectMainFileRefs=*/false, Origin); } FileSymbols::FileSymbols(IndexContents IdxContents, bool SupportContainedRefs) @@ -463,7 +464,7 @@ void FileIndex::updatePreamble(PathRef Path, llvm::StringRef Version, const include_cleaner::PragmaIncludes &PI) { IndexFileIn IF; std::tie(IF.Symbols, std::ignore, IF.Relations) = - indexHeaderSymbols(Version, AST, PP, PI); + indexHeaderSymbols(Version, AST, PP, PI, SymbolOrigin::Preamble); updatePreamble(std::move(IF)); } diff --git a/clang-tools-extra/clangd/index/FileIndex.h b/clang-tools-extra/clangd/index/FileIndex.h index 8e88dc9712996..86af5ee3723f6 100644 --- a/clang-tools-extra/clangd/index/FileIndex.h +++ b/clang-tools-extra/clangd/index/FileIndex.h @@ -164,7 +164,8 @@ SlabTuple indexMainDecls(ParsedAST &AST); /// included headers. SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST, Preprocessor &PP, - const include_cleaner::PragmaIncludes &PI); + const include_cleaner::Pra
[clang-tools-extra] [clangd] Store documentation when indexing standard library (PR #133681)
@@ -158,6 +158,43 @@ TEST(StdLibTests, EndToEnd) { UnorderedElementsAre(StdlibSymbol("list"), StdlibSymbol("vector"))); } +TEST(StdLibTests, StdLibDocComments) { + Config Cfg; + Cfg.Index.StandardLibrary = true; + WithContextValue Enabled(Config::Key, std::move(Cfg)); + + MockFS FS; + FS.Files["stdlib/vector"] = R"cpp( +namespace std { + template + class vector { + public: +/**doc comment*/ +unsigned int size() const; + }; +} + )cpp"; + MockCompilationDatabase CDB; + CDB.ExtraClangFlags.push_back("-isystem" + testPath("stdlib")); + ClangdServer::Options Opts = ClangdServer::optsForTest(); + Opts.BuildDynamicSymbolIndex = true; // also used for stdlib index + ClangdServer Server(CDB, FS, Opts); + + Annotations A(R"cpp( +#include +void foo() { + std::vector v; + v.si^ze(); +} + )cpp"); + + Server.addDocument(testPath("foo.cc"), A.code()); + ASSERT_TRUE(Server.blockUntilIdleForTest()); HighCommander4 wrote: > IIUC we're testing preamble vs stdlib index depending on which one finishes > first here. Good catch! (I was basing the test on `StdLibTests.EndToEnd`, but that has the important difference of operating on a file with no includes, so there's no preamble index.) > I think we can try with a vector implementation like: > > ```c++ > struct vector { > // This shouldn't be indexed for code-completion, hence static-idx wouldn't > have any docs for it. > struct inner {}; > }; > ``` > > afterwards we can add an empty file to clangd, to make sure we only index > `vector` through stdlib-index and not preabmle. > > afterwards we run a workspace symbol query for `vector::inner` and ensure it > has docs. WDYT? Makes sense, but unfortunately workspace symbols do not include documentation. Instead, I added a function to ClangdServer to expose the index for test use, and ran a FuzzyFind operation on it directly. Let me know if that's reasonable; I'm open to other suggestions if not. https://github.com/llvm/llvm-project/pull/133681 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)
@@ -231,6 +231,13 @@ namespace DeprecatedVolatile { a = c = a; b += a; } + + volatile struct amber jurassic(); Fznamznon wrote: As I can see, if the return type is not a struct/class, the warning is issued. Could you please add a test case with volatile qualifier applied to a basic type (for example int) and make sure there is no double diagnostic issued now? https://github.com/llvm/llvm-project/pull/137899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)
@@ -5056,13 +5056,13 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, S.Diag(DeclType.Loc, diag::err_func_returning_qualified_void) << T; } else diagnoseRedundantReturnTypeQualifiers(S, T, D, chunkIndex); - -// C++2a [dcl.fct]p12: -// A volatile-qualified return type is deprecated -if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20) - S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T; } + // C++2a [dcl.fct]p12: + // A volatile-qualified return type is deprecated + if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20) +S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T; Fznamznon wrote: I see there is another place that issues `warn_deprecated_volatile_return` in `Sema::CheckFunctionReturnType`. I wonder why doesn't it suffice? https://github.com/llvm/llvm-project/pull/137899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)
https://github.com/Fznamznon commented: Thank you for the fix, could you please also add a release note? https://github.com/llvm/llvm-project/pull/137899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)
https://github.com/Fznamznon edited https://github.com/llvm/llvm-project/pull/137899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Support the generic address space (PR #137183)
@@ -23,4 +23,20 @@ #define _CLC_DEF __attribute__((always_inline)) #endif +#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \ +(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \ + defined(__opencl_c_generic_address_space)) +#define _CLC_GENERIC_AS_SUPPORTED 1 +// Note that we hard-code the assumption that a non-distinct address space means +// that the target maps the generic address space to the private address space. +#ifdef __CLC_DISTINCT_GENERIC_ADDRSPACE__ +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1 +#else +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 +#endif +#else arsenm wrote: Even if not this, the current name is misleading. It's not about generic being supported, if anything it's more like private isn't real https://github.com/llvm/llvm-project/pull/137183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch (PR #137932)
https://github.com/frasercrmck approved this pull request. LGTM. I see there's a note in the spec: `async_work_group_copy and async_work_group_strided_copy for 3-component vector types behave as async_work_group_copy and async_work_group_strided_copy respectively for 4-component vector types. `. I'm not sure what that really means for our implementation which does a loop and a store. I also wonder why we have `async/gentype.inc`. With this change, couldn't we just use `float/gentype.inc` and `integer/gentype.inc` in succession? https://github.com/llvm/llvm-project/pull/137932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)
https://github.com/melver edited https://github.com/llvm/llvm-project/pull/137133 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)
https://github.com/melver edited https://github.com/llvm/llvm-project/pull/137133 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NVPTX] Support the OpenCL generic addrspace feature by default (PR #137940)
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/137940 As best as I can see, all NVPTX architectures support the generic address space. I note there's a FIXME in the target's address space map about 'generic' still having to be added to the target but we haven't observed any issues with it downstream. The generic address space is mapped to the same target address space as default/private (0), but this isn't necessarily a problem for users. >From fada7821b0eeb3836ddef143fbff4c78abe4a35b Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 30 Apr 2025 10:13:37 +0100 Subject: [PATCH] [NVPTX] Support the OpenCL generic addrspace feature by default As best as I can see, all NVPTX architectures support the generic address space. I note there's a FIXME in the target's address space map about 'generic' still having to be added to the target but we haven't observed any issues with it downstream. The generic address space is mapped to the same target address space as default/private (0), but this isn't necessarily a problem for users. --- clang/lib/Basic/Targets/NVPTX.h | 2 ++ clang/test/Misc/nvptx.languageOptsOpenCL.cl | 8 2 files changed, 10 insertions(+) diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h index dc1ecc30980b7..fbb46001b0f90 100644 --- a/clang/lib/Basic/Targets/NVPTX.h +++ b/clang/lib/Basic/Targets/NVPTX.h @@ -170,6 +170,8 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo { Opts["cl_khr_global_int32_extended_atomics"] = true; Opts["cl_khr_local_int32_base_atomics"] = true; Opts["cl_khr_local_int32_extended_atomics"] = true; + +Opts["__opencl_c_generic_address_space"] = true; } const llvm::omp::GV &getGridValue() const override { diff --git a/clang/test/Misc/nvptx.languageOptsOpenCL.cl b/clang/test/Misc/nvptx.languageOptsOpenCL.cl index f479dddffb3ab..2610cfafc257b 100644 --- a/clang/test/Misc/nvptx.languageOptsOpenCL.cl +++ b/clang/test/Misc/nvptx.languageOptsOpenCL.cl @@ -132,3 +132,11 @@ #pragma OPENCL EXTENSION cl_khr_subgroups: enable // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}} +#if (__OPENCL_C_VERSION__ >= 300) +#ifndef __opencl_c_generic_address_space +#error "Missing __opencl_c_generic_address_space define" +#else +#error "Incorrect __opencl_c_generic_address_space define" +#endif +#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NVPTX] Support the OpenCL generic addrspace feature by default (PR #137940)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Fraser Cormack (frasercrmck) Changes As best as I can see, all NVPTX architectures support the generic address space. I note there's a FIXME in the target's address space map about 'generic' still having to be added to the target but we haven't observed any issues with it downstream. The generic address space is mapped to the same target address space as default/private (0), but this isn't necessarily a problem for users. --- Full diff: https://github.com/llvm/llvm-project/pull/137940.diff 2 Files Affected: - (modified) clang/lib/Basic/Targets/NVPTX.h (+2) - (modified) clang/test/Misc/nvptx.languageOptsOpenCL.cl (+8) ``diff diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h index dc1ecc30980b7..fbb46001b0f90 100644 --- a/clang/lib/Basic/Targets/NVPTX.h +++ b/clang/lib/Basic/Targets/NVPTX.h @@ -170,6 +170,8 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo { Opts["cl_khr_global_int32_extended_atomics"] = true; Opts["cl_khr_local_int32_base_atomics"] = true; Opts["cl_khr_local_int32_extended_atomics"] = true; + +Opts["__opencl_c_generic_address_space"] = true; } const llvm::omp::GV &getGridValue() const override { diff --git a/clang/test/Misc/nvptx.languageOptsOpenCL.cl b/clang/test/Misc/nvptx.languageOptsOpenCL.cl index f479dddffb3ab..2610cfafc257b 100644 --- a/clang/test/Misc/nvptx.languageOptsOpenCL.cl +++ b/clang/test/Misc/nvptx.languageOptsOpenCL.cl @@ -132,3 +132,11 @@ #pragma OPENCL EXTENSION cl_khr_subgroups: enable // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}} +#if (__OPENCL_C_VERSION__ >= 300) +#ifndef __opencl_c_generic_address_space +#error "Missing __opencl_c_generic_address_space define" +#else +#error "Incorrect __opencl_c_generic_address_space define" +#endif +#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable +#endif `` https://github.com/llvm/llvm-project/pull/137940 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 04aa5a8 - [OMPIRBuilder] Don't discard the debug record from entry block. (#135161)
Author: Abid Qadeer Date: 2025-04-30T10:25:35+01:00 New Revision: 04aa5a88d17f5c1cab7acde2e87de05a405e60f1 URL: https://github.com/llvm/llvm-project/commit/04aa5a88d17f5c1cab7acde2e87de05a405e60f1 DIFF: https://github.com/llvm/llvm-project/commit/04aa5a88d17f5c1cab7acde2e87de05a405e60f1.diff LOG: [OMPIRBuilder] Don't discard the debug record from entry block. (#135161) When we get a function back from `CodeExtractor`, we discard its entry block after coping its instructions into the entry block we prepared. While copying the instructions, the terminator is discarded for obvious reasons. But if there were some debug values attached to the terminator, those are useful and needs to be copied. Added: mlir/test/Target/LLVMIR/omptarget-parallel-llvm-debug.mlir Modified: clang/test/OpenMP/irbuilder_nested_parallel_for.c clang/test/OpenMP/nested_loop_codegen.cpp clang/test/OpenMP/parallel_codegen.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp Removed: diff --git a/clang/test/OpenMP/irbuilder_nested_parallel_for.c b/clang/test/OpenMP/irbuilder_nested_parallel_for.c index ae3570fda412d..5cc5640a5173b 100644 --- a/clang/test/OpenMP/irbuilder_nested_parallel_for.c +++ b/clang/test/OpenMP/irbuilder_nested_parallel_for.c @@ -1679,6 +1679,9 @@ void parallel_for_2(float *r, int a, double b) { // CHECK-DEBUG-NEXT:[[TMP1:%.*]] = load i32, ptr [[TID_ADDR]], align 4 // CHECK-DEBUG-NEXT:store i32 [[TMP1]], ptr [[TID_ADDR_LOCAL]], align 4 // CHECK-DEBUG-NEXT:[[TID:%.*]] = load i32, ptr [[TID_ADDR_LOCAL]], align 4 +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_A_ADDR]], [[META88:![0-9]+]], !DIExpression(), [[META89:![0-9]+]]) +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_B_ADDR]], [[META90:![0-9]+]], !DIExpression(), [[META91:![0-9]+]]) +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_R_ADDR]], [[META92:![0-9]+]], !DIExpression(), [[META93:![0-9]+]]) // CHECK-DEBUG-NEXT:br label [[OMP_PAR_REGION:%.*]] // CHECK-DEBUG: omp.par.region: // CHECK-DEBUG-NEXT:[[OMP_GLOBAL_THREAD_NUM1:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB8:[0-9]+]]), !dbg [[DBG86:![0-9]+]] @@ -1723,6 +1726,9 @@ void parallel_for_2(float *r, int a, double b) { // CHECK-DEBUG-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON_1:%.*]], align 8 // CHECK-DEBUG-NEXT:[[AGG_CAPTURED12:%.*]] = alloca [[STRUCT_ANON_2:%.*]], align 4 // CHECK-DEBUG-NEXT:[[DOTCOUNT_ADDR:%.*]] = alloca i32, align 4 +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_A_ADDR]], [[META102:![0-9]+]], !DIExpression(), [[META103:![0-9]+]]) +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_B_ADDR]], [[META104:![0-9]+]], !DIExpression(), [[META105:![0-9]+]]) +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_R_ADDR]], [[META106:![0-9]+]], !DIExpression(), [[META107:![0-9]+]]) // CHECK-DEBUG-NEXT:br label [[OMP_PAR_REGION5:%.*]] // CHECK-DEBUG: omp.par.region5: // CHECK-DEBUG-NEXT: #dbg_declare(ptr [[I]], [[META94:![0-9]+]], !DIExpression(), [[META99:![0-9]+]]) @@ -1964,6 +1970,9 @@ void parallel_for_2(float *r, int a, double b) { // CHECK-DEBUG-NEXT:[[AGG_CAPTURED161:%.*]] = alloca [[STRUCT_ANON_15:%.*]], align 8 // CHECK-DEBUG-NEXT:[[AGG_CAPTURED162:%.*]] = alloca [[STRUCT_ANON_16:%.*]], align 4 // CHECK-DEBUG-NEXT:[[DOTCOUNT_ADDR163:%.*]] = alloca i32, align 4 +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_A_ADDR]], [[META171:![0-9]+]], !DIExpression(), [[META172:![0-9]+]]) +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_B_ADDR]], [[META173:![0-9]+]], !DIExpression(), [[META174:![0-9]+]]) +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_R_ADDR]], [[META175:![0-9]+]], !DIExpression(), [[META176:![0-9]+]]) // CHECK-DEBUG-NEXT:br label [[OMP_PAR_REGION:%.*]] // CHECK-DEBUG: omp.par.region: // CHECK-DEBUG-NEXT: #dbg_declare(ptr [[I]], [[META157:![0-9]+]], !DIExpression(), [[META161:![0-9]+]]) @@ -2122,6 +2131,9 @@ void parallel_for_2(float *r, int a, double b) { // CHECK-DEBUG-NEXT:[[AGG_CAPTURED136:%.*]] = alloca [[STRUCT_ANON_13:%.*]], align 8 // CHECK-DEBUG-NEXT:[[AGG_CAPTURED137:%.*]] = alloca [[STRUCT_ANON_14:%.*]], align 4 // CHECK-DEBUG-NEXT:[[DOTCOUNT_ADDR138:%.*]] = alloca i32, align 4 +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_A_ADDR]], [[META207:![0-9]+]], !DIExpression(), [[META208:![0-9]+]]) +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_B_ADDR]], [[META209:![0-9]+]], !DIExpression(), [[META210:![0-9]+]]) +// CHECK-DEBUG-NEXT: #dbg_declare(ptr [[LOADGEP_R_ADDR]], [[META211:![0-9]+]], !DIExpression(), [[META212:![0-9]+]]) // CHECK-DEBUG-NEXT:br label [[OMP_PAR_REGION9:%.*]] // CHECK-DEBUG: omp.par.region9: // CHECK-DEBUG-NEXT: #dbg_declare(ptr [[I16]], [[META187:![0-9]+]], !DIExpression(), [[META192:![0-9]+]]) @@ -2322,6 +2334,9 @@ void parallel_
[clang] [llvm] [mlir] [OMPIRBuilder] Don't discard the debug record from entry block. (PR #135161)
https://github.com/abidh closed https://github.com/llvm/llvm-project/pull/135161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Diagnose use of C++ keywords in C (PR #137234)
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/137234 >From 56a3f3cd282e9bd5ef9014e4125380e0d9685121 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 24 Apr 2025 14:17:42 -0400 Subject: [PATCH 01/19] [C] Diagnose use of C++ keywords in C This adds a new diagnostic group, -Widentifier-is-c++-keyword, which is off by default and grouped under -Wc++-compat. The diagnostic catches use of C++ keywords in C code. This change additionally fixes an issue with -Wreserved-identifier not diagnosing use of reserved identifiers in function parameter lists. Partially fixes #21898 --- clang/docs/ReleaseNotes.rst | 3 + clang/include/clang/Basic/DiagnosticGroups.td | 3 +- .../clang/Basic/DiagnosticSemaKinds.td| 3 + clang/include/clang/Basic/IdentifierTable.h | 11 +- clang/lib/Basic/IdentifierTable.cpp | 27 +++ clang/lib/Sema/SemaDecl.cpp | 23 ++ clang/test/Sema/c++-keyword-in-c.c| 213 ++ 7 files changed, 279 insertions(+), 4 deletions(-) create mode 100644 clang/test/Sema/c++-keyword-in-c.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d1f24fb23d44d..57b604335fcdd 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -143,6 +143,9 @@ C Language Changes - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) +- Added ``-Widentifier-is-c++-keyword``, grouped under ``-Wc++-compat``, which + diagnoses when a C++ keyword is used as an identifier in C. Partially + addresses #GH21898. C2y Feature Support ^^^ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 6441b8049ed8d..84e590a857398 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -155,8 +155,9 @@ def C99Compat : DiagGroup<"c99-compat">; def C23Compat : DiagGroup<"c23-compat">; def : DiagGroup<"c2x-compat", [C23Compat]>; +def CppKeywordInC : DiagGroup<"identifier-is-c++-keyword">; def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">; -def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast]>; +def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, CppKeywordInC]>; def ExternCCompat : DiagGroup<"extern-c-compat">; def KeywordCompat : DiagGroup<"keyword-compat">; def GNUCaseRange : DiagGroup<"gnu-case-range">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 8ff170520aafe..50a960313349a 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -496,6 +496,9 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 is not " "%select{used|required to be captured for this use}1">, InGroup, DefaultIgnore; +def warn_identifier_is_cpp_keyword : Warning< + "identifier %0 conflicts with a C++ keyword">, + InGroup, DefaultIgnore; def warn_reserved_extern_symbol: Warning< "identifier %0 is reserved because %select{" "|" // ReservedIdentifierStatus::NotReserved diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index 1275b056227b5..05c989c1b07d9 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -444,13 +444,18 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo { } bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; } - /// Return true if this token is a keyword in the specified language. + /// Return true if this identifier uses a keyword token and is a keyword in + /// the specified language. bool isKeyword(const LangOptions &LangOpts) const; - /// Return true if this token is a C++ keyword in the specified - /// language. + /// Return true if this identifier uses a keyword token and is a C++ keyword + /// in the specified language. bool isCPlusPlusKeyword(const LangOptions &LangOpts) const; + /// Returns true if the name of this identifier matches a keyword given the + /// specified language options. + bool isNameKeyword(const LangOptions &LangOpts) const; + /// Get and set FETokenInfo. The language front-end is allowed to associate /// arbitrary metadata with this token. void *getFETokenInfo() const { return FETokenInfo; } diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 16151c94464f9..412f0af40861a 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -343,6 +343,14 @@ static KeywordStatus getTokenKwStatus(const LangOptions &LangOpts, } } +static KeywordStatus getNameKwStatus(const LangOptions &LangOpts, + StringRef Name)
[clang] [Clang][OpenCL][AMDGPU] OpenCL Kernel stubs should be assigned alwaysinline attribute (PR #137769)
https://github.com/lalaniket8 updated https://github.com/llvm/llvm-project/pull/137769 >From 8fd3b0cafa7ddd260d073232f93e262a6d508d52 Mon Sep 17 00:00:00 2001 From: anikelal Date: Tue, 29 Apr 2025 13:59:48 +0530 Subject: [PATCH] add alwaysinline attribute to stubs --- clang/lib/CodeGen/CodeGenModule.cpp | 13 ++ .../CodeGenOpenCL/amdgpu-enqueue-kernel.cl| 6 ++--- .../test/CodeGenOpenCL/cl-uniform-wg-size.cl | 4 .../CodeGenOpenCL/cl20-device-side-enqueue.cl | 24 +++ clang/test/CodeGenOpenCL/convergent.cl| 9 +++ .../enqueue-kernel-non-entry-block.cl | 11 ++--- 6 files changed, 32 insertions(+), 35 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e917f3c42da06..2daeb6dbc751a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -6174,6 +6174,19 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, CodeGenFunction(*this).GenerateCode(GD, Fn, FI); setNonAliasAttributes(GD, Fn); + + bool ShouldAddOptNone = !CodeGenOpts.DisableO0ImplyOptNone && + (CodeGenOpts.OptimizationLevel == 0) && + !D->hasAttr(); + + if (D->hasAttr()) +if (GD.getKernelReferenceKind() == KernelReferenceKind::Stub && +!D->hasAttr() && +!Fn->hasFnAttribute(llvm::Attribute::NoInline) && +!D->hasAttr() && +!Fn->hasFnAttribute(llvm::Attribute::OptimizeNone) && !ShouldAddOptNone) + Fn->addFnAttr(llvm::Attribute::AlwaysInline); + SetLLVMFunctionAttributesForDefinition(D, Fn); if (const ConstructorAttr *CA = D->getAttr()) diff --git a/clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl b/clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl index 773daf53b2746..a0e11a1b5997e 100644 --- a/clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl +++ b/clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl @@ -492,7 +492,7 @@ kernel void test_target_features_kernel(global int *i) { // GFX900-NEXT:ret void // // -// GFX900: Function Attrs: convergent norecurse nounwind +// GFX900: Function Attrs: alwaysinline convergent norecurse nounwind // GFX900-LABEL: define dso_local void @__clang_ocl_kern_imp_test( // GFX900-SAME: ptr addrspace(1) noundef align 1 [[A:%.*]], i8 noundef signext [[B:%.*]], ptr addrspace(1) noundef align 8 [[C:%.*]], i64 noundef [[D:%.*]]) #[[ATTR3:[0-9]+]] !kernel_arg_addr_space [[META10]] !kernel_arg_access_qual [[META11]] !kernel_arg_type [[META12]] !kernel_arg_base_type [[META12]] !kernel_arg_type_qual [[META13]] { // GFX900-NEXT: [[ENTRY:.*:]] @@ -640,7 +640,7 @@ kernel void test_target_features_kernel(global int *i) { // GFX900-NEXT:ret void // // -// GFX900: Function Attrs: convergent norecurse nounwind +// GFX900: Function Attrs: alwaysinline convergent norecurse nounwind // GFX900-LABEL: define dso_local void @__clang_ocl_kern_imp_test_target_features_kernel( // GFX900-SAME: ptr addrspace(1) noundef align 4 [[I:%.*]]) #[[ATTR3]] !kernel_arg_addr_space [[META22]] !kernel_arg_access_qual [[META23]] !kernel_arg_type [[META24]] !kernel_arg_base_type [[META24]] !kernel_arg_type_qual [[META25]] { // GFX900-NEXT: [[ENTRY:.*:]] @@ -832,7 +832,7 @@ kernel void test_target_features_kernel(global int *i) { // GFX900: attributes #[[ATTR0:[0-9]+]] = { "objc_arc_inert" } // GFX900: attributes #[[ATTR1]] = { convergent norecurse nounwind "denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64,-sram-ecc" } // GFX900: attributes #[[ATTR2]] = { convergent norecurse nounwind "amdgpu-flat-work-group-size"="1,256" "denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64,-sram-ecc" "uniform-work-group-size"="false" } -// GFX900: attributes #[[ATTR3]] = { convergent norecurse nounwind "amdgpu-flat-work-group-size"="1,256" "denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64,-sram-ecc" } +// GFX900: attributes #[[ATTR3]] = { alwaysinline convergent norecurse nounwind "amdgpu-flat-work-group-size"="1,256" "denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64,-sram-ecc" } // GFX900: attributes #[[ATTR4:[0-9]+]] = { nocallback nofree
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)
https://github.com/ravurvi20 updated https://github.com/llvm/llvm-project/pull/128640 >From 6ebd5991788608fbd104ea9c23230912044462d3 Mon Sep 17 00:00:00 2001 From: Urvi Rav Date: Tue, 25 Feb 2025 00:49:07 -0600 Subject: [PATCH 1/7] default clause replaced by otherwise clause for metadirective --- .../clang/Basic/DiagnosticParseKinds.td | 4 ++ clang/lib/Parse/ParseOpenMP.cpp | 20 ++ clang/test/OpenMP/metadirective_messages.cpp | 61 +-- 3 files changed, 68 insertions(+), 17 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index c513dab810d1f..4b8449e9ee9b6 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1657,6 +1657,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">; def err_omp_missing_comma : Error< "missing ',' after %0">; def err_omp_expected_context_selector : Error<"expected valid context selector in %0">; +def err_omp_unknown_clause +: Error<"unknown clause '%0' in %1">; +def warn_omp_default_deprecated : Warning<"'default' clause for" + " 'metadirective' is deprecated; use 'otherwise' instead">, InGroup; def err_omp_requires_out_inout_depend_type : Error< "reserved locator 'omp_all_memory' requires 'out' or 'inout' " "dependency types">; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 42e6aac681c1c..3b86847e937a2 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2759,6 +2759,19 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( OpenMPClauseKind CKind = Tok.isAnnotation() ? OMPC_unknown : getOpenMPClauseKind(PP.getSpelling(Tok)); + // Check if the clause is unrecognized. + if (getLangOpts().OpenMP < 52 && + (CKind == OMPC_unknown || CKind == OMPC_otherwise)) { +Diag(Tok, diag::err_omp_unknown_clause) +<< PP.getSpelling(Tok) << "metadirective"; + } + if (getLangOpts().OpenMP >= 52 && CKind == OMPC_unknown) { +Diag(Tok, diag::err_omp_unknown_clause) +<< PP.getSpelling(Tok) << "metadirective"; + } + if (CKind == OMPC_default && getLangOpts().OpenMP >= 52) { +Diag(Tok, diag::warn_omp_default_deprecated); + } SourceLocation Loc = ConsumeToken(); // Parse '('. @@ -2785,6 +2798,13 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( return Directive; } } + if (CKind == OMPC_otherwise) { +// Check for 'otherwise' keyword. +if (Tok.is(tok::identifier) && +Tok.getIdentifierInfo()->getName() == "otherwise") { + ConsumeToken(); // Consume 'otherwise' +} + } // Skip Directive for now. We will parse directive in the second iteration int paren = 0; while (Tok.isNot(tok::r_paren) || paren != 0) { diff --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp index 7fce9fa446058..40ea37845fdff 100644 --- a/clang/test/OpenMP/metadirective_messages.cpp +++ b/clang/test/OpenMP/metadirective_messages.cpp @@ -2,21 +2,48 @@ // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify -fopenmp-simd -x c++ -std=c++14 -fexceptions -fcxx-exceptions %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 100 -o - %s -Wuninitialized + void foo() { -#pragma omp metadirective // expected-error {{expected expression}} - ; -#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'target_device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}} - ; -#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} - ; -#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}} - ; -#pragma omp metadirective when(device{arch(nvptx)}: ) default() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} - ; -#pragma omp metadirective when(device
[clang] [clang] ownership_returns attribute takes no more than 2 arguments (PR #137897)
el-ev wrote: ### Merge activity * **Apr 30, 7:27 AM EDT**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/137897). https://github.com/llvm/llvm-project/pull/137897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6dfd354 - [clang] ownership_returns attribute takes no more than 2 arguments (#137897)
Author: halbi2 Date: 2025-04-30T19:29:37+08:00 New Revision: 6dfd35457123089b3506899c8bc522f3dfa6e959 URL: https://github.com/llvm/llvm-project/commit/6dfd35457123089b3506899c8bc522f3dfa6e959 DIFF: https://github.com/llvm/llvm-project/commit/6dfd35457123089b3506899c8bc522f3dfa6e959.diff LOG: [clang] ownership_returns attribute takes no more than 2 arguments (#137897) Added: Modified: clang/lib/Sema/SemaDeclAttr.cpp clang/test/Sema/attr-ownership.c Removed: diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 413999b95b998..8499141c30bce 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1483,7 +1483,7 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { break; case OwnershipAttr::Returns: if (AL.getNumArgs() > 2) { - S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1; + S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 2; return; } break; diff --git a/clang/test/Sema/attr-ownership.c b/clang/test/Sema/attr-ownership.c index d2e40538a40f0..515428d7d6c44 100644 --- a/clang/test/Sema/attr-ownership.c +++ b/clang/test/Sema/attr-ownership.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -Wno-strict-prototypes void f1(void) __attribute__((ownership_takes("foo"))); // expected-error {{'ownership_takes' attribute requires parameter 1 to be an identifier}} -void *f2(void) __attribute__((ownership_returns(foo, 1, 2))); // expected-error {{'ownership_returns' attribute takes no more than 1 argument}} +void *f2(void) __attribute__((ownership_returns(foo, 1, 2))); // expected-error {{'ownership_returns' attribute takes no more than 2 arguments}} void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}} void *f4(void) __attribute__((ownership_returns(foo))); void f5(void) __attribute__((ownership_holds(foo))); // expected-error {{'ownership_holds' attribute takes at least 2 arguments}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] ownership_returns attribute takes no more than 2 arguments (PR #137897)
https://github.com/el-ev closed https://github.com/llvm/llvm-project/pull/137897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Clean up unnecessary #undef __CLC_BODYs (PR #137959)
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/137959 This macro is automatically undefined by the various gentype-like helpers. >From ef6433ffa32a8f4ced865382bfd45de61f5aef53 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 30 Apr 2025 13:48:16 +0100 Subject: [PATCH] [libclc] Clean up unnecessary #undef __CLC_BODYs This macro is automatically undefined by the various gentype-like helpers. --- libclc/clc/include/clc/common/clc_degrees.h | 1 - libclc/clc/include/clc/common/clc_radians.h | 1 - libclc/clc/include/clc/common/clc_sign.h | 1 - libclc/clc/include/clc/common/clc_smoothstep.h| 1 - libclc/clc/include/clc/integer/clc_add_sat.h | 1 - libclc/clc/include/clc/integer/clc_clz.h | 1 - libclc/clc/include/clc/integer/clc_ctz.h | 1 - libclc/clc/include/clc/integer/clc_hadd.h | 1 - libclc/clc/include/clc/integer/clc_mad24.h| 1 - libclc/clc/include/clc/integer/clc_mad_sat.h | 1 - libclc/clc/include/clc/integer/clc_mul24.h| 1 - libclc/clc/include/clc/integer/clc_mul_hi.h | 1 - libclc/clc/include/clc/integer/clc_rhadd.h| 1 - libclc/clc/include/clc/integer/clc_rotate.h | 1 - libclc/clc/include/clc/integer/clc_sub_sat.h | 1 - libclc/clc/include/clc/internal/math/clc_sw_fma.h | 1 - libclc/clc/include/clc/math/clc_acos.h| 1 - libclc/clc/include/clc/math/clc_acosh.h | 1 - libclc/clc/include/clc/math/clc_acospi.h | 1 - libclc/clc/include/clc/math/clc_asin.h| 1 - libclc/clc/include/clc/math/clc_asinh.h | 1 - libclc/clc/include/clc/math/clc_asinpi.h | 1 - libclc/clc/include/clc/math/clc_atan.h| 1 - libclc/clc/include/clc/math/clc_atan2.h | 1 - libclc/clc/include/clc/math/clc_atan2pi.h | 1 - libclc/clc/include/clc/math/clc_atanh.h | 1 - libclc/clc/include/clc/math/clc_atanpi.h | 1 - libclc/clc/include/clc/math/clc_cbrt.inc | 1 - libclc/clc/include/clc/math/clc_ceil.h| 1 - libclc/clc/include/clc/math/clc_copysign.h| 1 - libclc/clc/include/clc/math/clc_cosh.h| 1 - libclc/clc/include/clc/math/clc_cospi.h | 1 - libclc/clc/include/clc/math/clc_exp.h | 1 - libclc/clc/include/clc/math/clc_exp10.h | 1 - libclc/clc/include/clc/math/clc_exp2.h| 1 - libclc/clc/include/clc/math/clc_exp_helper.h | 1 - libclc/clc/include/clc/math/clc_expm1.h | 1 - libclc/clc/include/clc/math/clc_fabs.h| 1 - libclc/clc/include/clc/math/clc_fdim.h| 1 - libclc/clc/include/clc/math/clc_floor.h | 1 - libclc/clc/include/clc/math/clc_fma.h | 1 - libclc/clc/include/clc/math/clc_fmax.h| 1 - libclc/clc/include/clc/math/clc_fmin.h| 1 - libclc/clc/include/clc/math/clc_fmod.h| 1 - libclc/clc/include/clc/math/clc_fract.h | 1 - libclc/clc/include/clc/math/clc_frexp.h | 1 - libclc/clc/include/clc/math/clc_hypot.h | 1 - libclc/clc/include/clc/math/clc_lgamma.h | 1 - libclc/clc/include/clc/math/clc_lgamma_r.h| 1 - libclc/clc/include/clc/math/clc_log.h | 1 - libclc/clc/include/clc/math/clc_log10.h | 1 - libclc/clc/include/clc/math/clc_log1p.h | 1 - libclc/clc/include/clc/math/clc_log2.h| 1 - libclc/clc/include/clc/math/clc_mad.h | 1 - libclc/clc/include/clc/math/clc_modf.h| 1 - libclc/clc/include/clc/math/clc_nan.h | 1 - libclc/clc/include/clc/math/clc_native_cos.h | 1 - libclc/clc/include/clc/math/clc_native_divide.h | 1 - libclc/clc/include/clc/math/clc_native_exp.h | 1 - libclc/clc/include/clc/math/clc_native_exp10.h| 1 - libclc/clc/include/clc/math/clc_native_exp2.h | 1 - libclc/clc/include/clc/math/clc_native_log.h | 1 - libclc/clc/include/clc/math/clc_native_log10.h| 1 - libclc/clc/include/clc/math/clc_native_log2.h | 1 - libclc/clc/include/clc/math/clc_native_powr.h | 1 - libclc/clc/include/clc/math/clc_native_recip.h| 1 -
[clang] [Clang][AArch64] make bitperm intrinsics available in streaming mode (PR #129700)
https://github.com/CarolineConcatto approved this pull request. https://github.com/llvm/llvm-project/pull/129700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/137958 >From 2d3db51939ec6ca2dfb2e327bce0f33bd2532ff9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 30 Apr 2025 13:00:19 +0200 Subject: [PATCH] [IR] Do not store Function inside BlockAddress Currently BlockAddresses store both the Function and the BasicBlock they reference, and the BlockAddress is part of the use list of both the Function and BasicBlock. This is quite awkward, because this is not really a use of the function itself (and walks of function uses generally skip block addresses for that reason). This also has weird implications on function RAUW (as that will replace the function in block addresses in a way that generally doesn't make sense), and causes other peculiar issues, like the ability to have multiple block addresses for one block (with different functions). Instead, I believe it makes more sense to specify only the basic block and let the function be implied by the BB parent. This does mean that we may have block addresses without a function (if the BB is not inserted), but this should only happen during IR construction. --- clang/lib/CodeGen/CodeGenFunction.cpp | 2 +- llvm/include/llvm/IR/Constants.h | 15 +++-- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp| 4 -- llvm/lib/IR/Constants.cpp | 56 +++ llvm/lib/IR/Function.cpp | 10 +--- llvm/lib/IR/LLVMContextImpl.h | 3 +- llvm/lib/Transforms/IPO/Attributor.cpp| 11 llvm/lib/Transforms/IPO/GlobalOpt.cpp | 24 +--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp| 6 +- llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 5 +- llvm/lib/Transforms/IPO/PartialInlining.cpp | 7 --- llvm/lib/Transforms/IPO/SCCP.cpp | 9 ++- ...e-functions-blockaddress-wrong-function.ll | 4 +- .../reduce-functions-blockaddress.ll | 9 ++- .../llvm-reduce/deltas/ReduceFunctions.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Utils.cpp | 6 -- llvm/tools/llvm-reduce/deltas/Utils.h | 1 - 18 files changed, 52 insertions(+), 124 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 4d29ceace646f..d773cdd505ff4 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2286,7 +2286,7 @@ llvm::BlockAddress *CodeGenFunction::GetAddrOfLabel(const LabelDecl *L) { // Make sure the indirect branch includes all of the address-taken blocks. IndirectBranch->addDestination(BB); - return llvm::BlockAddress::get(CurFn, BB); + return llvm::BlockAddress::get(CurFn->getType(), BB); } llvm::BasicBlock *CodeGenFunction::GetIndirectGotoBlock() { diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index a50217078d0ed..4525d8a6ed1e2 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -893,9 +893,9 @@ class ConstantTargetNone final : public ConstantData { class BlockAddress final : public Constant { friend class Constant; - constexpr static IntrusiveOperandsAllocMarker AllocMarker{2}; + constexpr static IntrusiveOperandsAllocMarker AllocMarker{1}; - BlockAddress(Function *F, BasicBlock *BB); + BlockAddress(Type *Ty, BasicBlock *BB); void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -912,6 +912,11 @@ class BlockAddress final : public Constant { /// block must be embedded into a function. static BlockAddress *get(BasicBlock *BB); + /// Return a BlockAddress for the specified basic block, which may not be + /// part of a function. The specified type must match the type of the function + /// the block will be inserted into. + static BlockAddress *get(Type *Ty, BasicBlock *BB); + /// Lookup an existing \c BlockAddress constant for the given BasicBlock. /// /// \returns 0 if \c !BB->hasAddressTaken(), otherwise the \c BlockAddress. @@ -920,8 +925,8 @@ class BlockAddress final : public Constant { /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - Function *getFunction() const { return (Function *)Op<0>().get(); } - BasicBlock *getBasicBlock() const { return (BasicBlock *)Op<1>().get(); } + BasicBlock *getBasicBlock() const { return (BasicBlock *)Op<0>().get(); } + Function *getFunction() const { return getBasicBlock()->getParent(); } /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -931,7 +936,7 @@ class BlockAddress final : public Constant { template <> struct OperandTraits -: public FixedNumOperandTraits {}; +: public FixedNumOperandTraits {}; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BlockAddress, Value) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/Bitcode
[clang] Fix crash when an attribute is applied to pragma attribute/pragma dump (PR #137880)
https://github.com/AaronBallman approved this pull request. LGTM, but the changes should come with a release note, right? https://github.com/llvm/llvm-project/pull/137880 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
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 HEAD~1 HEAD --extensions cpp,h -- clang/lib/CodeGen/CodeGenFunction.cpp llvm/include/llvm/IR/Constants.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp llvm/lib/IR/Constants.cpp llvm/lib/IR/Function.cpp llvm/lib/IR/LLVMContextImpl.h llvm/lib/Transforms/IPO/Attributor.cpp llvm/lib/Transforms/IPO/GlobalOpt.cpp llvm/lib/Transforms/IPO/LowerTypeTests.cpp llvm/lib/Transforms/IPO/OpenMPOpt.cpp llvm/lib/Transforms/IPO/PartialInlining.cpp llvm/lib/Transforms/IPO/SCCP.cpp llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp llvm/tools/llvm-reduce/deltas/Utils.cpp llvm/tools/llvm-reduce/deltas/Utils.h `` View the diff from clang-format here. ``diff diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 6bfab0917..49107a421 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1925,8 +1925,7 @@ BlockAddress *BlockAddress::lookup(const BasicBlock *BB) { /// Remove the constant from the constant table. void BlockAddress::destroyConstantImpl() { - getType()->getContext().pImpl->BlockAddresses.erase( - getBasicBlock()); + getType()->getContext().pImpl->BlockAddresses.erase(getBasicBlock()); getBasicBlock()->AdjustBlockAddressRefCount(-1); } `` https://github.com/llvm/llvm-project/pull/137958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Clean up unnecessary #undef __CLC_BODYs (PR #137959)
frasercrmck wrote: CC @wenju-he https://github.com/llvm/llvm-project/pull/137959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenCL][AMDGPU] OpenCL Kernel stubs should be assigned alwaysinline attribute (PR #137769)
yxsamliu wrote: > > In practice this should be a single use of an internal function and should > > not require this hint. Is this papering over a different issue? > > Why do you think it is an internal function? I thought it's an externally > callable stub. Agree. OpenCL allows calling an external kernel function https://godbolt.org/z/ThPKfxKqo so the stub function should have external linkage. https://github.com/llvm/llvm-project/pull/137769 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] make bitperm intrinsics available in streaming mode (PR #129700)
https://github.com/Lukacma updated https://github.com/llvm/llvm-project/pull/129700 >From 4b7b5a05b918e644559319f10e6635643a2ee2e7 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Tue, 4 Mar 2025 12:48:19 + Subject: [PATCH] [Clang][AArch64] update bitperm intrinsics to be available in streaming mode --- clang/include/clang/Basic/arm_sve.td | 14 +-- .../AArch64/sve2-intrinsics/acle_sve2_bdep.c | 24 +++-- .../AArch64/sve2-intrinsics/acle_sve2_bext.c | 24 +++-- .../AArch64/sve2-intrinsics/acle_sve2_bgrp.c | 24 +++-- .../acle_sve2_aes_bitperm_sha3_sm4.cpp| 96 +-- 5 files changed, 103 insertions(+), 79 deletions(-) diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index b51106fa56759..03051362be4f9 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -1988,13 +1988,13 @@ def SVSM4E: SInst<"svsm4e[_{d}]","ddd", "Ui", MergeNone, "aarch64_sve_sm def SVSM4EKEY : SInst<"svsm4ekey[_{d}]", "ddd", "Ui", MergeNone, "aarch64_sve_sm4ekey", [IsOverloadNone]>; } -let SVETargetGuard = "sve2,sve-bitperm", SMETargetGuard = InvalidMode in { -def SVBDEP : SInst<"svbdep[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sve_bdep_x">; -def SVBDEP_N : SInst<"svbdep[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sve_bdep_x">; -def SVBEXT : SInst<"svbext[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sve_bext_x">; -def SVBEXT_N : SInst<"svbext[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sve_bext_x">; -def SVBGRP : SInst<"svbgrp[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sve_bgrp_x">; -def SVBGRP_N : SInst<"svbgrp[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sve_bgrp_x">; +let SVETargetGuard = "sve2,sve-bitperm", SMETargetGuard = "sme,ssve-bitperm" in { +def SVBDEP : SInst<"svbdep[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sve_bdep_x", [VerifyRuntimeMode]>; +def SVBDEP_N : SInst<"svbdep[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sve_bdep_x", [VerifyRuntimeMode]>; +def SVBEXT : SInst<"svbext[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sve_bext_x", [VerifyRuntimeMode]>; +def SVBEXT_N : SInst<"svbext[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sve_bext_x", [VerifyRuntimeMode]>; +def SVBGRP : SInst<"svbgrp[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sve_bgrp_x", [VerifyRuntimeMode]>; +def SVBGRP_N : SInst<"svbgrp[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sve_bgrp_x", [VerifyRuntimeMode]>; } let SVETargetGuard = "sve2p1", SMETargetGuard = "sme" in { diff --git a/clang/test/CodeGen/AArch64/sve2-intrinsics/acle_sve2_bdep.c b/clang/test/CodeGen/AArch64/sve2-intrinsics/acle_sve2_bdep.c index d4681394a0508..484a00af04cba 100644 --- a/clang/test/CodeGen/AArch64/sve2-intrinsics/acle_sve2_bdep.c +++ b/clang/test/CodeGen/AArch64/sve2-intrinsics/acle_sve2_bdep.c @@ -5,6 +5,8 @@ // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64 -target-feature +sve -target-feature +sve2 -target-feature +sve-bitperm -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK // RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -target-feature +sve2 -target-feature +sve-bitperm -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -target-feature +sve2 -target-feature +sve-bitperm -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +ssve-bitperm -S -disable-O0-optnone -Werror -Wall -o /dev/null %s +// RUN: not %clang_cc1 -triple aarch64 -target-feature +sme -S -disable-O0-optnone -Werror -Wall -o /dev/null %s #include @@ -15,6 +17,12 @@ #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 #endif +#ifdef __ARM_FEATURE_SME +#define STREAMING __arm_streaming +#else +#define STREAMING +#endif + // CHECK-LABEL: @test_svbdep_u8( // CHECK-NEXT: entry: // CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.bdep.x.nxv16i8( [[OP1:%.*]], [[OP2:%.*]]) @@ -25,7 +33,7 @@ // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.bdep.x.nxv16i8( [[OP1:%.*]], [[OP2:%.*]]) // CPP-CHECK-NEXT:ret [[TMP0]] // -svuint8_t test_svbdep_u8(svuint8_t op1, svuint8_t op2) +svuint8_t test_svbdep_u8(svuint8_t op1, svuint8_t op2) STREAMING { return SVE_ACLE_FUNC(svbdep,_u8,,)(op1, op2); } @@ -40,7 +48,7 @@ svuint8_t test_svbdep_u8(svuint8_t op1, svuint8_t op2) // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.bdep.x.nxv8i16( [[OP1:%.*]], [[OP2:%.*]]) // CPP-CHECK-NEXT:ret [[TMP0]] // -svuint16_t test_svbdep_u16(svuint16_t op1, svuint16_t op2) +svuint16_t test_svbdep_u16(svuint16_t op1, svuint16_t op2) STREAMING { return SVE_ACLE_FUNC(svbdep,_u16,,)(op1, op2); } @@ -55,7 +63,7 @@ svuint16_t test_svbdep
[clang] [clang] Merge gtest binaries into AllClangUnitTests (PR #134196)
nico wrote: `BasicTests` and `FormatTests` had fairly few deps (they didn't need Sema etc) and compiled much fewer files than they presumably now do. Does it make sense to keep those as distinct binaries? https://github.com/llvm/llvm-project/pull/134196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Clean up unnecessary #undef __CLC_BODYs (PR #137959)
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 HEAD~1 HEAD --extensions inc,h,cl -- libclc/clc/include/clc/common/clc_degrees.h libclc/clc/include/clc/common/clc_radians.h libclc/clc/include/clc/common/clc_sign.h libclc/clc/include/clc/common/clc_smoothstep.h libclc/clc/include/clc/integer/clc_add_sat.h libclc/clc/include/clc/integer/clc_clz.h libclc/clc/include/clc/integer/clc_ctz.h libclc/clc/include/clc/integer/clc_hadd.h libclc/clc/include/clc/integer/clc_mad24.h libclc/clc/include/clc/integer/clc_mad_sat.h libclc/clc/include/clc/integer/clc_mul24.h libclc/clc/include/clc/integer/clc_mul_hi.h libclc/clc/include/clc/integer/clc_rhadd.h libclc/clc/include/clc/integer/clc_rotate.h libclc/clc/include/clc/integer/clc_sub_sat.h libclc/clc/include/clc/internal/math/clc_sw_fma.h libclc/clc/include/clc/math/clc_acos.h libclc/clc/include/clc/math/clc_acosh.h libclc/clc/include/clc/math/clc_acospi.h libclc/clc/include/clc/math/clc_asin.h libclc/clc/include/clc/math/clc_asinh.h libclc/clc/include/clc/math/clc_asinpi.h libclc/clc/include/clc/math/clc_atan.h libclc/clc/include/clc/math/clc_atan2.h libclc/clc/include/clc/math/clc_atan2pi.h libclc/clc/include/clc/math/clc_atanh.h libclc/clc/include/clc/math/clc_atanpi.h libclc/clc/include/clc/math/clc_cbrt.inc libclc/clc/include/clc/math/clc_ceil.h libclc/clc/include/clc/math/clc_copysign.h libclc/clc/include/clc/math/clc_cosh.h libclc/clc/include/clc/math/clc_cospi.h libclc/clc/include/clc/math/clc_exp.h libclc/clc/include/clc/math/clc_exp10.h libclc/clc/include/clc/math/clc_exp2.h libclc/clc/include/clc/math/clc_exp_helper.h libclc/clc/include/clc/math/clc_expm1.h libclc/clc/include/clc/math/clc_fabs.h libclc/clc/include/clc/math/clc_fdim.h libclc/clc/include/clc/math/clc_floor.h libclc/clc/include/clc/math/clc_fma.h libclc/clc/include/clc/math/clc_fmax.h libclc/clc/include/clc/math/clc_fmin.h libclc/clc/include/clc/math/clc_fmod.h libclc/clc/include/clc/math/clc_fract.h libclc/clc/include/clc/math/clc_frexp.h libclc/clc/include/clc/math/clc_hypot.h libclc/clc/include/clc/math/clc_lgamma.h libclc/clc/include/clc/math/clc_lgamma_r.h libclc/clc/include/clc/math/clc_log.h libclc/clc/include/clc/math/clc_log10.h libclc/clc/include/clc/math/clc_log1p.h libclc/clc/include/clc/math/clc_log2.h libclc/clc/include/clc/math/clc_mad.h libclc/clc/include/clc/math/clc_modf.h libclc/clc/include/clc/math/clc_nan.h libclc/clc/include/clc/math/clc_native_cos.h libclc/clc/include/clc/math/clc_native_divide.h libclc/clc/include/clc/math/clc_native_exp.h libclc/clc/include/clc/math/clc_native_exp10.h libclc/clc/include/clc/math/clc_native_exp2.h libclc/clc/include/clc/math/clc_native_log.h libclc/clc/include/clc/math/clc_native_log10.h libclc/clc/include/clc/math/clc_native_log2.h libclc/clc/include/clc/math/clc_native_powr.h libclc/clc/include/clc/math/clc_native_recip.h libclc/clc/include/clc/math/clc_native_rsqrt.h libclc/clc/include/clc/math/clc_native_sin.h libclc/clc/include/clc/math/clc_native_sqrt.h libclc/clc/include/clc/math/clc_native_tan.h libclc/clc/include/clc/math/clc_nextafter.h libclc/clc/include/clc/math/clc_pow.h libclc/clc/include/clc/math/clc_pown.h libclc/clc/include/clc/math/clc_powr.h libclc/clc/include/clc/math/clc_remainder.h libclc/clc/include/clc/math/clc_remquo.h libclc/clc/include/clc/math/clc_rint.h libclc/clc/include/clc/math/clc_rootn.h libclc/clc/include/clc/math/clc_round.h libclc/clc/include/clc/math/clc_rsqrt.h libclc/clc/include/clc/math/clc_sincos_helpers.h libclc/clc/include/clc/math/clc_sinh.h libclc/clc/include/clc/math/clc_sinpi.h libclc/clc/include/clc/math/clc_sqrt.h libclc/clc/include/clc/math/clc_tanh.h libclc/clc/include/clc/math/clc_tanpi.h libclc/clc/include/clc/math/clc_tgamma.h libclc/clc/include/clc/math/clc_trunc.h libclc/clc/include/clc/relational/clc_bitselect.h libclc/clc/include/clc/relational/clc_isfinite.h libclc/clc/include/clc/relational/clc_isgreater.h libclc/clc/include/clc/relational/clc_isgreaterequal.h libclc/clc/include/clc/relational/clc_isless.h libclc/clc/include/clc/relational/clc_islessequal.h libclc/clc/include/clc/relational/clc_islessgreater.h libclc/clc/include/clc/relational/clc_isnormal.h libclc/clc/include/clc/relational/clc_isnotequal.h libclc/clc/include/clc/relational/clc_isordered.h libclc/clc/include/clc/relational/clc_isunordered.h libclc/clc/include/clc/relational/clc_signbit.h libclc/clc/lib/generic/math/clc_hypot.cl libclc/clc/lib/generic/relational/clc_bitselect.cl libclc/clspv/lib/shared/vstore_half.cl libclc/generic/include/clc/async/async_work_group_copy.h libclc/generic/include/clc/async/async_work_group_strided_copy.h libclc/generic/include/clc/async/prefetch.h libclc/generic/include/clc/common/degrees.h libclc/generic/include/clc/common/radia
[clang] [clang] Merge gtest binaries into AllClangUnitTests (PR #134196)
@@ -304,7 +304,7 @@ getCodeModel(const CodeGenOptions &CodeGenOpts) { .Case("kernel", llvm::CodeModel::Kernel) .Case("medium", llvm::CodeModel::Medium) .Case("large", llvm::CodeModel::Large) - .Case("default", ~1u) + .Cases("default", "", ~1u) nico wrote: I was going to ask about this: Why do FrontendTests now have to call `llvm::InitializeAllTargetMCs();`? They used to not depend on llvm/lib/Target at all. Why is this needed now that that code gets linked into a bigger binary? https://github.com/llvm/llvm-project/pull/134196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Modify -Wdefault-const-init (PR #137961)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes Post-commit review feedback on https://github.com/llvm/llvm-project/pull/137166 raised a concern from the Linux kernel about wanting to silence the new diagnostic when the uninitialized object is a const member of a structure. These members can be initialized later if the containing object is non-const, such as through a call to memset, for example. This splits the diagnostic groups into: ``` -Wc++-compat -Wdefault-const-init -Wdefault-const-init-field -Wdefault-const-init-var -Wdefault-const-init-unsafe -Wdefault-const-init-field-unsafe -Wdefault-const-init-var-unsafe ``` --- Full diff: https://github.com/llvm/llvm-project/pull/137961.diff 7 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+10-6) - (modified) clang/include/clang/Basic/DiagnosticGroups.td (+10-2) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+12-6) - (modified) clang/lib/Sema/Sema.cpp (+1-1) - (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) - (modified) clang/lib/Sema/SemaInit.cpp (+3-3) - (modified) clang/test/Sema/warn-default-const-init.c (+14-19) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index bc68bb8b70b3d..4fb606afc0f14 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -141,12 +141,16 @@ C Language Changes function type in Microsoft compatibility mode. #GH124869 - Clang now allows ``restrict`` qualifier for array types with pointer elements (#GH92847). - Clang now diagnoses ``const``-qualified object definitions without an - initializer. If the object is zero-initialized, it will be diagnosed under - the new warning ``-Wdefault-const-init`` (which is grouped under - ``-Wc++-compat`` because this construct is not compatible with C++). If the - object is left uninitialized, it will be diagnosed unsed the new warning - ``-Wdefault-const-init-unsafe`` (which is grouped under - ``-Wdefault-const-init``). #GH19297 + initializer. If the object is a variable or field which is zero-initialized, + it will be diagnosed under the new warning ``-Wdefault-const-init-var`` or + ``-Wdefault-const-init-field``, respectively. Similarly, if the variable or + field is not zero-initialized, it will be diagnosed under the new diagnostic + ``-Wdefault-const-init-var-unsafe`` or ``-Wdefault-const-init-field-unsafe``, + respectively. The unsafe diagnostic variants are grouped under a new + diagnostic ``-Wdefault-const-init-unsafe``, which itself is grouped under the + new diagnostic ``-Wdefault-const-init``. Finally, ``-Wdefault-const-init`` is + grouped under ``-Wc++-compat`` because these constructs are not compatible + with C++. #GH19297 - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index fc1ce197ef134..3835cd7251488 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -157,8 +157,16 @@ def C99Compat : DiagGroup<"c99-compat">; def C23Compat : DiagGroup<"c23-compat">; def : DiagGroup<"c2x-compat", [C23Compat]>; def HiddenCppDecl : DiagGroup<"c++-hidden-decl">; -def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe">; -def DefaultConstInit : DiagGroup<"default-const-init", [DefaultConstInitUnsafe]>; +def DefaultConstInitFieldUnsafe : DiagGroup<"default-const-init-field-unsafe">; +def DefaultConstInitVarUnsafe : DiagGroup<"default-const-init-var-unsafe">; +def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe", + [DefaultConstInitFieldUnsafe, +DefaultConstInitVarUnsafe]>; +def DefaultConstInitField : DiagGroup<"default-const-init-field">; +def DefaultConstInitVar : DiagGroup<"default-const-init-var">; +def DefaultConstInit : DiagGroup<"default-const-init", + [DefaultConstInitField, DefaultConstInitVar, + DefaultConstInitUnsafe]>; def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">; def ImplicitIntToEnumCast : DiagGroup<"implicit-int-enum-cast", [ImplicitEnumEnumCast]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index ad5bf26be2590..90a7cac9df29e 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8206,14 +8206,20 @@ def err_address_space_qualified_delete : Error< def note_default_init_const_member : Note< "member %0 declared 'const' here">; +def warn_default_init_const_field : Warning< + "default initialization of an object of typ
[clang] [C] Warn on uninitialized const objects (PR #137166)
AaronBallman wrote: > > This case might be reasonable to handle differently, but I'm on the fence > > too. There's two cases for structure members, broadly: > > > > 1. Don't initialize the `const` field, don't ever read the `const` field. > > 2. Rely on the fact that you can overwrite a `const` if the top-level > > object was not declared `const`. > > Yes, this appears to be the case for the 10 or so unique cases that I found > in the kernel. > > > In both cases, the code is valid and so the warning is a false positive. In > > both cases, the code is dangerous and the warning is useful. So I kind of > > think this is a case where we split the field diagnostic out into its own > > group. So we'd have `-Wdefault-const-init-field` which covers field > > initialization cases, and it would be grouped under `-Wdefault-const-init` > > which covers both fields and variables. WDYT? > > Yes, that seems like a reasonable place to start. I would be happy to test > such a change. https://github.com/llvm/llvm-project/pull/137961 should hopefully address your concerns https://github.com/llvm/llvm-project/pull/137166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Modify -Wdefault-const-init (PR #137961)
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/137961 Post-commit review feedback on https://github.com/llvm/llvm-project/pull/137166 raised a concern from the Linux kernel about wanting to silence the new diagnostic when the uninitialized object is a const member of a structure. These members can be initialized later if the containing object is non-const, such as through a call to memset, for example. This splits the diagnostic groups into: ``` -Wc++-compat -Wdefault-const-init -Wdefault-const-init-field -Wdefault-const-init-var -Wdefault-const-init-unsafe -Wdefault-const-init-field-unsafe -Wdefault-const-init-var-unsafe ``` >From d331697715977eca37197f25bac31b4724ffefee Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 30 Apr 2025 08:57:48 -0400 Subject: [PATCH] [C] Modify -Wdefault-const-init Post-commit review feedback on https://github.com/llvm/llvm-project/pull/137166 raised a concern from the Linux kernel about wanting to silence the new diagnostic when the uninitialized object is a const member of a structure. These members can be initialized later if the containing object is non-const, such as through a call to memset, for example. This splits the diagnostic groups into: -Wc++-compat -Wdefault-const-init -Wdefault-const-init-field -Wdefault-const-init-var -Wdefault-const-init-unsafe -Wdefault-const-init-field-unsafe -Wdefault-const-init-var-unsafe --- clang/docs/ReleaseNotes.rst | 16 + clang/include/clang/Basic/DiagnosticGroups.td | 12 +-- .../clang/Basic/DiagnosticSemaKinds.td| 18 ++ clang/lib/Sema/Sema.cpp | 2 +- clang/lib/Sema/SemaDecl.cpp | 2 +- clang/lib/Sema/SemaInit.cpp | 6 ++-- clang/test/Sema/warn-default-const-init.c | 33 --- 7 files changed, 51 insertions(+), 38 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index bc68bb8b70b3d..4fb606afc0f14 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -141,12 +141,16 @@ C Language Changes function type in Microsoft compatibility mode. #GH124869 - Clang now allows ``restrict`` qualifier for array types with pointer elements (#GH92847). - Clang now diagnoses ``const``-qualified object definitions without an - initializer. If the object is zero-initialized, it will be diagnosed under - the new warning ``-Wdefault-const-init`` (which is grouped under - ``-Wc++-compat`` because this construct is not compatible with C++). If the - object is left uninitialized, it will be diagnosed unsed the new warning - ``-Wdefault-const-init-unsafe`` (which is grouped under - ``-Wdefault-const-init``). #GH19297 + initializer. If the object is a variable or field which is zero-initialized, + it will be diagnosed under the new warning ``-Wdefault-const-init-var`` or + ``-Wdefault-const-init-field``, respectively. Similarly, if the variable or + field is not zero-initialized, it will be diagnosed under the new diagnostic + ``-Wdefault-const-init-var-unsafe`` or ``-Wdefault-const-init-field-unsafe``, + respectively. The unsafe diagnostic variants are grouped under a new + diagnostic ``-Wdefault-const-init-unsafe``, which itself is grouped under the + new diagnostic ``-Wdefault-const-init``. Finally, ``-Wdefault-const-init`` is + grouped under ``-Wc++-compat`` because these constructs are not compatible + with C++. #GH19297 - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index fc1ce197ef134..3835cd7251488 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -157,8 +157,16 @@ def C99Compat : DiagGroup<"c99-compat">; def C23Compat : DiagGroup<"c23-compat">; def : DiagGroup<"c2x-compat", [C23Compat]>; def HiddenCppDecl : DiagGroup<"c++-hidden-decl">; -def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe">; -def DefaultConstInit : DiagGroup<"default-const-init", [DefaultConstInitUnsafe]>; +def DefaultConstInitFieldUnsafe : DiagGroup<"default-const-init-field-unsafe">; +def DefaultConstInitVarUnsafe : DiagGroup<"default-const-init-var-unsafe">; +def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe", + [DefaultConstInitFieldUnsafe, +DefaultConstInitVarUnsafe]>; +def DefaultConstInitField : DiagGroup<"default-const-init-field">; +def DefaultConstInitVar : DiagGroup<"default-const-init-var">; +def DefaultConstInit : DiagGroup<"default-const-init", + [DefaultConstInitField, DefaultConstInitVar, +
[clang] [OpenACC][CIR] Start work to lower 'loop' (PR #137972)
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 HEAD~1 HEAD --extensions cpp -- clang/test/CIR/CodeGenOpenACC/loop.cpp clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp clang/lib/Sema/SemaOpenACC.cpp clang/test/CIR/CodeGenOpenACC/openacc-not-implemented.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp index f26096f70..0c4c6371f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp @@ -19,7 +19,6 @@ #include "mlir/Dialect/OpenACC/OpenACC.h" - using namespace clang; using namespace clang::CIRGen; using namespace cir; `` https://github.com/llvm/llvm-project/pull/137972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
emaxx-google wrote: > It is not clear to me why this is a specifically a problem when called from > `Profile(...)` can you elaborate a bit more in the summary. I've added a bit more details - it's basically the fact that the "get most recent" operation triggered the load of new nodes from the PCM file. If all this happens while a hash for another node is calculated in `Profile()`, it means we're modifying the hash map while doing another operation with it. At least that's the current theory, based on debugging the "deviating" executions of the compiler and seeing the `getMostRecentNonInjectedDecl()` call and the deserialization all during the `FoldingSet::NodeEquals()` function call. > Does `getMostRecentCXXRecordDecl(...)` require a comment that documents this > behavior so that future users do not fall into the same issue? Sure, I've added a comment. https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenACC][CIR] Start work to lower 'loop' (PR #137972)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Erich Keane (erichkeane) Changes As can be seen by the comment, this ends up being a construct that is going to be quite a lot of work in the future to make sure we properly identify the upperbound, lowerbound, and step. For now, we just treat the 'loop' as container so that we can put the 'for' loop into it. In the future, we'll have to teach the OpenACC dialect how to derive the upperbound, lowerbound, and step from the cir.for loop. Additionally, we'll probably have to add a few more options to it so that we can give it the recipes it needs to determine these for random access iterators. For Integer and Pointer values, these should already be known. --- Full diff: https://github.com/llvm/llvm-project/pull/137972.diff 4 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp (+90-3) - (modified) clang/lib/Sema/SemaOpenACC.cpp (+2-2) - (added) clang/test/CIR/CodeGenOpenACC/loop.cpp (+33) - (modified) clang/test/CIR/CodeGenOpenACC/openacc-not-implemented.cpp (-6) ``diff diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp index b01ff85607939..f26096f708f99 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp @@ -13,10 +13,13 @@ #include "CIRGenBuilder.h" #include "CIRGenFunction.h" #include "CIRGenOpenACCClause.h" -#include "mlir/Dialect/OpenACC/OpenACC.h" + #include "clang/AST/OpenACCClause.h" #include "clang/AST/StmtOpenACC.h" +#include "mlir/Dialect/OpenACC/OpenACC.h" + + using namespace clang; using namespace clang::CIRGen; using namespace cir; @@ -24,6 +27,90 @@ using namespace mlir::acc; mlir::LogicalResult CIRGenFunction::emitOpenACCLoopConstruct(const OpenACCLoopConstruct &s) { - cgm.errorNYI(s.getSourceRange(), "OpenACC Loop Construct"); - return mlir::failure(); + mlir::Location start = getLoc(s.getSourceRange().getBegin()); + mlir::Location end = getLoc(s.getSourceRange().getEnd()); + llvm::SmallVector retTy; + llvm::SmallVector operands; + auto op = builder.create(start, retTy, operands); + + // TODO(OpenACC): In the future we are going to need to come up with a + // transformation here that can teach the acc.loop how to figure out the + // 'lowerbound', 'upperbound', and 'step'. + // + // -'upperbound' should fortunately be pretty easy as it should be + // in the initialization section of the cir.for loop. In Sema, we limit to + // just the forms 'Var = init', `Type Var = init`, or `Var = init` (where it + // is an operator= call)`. However, as those are all necessary to emit for + // the init section of the for loop, they should be inside the initial + // cir.scope. + // + // -'upperbound' should be somewhat easy to determine. Sema is limiting this + // to: ==, <, >, !=, <=, >= builtin operators, the overloaded 'comparison' + // operations, and member-call expressions. + // + // For the builtin comparison operators, we can pretty well deduce based on + // the comparison what the 'end' object is going to be, and the inclusive + // nature of it. + // + // For the overloaded operators, Sema will ensure that at least one side of + // the operator is the init variable, so we can deduce the comparison there + // too. The standard places no real bounds on WHAT the comparison operators do + // for a `RandomAccessIterator` however, so we'll have to just 'assume' they + // do the right thing? Note that this might be incrementing by a different + // 'object', not an integral, so it isn't really clear to me what we can do to + // determine the other side. + // + // Member-call expressions are the difficult ones. I don't think there is + // anything we can deduce from this to determine the 'end', so we might end up + // having to go back to Sema and make this ill-formed. + // + // HOWEVER: What ACC dialect REALLY cares about is the tripcount, which you + // cannot get (in the case of `RandomAccessIterator`) from JUST 'upperbound' + // and 'lowerbound'. We will likely have to provide a 'recipe' equivilent to + // `std::distance` instead. In the case of integer/pointers, it is fairly + // simple to find: it is just the mathematical subtraction. Howver, in the + // case of `RandomAccessIterator`, we have to enable the use of `operator-`. + // FORTUNATELY the standard requires this to work correctly for + // `RandomAccessIterator`, so we don't have to implement a `std::distance` + // that loops through, like we would for a forward/etc iterator. + // + // 'step': Sema is currently allowing builtin ++,--, +=, -=, *=, /=, and = + // operators. Additionally, it allows the equivilent for the operator-call, as + // well as member-call. + // + // For builtin operators, we perhaps should refine the assignment here. It + // doesn't reallly help us know the 'step' count at all, but we could perhaps + // do one more step
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()); emaxx-google wrote: Yes, but this suggestion seems not needed because this `getCanonicalDecl()` call is already made inside the `Profile()` method: https://github.com/llvm/llvm-project/blob/e8ae77947154e10dbc05cbb95ec9e10d3b0be13e/clang/lib/AST/Type.cpp#L5279 https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenACC][CIR] Start work to lower 'loop' (PR #137972)
https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/137972 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
@@ -39,6 +39,29 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +AST_MATCHER(clang::TypeLoc, isInImplicitTemplateInstantiation) { + const auto IsImplicitTemplateInstantiation = [](const auto *Node) { +return (Node != nullptr) && + (Node->getTemplateSpecializationKind() == TSK_ImplicitInstantiation); + }; + + auto ParentNodes = Finder->getASTContext().getParents(Node); + while (!ParentNodes.empty()) { +const auto &ParentNode = ParentNodes[0]; vbvictor wrote: ditto https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
https://github.com/emaxx-google edited https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
@@ -235,7 +237,8 @@ Changes in existing checks - Improved :doc:`bugprone-unsafe-functions ` check to allow specifying - additional functions to match. + additional functions to match. Added `ctime` and `localtime` + to unsafe functions check in clang-tidy. EugeneZelenko wrote: ```suggestion to unsafe functions list. ``` Entire section is about Clang-Tidy and this particular entry is about check. https://github.com/llvm/llvm-project/pull/110366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
https://github.com/vbvictor edited https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
@@ -39,6 +39,29 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +AST_MATCHER(clang::TypeLoc, isInImplicitTemplateInstantiation) { + const auto IsImplicitTemplateInstantiation = [](const auto *Node) { +return (Node != nullptr) && + (Node->getTemplateSpecializationKind() == TSK_ImplicitInstantiation); + }; + + auto ParentNodes = Finder->getASTContext().getParents(Node); vbvictor wrote: Please use explicit type instead of `auto` unless type is spelled statement. https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
@@ -39,6 +39,30 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +bool isWithinImplicitTemplateInstantiation(const TypeLoc *MatchedTypeLoc, vbvictor wrote: Maybe previous devs did not cover all cases, so you didn't have to delete and check-messages https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
https://github.com/zimirza updated https://github.com/llvm/llvm-project/pull/110366 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()); erichkeane wrote: Hmm... then I'm surprised that this patch is needed at all for the purposes of non-determinism. `getMostRecentCXXRecordDecl()->getCanonicalDecl()` will get the same declaration as `getCXXRecordDecl()->getCanonicalDecl()`. https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)
https://github.com/gedare updated https://github.com/llvm/llvm-project/pull/108332 >From 8846ff045f969b258554c3cfb72161e9f61dda19 Mon Sep 17 00:00:00 2001 From: Gedare Bloom Date: Thu, 20 Jun 2024 17:35:39 -0600 Subject: [PATCH 1/2] Format: add AlignAfterControlStatement Introduce new style option to allow overriding the breaking after the opening parenthesis for control statements (if/for/while/switch). Fixes #67738. Fixes #79176. Fixes #80123. --- clang/include/clang/Format/Format.h| 17 ++ clang/lib/Format/ContinuationIndenter.cpp | 69 +++-- clang/lib/Format/Format.cpp| 13 + clang/lib/Format/TokenAnnotator.cpp| 8 +- clang/unittests/Format/ConfigParseTest.cpp | 8 + clang/unittests/Format/FormatTest.cpp | 298 + 6 files changed, 391 insertions(+), 22 deletions(-) diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index f6ceef08b46da..274a9e4ee272a 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -62,6 +62,22 @@ struct FormatStyle { /// \version 3.3 int AccessModifierOffset; + /// Different styles for breaking the parenthesis after a control statement + /// (``if/switch/while/for ...``). + /// \version 21 + enum BreakAfterControlStatementStyle : int8_t { +/// Use the default behavior. +BACSS_Default, +/// Force break after the left parenthesis of a control statement only +/// when the expression exceeds the column limit, and align on the +/// ``ContinuationIndentWidth``. +BACSS_MultiLine, +/// Do not force a break after the control statment. +BACSS_No, + }; + + BreakAfterControlStatementStyle AlignAfterControlStatement; + /// Different styles for aligning after open brackets. enum BracketAlignmentStyle : int8_t { /// Align parameters on the open bracket, e.g.: @@ -5283,6 +5299,7 @@ struct FormatStyle { bool operator==(const FormatStyle &R) const { return AccessModifierOffset == R.AccessModifierOffset && AlignAfterOpenBracket == R.AlignAfterOpenBracket && + AlignAfterControlStatement == R.AlignAfterControlStatement && AlignArrayOfStructures == R.AlignArrayOfStructures && AlignConsecutiveAssignments == R.AlignConsecutiveAssignments && AlignConsecutiveBitFields == R.AlignConsecutiveBitFields && diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 55e1d1ceb55b7..f4e48b7e37d54 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -814,6 +814,11 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // parenthesis by disallowing any further line breaks if there is no line // break after the opening parenthesis. Don't break if it doesn't conserve // columns. + auto IsOtherConditional = [&](const FormatToken &Tok) { +return Tok.isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch) || + (Style.isJavaScript() && Tok.is(Keywords.kw_await) && Tok.Previous && +Tok.Previous->is(tok::kw_for)); + }; auto IsOpeningBracket = [&](const FormatToken &Tok) { auto IsStartOfBracedList = [&]() { return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) && @@ -825,26 +830,36 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, } if (!Tok.Previous) return true; -if (Tok.Previous->isIf()) - return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak; -return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, - tok::kw_switch) && - !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await)); +if (Tok.Previous->isIf()) { + /* For backward compatibility, use AlignAfterOpenBracket + * in case AlignAfterControlStatement is not initialized */ + return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine || + (Style.AlignAfterControlStatement == FormatStyle::BACSS_Default && + Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak); +} +if (IsOtherConditional(*Tok.Previous)) + return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine; +if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak || +Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) { + return !Tok.Previous->is(TT_CastRParen) && + !(Style.isJavaScript() && Tok.is(Keywords.kw_await)); +} +return false; }; auto IsFunctionCallParen = [](const FormatToken &Tok) { return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous && Tok.Previous->is(tok::identifier); }; - auto IsInTemplateString = [this](const FormatToken &Tok) { + auto IsInTemplateString = [this](const FormatToken &Tok, bool NestBlocks) { if (!Style.isJavaScrip
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,Zishan Mirza ,Zishan Mirza ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan Message-ID: In-Reply-To: https://github.com/zimirza ready_for_review https://github.com/llvm/llvm-project/pull/110366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [IR] Do not store Function inside BlockAddress (PR #137958)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/137958 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()); emaxx-google wrote: The issue is transient - the reproducibility rate on the reproducer (https://pastebin.com/6aL6rmBe) is only 1%. Also it's not the pointer we have here that's problematic, but rather the fact of extra AST node loading inside the `FoldingSet` hash calculation operation. https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Add spir_kernel attribute (PR #137882)
https://github.com/sarnex edited https://github.com/llvm/llvm-project/pull/137882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Add spir_kernel attribute (PR #137882)
https://github.com/sarnex edited https://github.com/llvm/llvm-project/pull/137882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
AaronBallman wrote: > > > LGTM! Do you need me to land the changes on your behalf? > > > > > > Yup, I don't have access yet > > I'll push the changes once precommit CI goes green. Thank you for the > improvement! FYI: it looks like precommit CI found a failure with one of the tests https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,Zishan Mirza ,Zishan Mirza ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan Message-ID: In-Reply-To: zimirza wrote: `localtime_s` was removed from https://github.com/llvm/llvm-project/pull/110363, and will be added to a new pull request and `ctime_s` has not been merged yet (https://github.com/llvm/llvm-project/pull/110676). It might be a good wait before merging this pull request. https://github.com/llvm/llvm-project/pull/110366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 75f040a - [libclc] Clean up unnecessary #undef __CLC_BODYs (#137959)
Author: Fraser Cormack Date: 2025-04-30T16:13:04+01:00 New Revision: 75f040ab3e119e0ee87963ec9d2a01b1e6d4039e URL: https://github.com/llvm/llvm-project/commit/75f040ab3e119e0ee87963ec9d2a01b1e6d4039e DIFF: https://github.com/llvm/llvm-project/commit/75f040ab3e119e0ee87963ec9d2a01b1e6d4039e.diff LOG: [libclc] Clean up unnecessary #undef __CLC_BODYs (#137959) This macro is automatically undefined by the various gentype-like helpers. Added: Modified: libclc/clc/include/clc/common/clc_degrees.h libclc/clc/include/clc/common/clc_radians.h libclc/clc/include/clc/common/clc_sign.h libclc/clc/include/clc/common/clc_smoothstep.h libclc/clc/include/clc/integer/clc_add_sat.h libclc/clc/include/clc/integer/clc_clz.h libclc/clc/include/clc/integer/clc_ctz.h libclc/clc/include/clc/integer/clc_hadd.h libclc/clc/include/clc/integer/clc_mad24.h libclc/clc/include/clc/integer/clc_mad_sat.h libclc/clc/include/clc/integer/clc_mul24.h libclc/clc/include/clc/integer/clc_mul_hi.h libclc/clc/include/clc/integer/clc_rhadd.h libclc/clc/include/clc/integer/clc_rotate.h libclc/clc/include/clc/integer/clc_sub_sat.h libclc/clc/include/clc/internal/math/clc_sw_fma.h libclc/clc/include/clc/math/clc_acos.h libclc/clc/include/clc/math/clc_acosh.h libclc/clc/include/clc/math/clc_acospi.h libclc/clc/include/clc/math/clc_asin.h libclc/clc/include/clc/math/clc_asinh.h libclc/clc/include/clc/math/clc_asinpi.h libclc/clc/include/clc/math/clc_atan.h libclc/clc/include/clc/math/clc_atan2.h libclc/clc/include/clc/math/clc_atan2pi.h libclc/clc/include/clc/math/clc_atanh.h libclc/clc/include/clc/math/clc_atanpi.h libclc/clc/include/clc/math/clc_cbrt.inc libclc/clc/include/clc/math/clc_ceil.h libclc/clc/include/clc/math/clc_copysign.h libclc/clc/include/clc/math/clc_cosh.h libclc/clc/include/clc/math/clc_cospi.h libclc/clc/include/clc/math/clc_exp.h libclc/clc/include/clc/math/clc_exp10.h libclc/clc/include/clc/math/clc_exp2.h libclc/clc/include/clc/math/clc_exp_helper.h libclc/clc/include/clc/math/clc_expm1.h libclc/clc/include/clc/math/clc_fabs.h libclc/clc/include/clc/math/clc_fdim.h libclc/clc/include/clc/math/clc_floor.h libclc/clc/include/clc/math/clc_fma.h libclc/clc/include/clc/math/clc_fmax.h libclc/clc/include/clc/math/clc_fmin.h libclc/clc/include/clc/math/clc_fmod.h libclc/clc/include/clc/math/clc_fract.h libclc/clc/include/clc/math/clc_frexp.h libclc/clc/include/clc/math/clc_hypot.h libclc/clc/include/clc/math/clc_lgamma.h libclc/clc/include/clc/math/clc_lgamma_r.h libclc/clc/include/clc/math/clc_log.h libclc/clc/include/clc/math/clc_log10.h libclc/clc/include/clc/math/clc_log1p.h libclc/clc/include/clc/math/clc_log2.h libclc/clc/include/clc/math/clc_mad.h libclc/clc/include/clc/math/clc_modf.h libclc/clc/include/clc/math/clc_nan.h libclc/clc/include/clc/math/clc_native_cos.h libclc/clc/include/clc/math/clc_native_divide.h libclc/clc/include/clc/math/clc_native_exp.h libclc/clc/include/clc/math/clc_native_exp10.h libclc/clc/include/clc/math/clc_native_exp2.h libclc/clc/include/clc/math/clc_native_log.h libclc/clc/include/clc/math/clc_native_log10.h libclc/clc/include/clc/math/clc_native_log2.h libclc/clc/include/clc/math/clc_native_powr.h libclc/clc/include/clc/math/clc_native_recip.h libclc/clc/include/clc/math/clc_native_rsqrt.h libclc/clc/include/clc/math/clc_native_sin.h libclc/clc/include/clc/math/clc_native_sqrt.h libclc/clc/include/clc/math/clc_native_tan.h libclc/clc/include/clc/math/clc_nextafter.h libclc/clc/include/clc/math/clc_pow.h libclc/clc/include/clc/math/clc_pown.h libclc/clc/include/clc/math/clc_powr.h libclc/clc/include/clc/math/clc_remainder.h libclc/clc/include/clc/math/clc_remquo.h libclc/clc/include/clc/math/clc_rint.h libclc/clc/include/clc/math/clc_rootn.h libclc/clc/include/clc/math/clc_round.h libclc/clc/include/clc/math/clc_rsqrt.h libclc/clc/include/clc/math/clc_sincos_helpers.h libclc/clc/include/clc/math/clc_sinh.h libclc/clc/include/clc/math/clc_sinpi.h libclc/clc/include/clc/math/clc_sqrt.h libclc/clc/include/clc/math/clc_tanh.h libclc/clc/include/clc/math/clc_tanpi.h libclc/clc/include/clc/math/clc_tgamma.h libclc/clc/include/clc/math/clc_trunc.h libclc/clc/include/clc/relational/clc_bitselect.h libclc/clc/include/clc/relational/clc_isfinite.h libclc/clc/include/clc/relational/clc_isgreater.h libclc/clc/include/clc/relational/clc_isgreaterequal.h libclc/clc/include/clc/relational/clc_isless.h libclc/clc/include/clc/relational/clc_islessequal.h libclc/clc/include/clc/relational/clc_islessgreater.h libclc/clc/include/clc/relational/clc_isnormal.h libclc/clc/include/clc/relational/clc_isnotequal.h libclc/clc
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
https://github.com/erichkeane approved this pull request. I'm still not sure I understand the problem this is solving, but I also don't see any harm in it, so I'm leaning towards accept here. Aaron can be the final approval though. https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Clean up unnecessary #undef __CLC_BODYs (PR #137959)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/137959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang AST] move mangling API to namespace clang to allow calls from swift-frontend (PR #137884)
https://github.com/AaronBallman approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/137884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch (PR #137932)
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/137932 3-component vector type is supported for them per OpenCL spec. >From cafb374de8d77c82fa450b732a122663090f6e34 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Wed, 30 Apr 2025 00:44:50 -0700 Subject: [PATCH] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch 3-component vector type is supported for them per OpenCL spec. --- libclc/generic/include/clc/async/gentype.inc | 44 1 file changed, 44 insertions(+) diff --git a/libclc/generic/include/clc/async/gentype.inc b/libclc/generic/include/clc/async/gentype.inc index 1114883e1ad35..e023c8bbd97d2 100644 --- a/libclc/generic/include/clc/async/gentype.inc +++ b/libclc/generic/include/clc/async/gentype.inc @@ -14,6 +14,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE char3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE char4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -34,6 +38,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE uchar3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE uchar4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -54,6 +62,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE short3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE short4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -74,6 +86,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE ushort3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE ushort4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -94,6 +110,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE int3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE int4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -114,6 +134,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE uint3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE uint4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -134,6 +158,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE float3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE float4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -154,6 +182,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE long3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE long4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -174,6 +206,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE ulong3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE ulong4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -197,6 +233,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE double3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE double4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -222,6 +262,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE half3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE half4 #include __CLC_BODY #undef __CLC_GENTYPE ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] Add IR Profile-Guided Optimization (IR PGO) support to the Flang compiler (PR #136098)
@@ -19,6 +21,7 @@ template class Expected; template class IntrusiveRefCntPtr; class Module; class MemoryBufferRef; +extern cl::opt ClPGOColdFuncAttr; fanju110 wrote: I think you're right, I'll just put it back in BackendUtil.cpp. I'm going to leave this experiment out of flang for now. My next step is to work on the other options in PGO that are not implemented yet https://github.com/llvm/llvm-project/pull/136098 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, + Expr *Condition_NoVariants, Expr *Condition_NoContext) { + llvm::BasicBlock *ThenBlock = CGF->createBasicBlock("if.then"); + llvm::BasicBlock *ElseBlock = CGF->createBasicBlock("if.else"); + llvm::BasicBlock *MergeBlock = CGF->createBasicBlock("if.end"); + llvm::BasicBlock *ThenNoVariantsBlock = nullptr; + llvm::BasicBlock *ElseNoVariantsBlock = nullptr; + llvm::BasicBlock *ThenNoContextBlock = nullptr; + Expr *ElseCall = nullptr; + + if (Condition_NoVariants && Condition_NoContext) { +ThenNoVariantsBlock = CGF->createBasicBlock("if.then.NoVariants"); +ElseNoVariantsBlock = CGF->createBasicBlock("else.NoVariants"); +ThenNoContextBlock = CGF->createBasicBlock("if.then.NoContext"); + +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoVariantsBlock, + ElseNoVariantsBlock, 0); + + } else if (Condition_NoVariants) +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); + else +CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); + + if (Condition_NoVariants && Condition_NoContext) { +// Emit the NoVariants (if then, for the NoVariants) block. +CGF->EmitBlock(ThenNoVariantsBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + +CGF->EmitBlock(ElseNoVariantsBlock); +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoContextBlock, + ElseBlock, 0); +// Emit the NoContext (else if, for the NoContext) block. +CGF->EmitBlock(ThenNoContextBlock); +Stmt *ThenNoContextStmt = AssociatedStmt; +transformCallInStmt(ThenNoContextStmt, true); +CGF->EmitStmt(ThenNoContextStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoVariants) { +// Emit the NoVariants (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoContext) { +// Emit the NoContext (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, true); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + } + + // Emit the else block. + CGF->EmitBlock(ElseBlock); + Stmt *ElseStmt = AssociatedStmt; + if (auto *CaptStmt = dyn_cast(ElseStmt)) { +CapturedDecl *CDecl = CaptStmt->getCapturedDecl(); +replaceWithNewTraitsOrDire
[clang] [C] Add diagnostic + attr for unterminated strings (PR #137829)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/137829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Add diagnostic + attr for unterminated strings (PR #137829)
@@ -5024,3 +5024,9 @@ def OpenACCRoutineDecl :InheritableAttr { void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const; }]; } + +def NonString : InheritableAttr { + let Spellings = [GCC<"nonstring">]; erichkeane wrote: No interest in doing a 'clang' spelling for this as well? This seems reasonably valuable enough I would expect `clang::` to be ok too. https://github.com/llvm/llvm-project/pull/137829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Remove FEM_Indeterminable (PR #137247)
nico wrote: > What is the warning? => #137247 https://github.com/llvm/llvm-project/pull/137247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, alexey-bataev wrote: Try to add tests with classes, which evaluate to boolean, and create immediate class instance and see, that the destructors are called correctly https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -0,0 +1,364 @@ +// expected-no-diagnostics alexey-bataev wrote: The tests with classes and function members are required, as well as classes, used in conditions https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, + Expr *Condition_NoVariants, Expr *Condition_NoContext) { + llvm::BasicBlock *ThenBlock = CGF->createBasicBlock("if.then"); + llvm::BasicBlock *ElseBlock = CGF->createBasicBlock("if.else"); + llvm::BasicBlock *MergeBlock = CGF->createBasicBlock("if.end"); + llvm::BasicBlock *ThenNoVariantsBlock = nullptr; + llvm::BasicBlock *ElseNoVariantsBlock = nullptr; + llvm::BasicBlock *ThenNoContextBlock = nullptr; + Expr *ElseCall = nullptr; + + if (Condition_NoVariants && Condition_NoContext) { +ThenNoVariantsBlock = CGF->createBasicBlock("if.then.NoVariants"); +ElseNoVariantsBlock = CGF->createBasicBlock("else.NoVariants"); +ThenNoContextBlock = CGF->createBasicBlock("if.then.NoContext"); + +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoVariantsBlock, + ElseNoVariantsBlock, 0); + + } else if (Condition_NoVariants) +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); + else +CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); + + if (Condition_NoVariants && Condition_NoContext) { +// Emit the NoVariants (if then, for the NoVariants) block. +CGF->EmitBlock(ThenNoVariantsBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + +CGF->EmitBlock(ElseNoVariantsBlock); +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoContextBlock, + ElseBlock, 0); +// Emit the NoContext (else if, for the NoContext) block. +CGF->EmitBlock(ThenNoContextBlock); +Stmt *ThenNoContextStmt = AssociatedStmt; +transformCallInStmt(ThenNoContextStmt, true); +CGF->EmitStmt(ThenNoContextStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoVariants) { +// Emit the NoVariants (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoContext) { +// Emit the NoContext (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, true); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + } alexey-bataev wrote: Same code, which differs only by boolean flag https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.ll
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -10554,6 +10687,8 @@ SemaOpenMP::ActOnOpenMPDispatchDirective(ArrayRef Clauses, return StmtError(); Stmt *S = cast(AStmt)->getCapturedStmt(); + if (isa(S)) +S = cast(S)->getCapturedStmt(); alexey-bataev wrote: ```suggestion if (auto *CS = dyn_cast(S)) S = CS->getCapturedStmt(); ``` https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, + Expr *Condition_NoVariants, Expr *Condition_NoContext) { + llvm::BasicBlock *ThenBlock = CGF->createBasicBlock("if.then"); + llvm::BasicBlock *ElseBlock = CGF->createBasicBlock("if.else"); + llvm::BasicBlock *MergeBlock = CGF->createBasicBlock("if.end"); + llvm::BasicBlock *ThenNoVariantsBlock = nullptr; + llvm::BasicBlock *ElseNoVariantsBlock = nullptr; + llvm::BasicBlock *ThenNoContextBlock = nullptr; + Expr *ElseCall = nullptr; + + if (Condition_NoVariants && Condition_NoContext) { +ThenNoVariantsBlock = CGF->createBasicBlock("if.then.NoVariants"); +ElseNoVariantsBlock = CGF->createBasicBlock("else.NoVariants"); +ThenNoContextBlock = CGF->createBasicBlock("if.then.NoContext"); + +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoVariantsBlock, + ElseNoVariantsBlock, 0); + + } else if (Condition_NoVariants) +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); + else +CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); + + if (Condition_NoVariants && Condition_NoContext) { +// Emit the NoVariants (if then, for the NoVariants) block. +CGF->EmitBlock(ThenNoVariantsBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + +CGF->EmitBlock(ElseNoVariantsBlock); +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoContextBlock, + ElseBlock, 0); +// Emit the NoContext (else if, for the NoContext) block. +CGF->EmitBlock(ThenNoContextBlock); +Stmt *ThenNoContextStmt = AssociatedStmt; +transformCallInStmt(ThenNoContextStmt, true); +CGF->EmitStmt(ThenNoContextStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoVariants) { +// Emit the NoVariants (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoContext) { +// Emit the NoContext (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, true); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + } + + // Emit the else block. + CGF->EmitBlock(ElseBlock); + Stmt *ElseStmt = AssociatedStmt; + if (auto *CaptStmt = dyn_cast(ElseStmt)) { +CapturedDecl *CDecl = CaptStmt->getCapturedDecl(); +replaceWithNewTraitsOrDire
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4280,6 +4282,15 @@ getTargetRegionParams(Sema &SemaRef) { return Params; } +static SmallVector +getDispatchRegionParams(Sema &SemaRef) { + ASTContext &Context = SemaRef.getASTContext(); + SmallVector Params; + + Params.push_back(std::make_pair(StringRef(), QualType())); alexey-bataev wrote: ```suggestion Params.emplace_back(StringRef(), QualType()); ``` https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, + Expr *Condition_NoVariants, Expr *Condition_NoContext) { + llvm::BasicBlock *ThenBlock = CGF->createBasicBlock("if.then"); + llvm::BasicBlock *ElseBlock = CGF->createBasicBlock("if.else"); + llvm::BasicBlock *MergeBlock = CGF->createBasicBlock("if.end"); + llvm::BasicBlock *ThenNoVariantsBlock = nullptr; + llvm::BasicBlock *ElseNoVariantsBlock = nullptr; + llvm::BasicBlock *ThenNoContextBlock = nullptr; + Expr *ElseCall = nullptr; + + if (Condition_NoVariants && Condition_NoContext) { +ThenNoVariantsBlock = CGF->createBasicBlock("if.then.NoVariants"); +ElseNoVariantsBlock = CGF->createBasicBlock("else.NoVariants"); +ThenNoContextBlock = CGF->createBasicBlock("if.then.NoContext"); + +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoVariantsBlock, + ElseNoVariantsBlock, 0); + + } else if (Condition_NoVariants) +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); + else +CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); alexey-bataev wrote: ```suggestion } else if (Condition_NoVariants) { CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); } else { CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); } ``` https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + alexey-bataev wrote: I still think these functions should not be needed, if something is required, it should be build in Sema and stored in AST. If you need to replace some AST values by some LVM IR values, use OpaqueValue nodes, which can be replaced in codegen by special RAIIs. https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
@@ -912,6 +912,11 @@ class BlockAddress final : public Constant { /// block must be embedded into a function. static BlockAddress *get(BasicBlock *BB); + /// Return a BlockAddress for the specified basic block, which may not be + /// part of a function. The specified type must match the type of the function + /// the block will be inserted into. + static BlockAddress *get(Type *Ty, BasicBlock *BB); nikic wrote: I'd say "no unless it's actually needed". We should avoid creating blockaddresses for non-inserted blocks if possible. https://github.com/llvm/llvm-project/pull/137958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/132991 >From c476948593a80ed31765cdd711a626e4e03930ab Mon Sep 17 00:00:00 2001 From: hulxv Date: Tue, 25 Mar 2025 22:56:51 +0200 Subject: [PATCH 1/8] [include-cleaner] rename enabled flags to `disable-*` --- .../include-cleaner/test/tool.cpp | 4 ++-- .../include-cleaner/tool/IncludeCleaner.cpp | 20 +-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp b/clang-tools-extra/include-cleaner/test/tool.cpp index d72d2317ce2b1..8b723a5bf40e2 100644 --- a/clang-tools-extra/include-cleaner/test/tool.cpp +++ b/clang-tools-extra/include-cleaner/test/tool.cpp @@ -6,11 +6,11 @@ int x = foo(); // CHANGE: - "foobar.h" // CHANGE-NEXT: + "foo.h" -// RUN: clang-include-cleaner -remove=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s +// RUN: clang-include-cleaner -disable-remove -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s // INSERT-NOT: - "foobar.h" // INSERT: + "foo.h" -// RUN: clang-include-cleaner -insert=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s +// RUN: clang-include-cleaner -disable-insert -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s // REMOVE: - "foobar.h" // REMOVE-NOT: + "foo.h" diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 1d9458ffc4d32..472611073f732 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -91,16 +91,16 @@ cl::opt Edit{ cl::cat(IncludeCleaner), }; -cl::opt Insert{ -"insert", -cl::desc("Allow header insertions"), -cl::init(true), +cl::opt DisableInsert{ +"disable-insert", +cl::desc("DIsable header insertions"), +cl::init(false), cl::cat(IncludeCleaner), }; -cl::opt Remove{ -"remove", -cl::desc("Allow header removals"), -cl::init(true), +cl::opt DisableRemove{ +"disable-remove", +cl::desc("Disable header removals"), +cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +183,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) +if (DisableInsert) Results.Missing.clear(); -if (!Remove) +if (DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From e2f78ab69f656313fc87b004506abc1deb096189 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 18 Apr 2025 08:59:03 +0200 Subject: [PATCH 2/8] [include-cleaner] return `--remove` and `--insert` to be in deprecation period --- .../include-cleaner/tool/IncludeCleaner.cpp | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 472611073f732..7a07d09ce277d 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -90,10 +90,21 @@ cl::opt Edit{ cl::desc("Apply edits to analyzed source files"), cl::cat(IncludeCleaner), }; - +cl::opt Insert{ +"insert", +cl::desc("Allow header insertions"), +cl::init(true), +cl::cat(IncludeCleaner), +}; +cl::opt Remove{ +"remove", +cl::desc("Allow header removals"), +cl::init(true), +cl::cat(IncludeCleaner), +}; cl::opt DisableInsert{ "disable-insert", -cl::desc("DIsable header insertions"), +cl::desc("Disable header insertions"), cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +194,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (DisableInsert) +if (!Insert || DisableInsert) Results.Missing.clear(); -if (DisableRemove) +if (!Remove || DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From b7dd110307c0ba467022775398b9bd2ab66517f5 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 25 Apr 2025 19:30:55 +0300 Subject: [PATCH 3/8] [clang-tools-extra] add note for deprecation of `-remove` and `-insert` --- clang-tools-extra/docs/ReleaseNotes.rst | 8 1 file changed, 8 insertions(+) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 72aa05eb4dcd1..8b39fa09e2839 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/Releas
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()); erichkeane wrote: Is the problem that we run this profile in the 'middle' of a TU and the most recent decl changes by the end? If so, this makes sense. That said, I'd expect this to be the above suggestion in case this member pointer type has a redeclaration that perhaps changes what the actual referenced decl is. ```suggestion Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()->getCanonicalDecl()); ``` https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
@@ -183,9 +195,26 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) + +if (!Insert) { + llvm::errs() + << "[WARNING] -insert is deprecated in favor of `-disable-insert`. " + "The old flag was confusing since it suggested that inserts " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} + +if (!Remove) { + llvm::errs() + << "[WARNING] -remove is deprecated in favor of `-disable-remove`. " + "The old flag was confusing since it suggested that removes " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} + AaronBallman wrote: Oh shoot, then nope, ignore this suggestion. :-) https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/132991 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
hulxv wrote: I think all is fine now https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
@@ -183,9 +195,26 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) + +if (!Insert) { + llvm::errs() + << "warning: `-insert=0` is deprecated in favor of `-disable-insert`. " + "The old flag was confusing since it suggested that inserts " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} + +if (!Remove) { + llvm::errs() + << "warning: `-remove=0` is deprecated in favor of `-disable-remove`. " + "The old flag was confusing since it suggested that removes " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} AaronBallman wrote: Two changes still missing here: 1) Change backticks around the command syntax into single quotes 2) Remove the link to the GitHub issue https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 01e0296 - [clang] Temporarily silence noisy warning for FPEvalMethod
Author: Nico Weber Date: 2025-04-30T09:39:19-04:00 New Revision: 01e029602a8ae860852ad2dd8c6ea347c9200066 URL: https://github.com/llvm/llvm-project/commit/01e029602a8ae860852ad2dd8c6ea347c9200066 DIFF: https://github.com/llvm/llvm-project/commit/01e029602a8ae860852ad2dd8c6ea347c9200066.diff LOG: [clang] Temporarily silence noisy warning for FPEvalMethod See https://github.com/llvm/llvm-project/issues/137600#issuecomment-2842011513 Added: Modified: clang/include/clang/Basic/LangOptions.def Removed: diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 85ca523c44157..1258a349ebf00 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -347,7 +347,17 @@ BENIGN_ENUM_LANGOPT(DefaultFPContractMode, FPModeKind, 2, FPM_Off, "FP contracti COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating point") BENIGN_LANGOPT(RoundingMath, 1, false, "Do not assume default floating-point rounding behavior") BENIGN_ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Default, "FP Exception Behavior Mode type") + +#if defined(__clang__) +// FIXME: Remove this once the warning is fixed, https://llvm.org/PR137600 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpreferred-type-bitfield-enum-conversion" +#endif BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 3, FEM_UnsetOnCommandLine, "FP type used for floating point arithmetic") +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + ENUM_LANGOPT(Float16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for Float16 arithmetic") ENUM_LANGOPT(BFloat16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for BFloat16 arithmetic") LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits