[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)
@@ -110,15 +117,32 @@ bool UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall, BlockMap = std::make_unique(TheCFG.get(), Context); Visited.clear(); - const CFGBlock *Block = BlockMap->blockContainingStmt(MovingCall); - if (!Block) { + const CFGBlock *MoveBlock = BlockMap->blockContainingStmt(MovingCall); + if (!MoveBlock) { // This can happen if MovingCall is in a constructor initializer, which is // not included in the CFG because the CFG is built only from the function // body. -Block = &TheCFG->getEntry(); +MoveBlock = &TheCFG->getEntry(); } - return findInternal(Block, MovingCall, MovedVariable, TheUseAfterMove); + bool Found = findInternal(MoveBlock, MovingCall, MovedVariable->getDecl(), +TheUseAfterMove); + + if (Found) { +if (const CFGBlock *UseBlock = +BlockMap->blockContainingStmt(TheUseAfterMove->DeclRef)) { + // Does the use happen in a later loop iteration than the move? + // - If they are in the same CFG block, we know the use happened in a + // later iteration if we visited that block a second time. + // - Otherwise, we know the use happened in a later iteration if the + // move is reachable from the use. + auto CFA = std::make_unique(*TheCFG); + TheUseAfterMove->UseHappensInLaterLoopIteration = + UseBlock == MoveBlock ? Visited.contains(UseBlock) +: CFA->isReachable(UseBlock, MoveBlock); martinboehme wrote: Drive-by comment: These types are fine to put on the stack. Note that the elements contained in these containers are stored on the heap in any case. For example, in the case of `DenseMap`, this storage is allocated by `DenseMap::allocateBuckets()`. The only things contained in `DenseMap` itself (and hence stored on the stack) are a pointer to the bucket array `Buckets` and some counters (`NumEntries`, `NumBuckets`, `NumTombstones`). https://github.com/llvm/llvm-project/pull/93623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Make it possible to enable misc-const-correctness clang-tidy check (PR #94920)
https://github.com/kadircet approved this pull request. thanks, this definitely LG. it's something we've just forgot :( https://github.com/llvm/llvm-project/pull/94920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -484,10 +484,31 @@ MC/DC Instrumentation - When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the -clang option ``-fcoverage-mcdc``, users are limited to at most **six** leaf-level -conditions in a boolean expression. A warning will be generated for boolean -expressions that contain more than six, and they will not be instrumented for -MC/DC. +clang option ``-fcoverage-mcdc``, there are two hard limits. ornata wrote: I think it's fine actually. https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
https://github.com/ornata approved this pull request. https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)
https://github.com/Andarwinux updated https://github.com/llvm/llvm-project/pull/94731 >From 42af4eaa38241394dffb429ff355f32609d0 Mon Sep 17 00:00:00 2001 From: Andarwinux <144242044+andarwi...@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:07:40 + Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver fixes #91216 --- clang/include/clang/Driver/Options.td | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d44faa55c456f..1cce7a5146dd8 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">, Alias<_SLASH_winsdkdir>; def : Separate<["-"], "Xmicrosoft-windows-sdk-version">, Alias<_SLASH_winsdkversion>; +def : Separate<["-"], "Xmicrosoft-windows-sys-root">, +Alias<_SLASH_winsysroot>; // Ignored: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [APFloat] Add APFloat support for FP6 data types (PR #94735)
durga4github wrote: There is one test failure in Codegen/LoongArch/opt-pipeline.ll and it does not seem related to my changes here. So, merging this change. https://github.com/llvm/llvm-project/pull/94735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [APFloat] Add APFloat support for FP6 data types (PR #94735)
https://github.com/durga4github closed https://github.com/llvm/llvm-project/pull/94735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b1fe03f - [APFloat] Add APFloat support for FP6 data types (#94735)
Author: Durgadoss R Date: 2024-06-11T13:16:51+05:30 New Revision: b1fe03f0840a2c488b1f07a669bfea3cc986ce3b URL: https://github.com/llvm/llvm-project/commit/b1fe03f0840a2c488b1f07a669bfea3cc986ce3b DIFF: https://github.com/llvm/llvm-project/commit/b1fe03f0840a2c488b1f07a669bfea3cc986ce3b.diff LOG: [APFloat] Add APFloat support for FP6 data types (#94735) This patch adds APFloat type support for two FP6 data types, E2M3 and E3M2. The definitions for the two formats are detailed in section 5.3.2 of the OCP specification, which can be accessed here: https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf Signed-off-by: Durgadoss R Added: Modified: clang/lib/AST/MicrosoftMangle.cpp llvm/include/llvm/ADT/APFloat.h llvm/lib/Support/APFloat.cpp llvm/unittests/ADT/APFloatTest.cpp Removed: diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 2f7a276363920..ffc5d2d4cd8fc 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -899,6 +899,8 @@ void MicrosoftCXXNameMangler::mangleFloat(llvm::APFloat Number) { case APFloat::S_Float8E4M3FNUZ: case APFloat::S_Float8E4M3B11FNUZ: case APFloat::S_FloatTF32: + case APFloat::S_Float6E3M2FN: + case APFloat::S_Float6E2M3FN: llvm_unreachable("Tried to mangle unexpected APFloat semantics"); } diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index 78faadb30d9eb..a9bb6ccb1 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -189,6 +189,14 @@ struct APFloatBase { // improved range compared to half (16-bit) formats, at (potentially) // greater throughput than single precision (32-bit) formats. S_FloatTF32, +// 6-bit floating point number with bit layout S1E3M2. Unlike IEEE-754 +// types, there are no infinity or NaN values. The format is detailed in +// https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf +S_Float6E3M2FN, +// 6-bit floating point number with bit layout S1E2M3. Unlike IEEE-754 +// types, there are no infinity or NaN values. The format is detailed in +// https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf +S_Float6E2M3FN, S_x87DoubleExtended, S_MaxSemantics = S_x87DoubleExtended, @@ -209,6 +217,8 @@ struct APFloatBase { static const fltSemantics &Float8E4M3FNUZ() LLVM_READNONE; static const fltSemantics &Float8E4M3B11FNUZ() LLVM_READNONE; static const fltSemantics &FloatTF32() LLVM_READNONE; + static const fltSemantics &Float6E3M2FN() LLVM_READNONE; + static const fltSemantics &Float6E2M3FN() LLVM_READNONE; static const fltSemantics &x87DoubleExtended() LLVM_READNONE; /// A Pseudo fltsemantic used to construct APFloats that cannot conflict with @@ -627,6 +637,8 @@ class IEEEFloat final : public APFloatBase { APInt convertFloat8E4M3FNUZAPFloatToAPInt() const; APInt convertFloat8E4M3B11FNUZAPFloatToAPInt() const; APInt convertFloatTF32APFloatToAPInt() const; + APInt convertFloat6E3M2FNAPFloatToAPInt() const; + APInt convertFloat6E2M3FNAPFloatToAPInt() const; void initFromAPInt(const fltSemantics *Sem, const APInt &api); template void initFromIEEEAPInt(const APInt &api); void initFromHalfAPInt(const APInt &api); @@ -642,6 +654,8 @@ class IEEEFloat final : public APFloatBase { void initFromFloat8E4M3FNUZAPInt(const APInt &api); void initFromFloat8E4M3B11FNUZAPInt(const APInt &api); void initFromFloatTF32APInt(const APInt &api); + void initFromFloat6E3M2FNAPInt(const APInt &api); + void initFromFloat6E2M3FNAPInt(const APInt &api); void assign(const IEEEFloat &); void copySignificand(const IEEEFloat &); @@ -1046,6 +1060,17 @@ class APFloat : public APFloatBase { /// \param Semantics - type float semantics static APFloat getAllOnesValue(const fltSemantics &Semantics); + static bool hasNanOrInf(const fltSemantics &Sem) { +switch (SemanticsToEnum(Sem)) { +default: + return true; +// Below Semantics do not support {NaN or Inf} +case APFloat::S_Float6E3M2FN: +case APFloat::S_Float6E2M3FN: + return false; +} + } + /// Used to insert APFloat objects, or objects that contain APFloat objects, /// into FoldingSets. void Profile(FoldingSetNodeID &NID) const; diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 283fcc153b33a..1209bf71a287d 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -68,6 +68,10 @@ enum class fltNonfiniteBehavior { // `fltNanEncoding` enum. We treat all NaNs as quiet, as the available // encodings do not distinguish between signalling and quiet NaN. NanOnly, + + // This behavior is present in Float6E3M2FN and Float6E2M3FN types, + // which do not sup
[clang-tools-extra] [clang-tidy] fix false positives for the functions with the same name as standard library functions in misc-include-cleaner (PR #94923)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/94923 >From e467b03cc120eedc580c185232f000e0d8aa0cc7 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Mon, 10 Jun 2024 09:04:27 +0800 Subject: [PATCH 1/2] [clang-tidy] fix false positives for the functions with the same name as standard library functions in misc-include-cleaner Fixes: #93335 --- clang-tools-extra/docs/ReleaseNotes.rst | 4 .../include-cleaner/lib/LocateSymbol.cpp | 8 ++-- .../include-cleaner/unittests/FindHeadersTest.cpp | 11 +++ .../test/clang-tidy/checkers/misc/include-cleaner.cpp | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 3f0d25ec8c752..8c78d872b9a1a 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -286,6 +286,10 @@ Changes in existing checks Additionally, the option `UseHeaderFileExtensions` is removed, so that the check uses the `HeaderFileExtensions` option unconditionally. +- Improved :doc:`misc-include-cleaner + ` check by avoiding false positives for + the functions with the same name as standard library functions. + - Improved :doc:`misc-unused-using-decls ` check by replacing the local option `HeaderFileExtensions` by the global option of the same name. diff --git a/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp b/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp index 78e783a62eb27..9148d36a5038f 100644 --- a/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp +++ b/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp @@ -14,6 +14,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/Tooling/Inclusions/StandardLibrary.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/raw_ostream.h" #include #include @@ -40,8 +41,11 @@ Hints declHints(const Decl *D) { std::vector> locateDecl(const Decl &D) { std::vector> Result; // FIXME: Should we also provide physical locations? - if (auto SS = tooling::stdlib::Recognizer()(&D)) -return {{*SS, Hints::CompleteSymbol}}; + if (auto SS = tooling::stdlib::Recognizer()(&D)) { +Result.push_back({*SS, Hints::CompleteSymbol}); +if (!D.hasBody()) + return Result; + } // FIXME: Signal foreign decls, e.g. a forward declaration not owned by a // library. Some useful signals could be derived by checking the DeclContext. // Most incidental forward decls look like: diff --git a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp index 07302142a13e3..fdcbf25fd628c 100644 --- a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp @@ -628,6 +628,17 @@ TEST_F(HeadersForSymbolTest, StandardHeaders) { tooling::stdlib::Header::named(""))); } +TEST_F(HeadersForSymbolTest, NonStandardHeaders) { + Inputs.Code = "void assert() {}"; + buildAST(); + EXPECT_THAT( + headersFor("assert"), + // Respect the ordering from the stdlib mapping. + UnorderedElementsAre(physicalHeader("input.mm"), + tooling::stdlib::Header::named(""), + tooling::stdlib::Header::named(""))); +} + TEST_F(HeadersForSymbolTest, ExporterNoNameMatch) { Inputs.Code = R"cpp( #include "exporter/foo.h" diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp index e10ac3f46e2e9..b1e001834db5a 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp @@ -15,3 +15,5 @@ std::string HelloString; // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" is directly included [misc-include-cleaner] int FooBarResult = foobar(); // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is directly included [misc-include-cleaner] + +void log2() {} >From 0e3d60906d390990f029baa226b76bc55927f27a Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Tue, 11 Jun 2024 11:24:40 +0800 Subject: [PATCH 2/2] Update clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp --- .../test/clang-tidy/checkers/misc/include-cleaner.cpp | 6 ++ 1 file changed, 6 insertions(+) diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp index b1e001834db5a..d5ea96b00254c 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp @@ -16,4 +16,10 @@ std::string HelloString; int FooBarResult = foobar(); // CHECK-MESSAGES: :[[@LINE-1]]:20:
[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)
martinboehme wrote: More extensive comments on #90174 (let's continue the discussion there), but briefly: > * Removed custom smart pointers handling (were hiding issues) The standard smart pointers have a well-defined moved-from state (they are defined to be null after a move). Programmers may intentionally rely on this defined behavior. Warning on a (non-dereferencing) use-after-move for smart pointers as we do for other types would therefore result in false positives. > * Changed 'move occurred here' note location to always point to 'std::move' As discussed in more detail on #90174, the move doesn't actually occur in the `std::move()` (which is just a cast), and this can be important when sequencing rules come into play. https://github.com/llvm/llvm-project/pull/94869 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [libcxx] [libcxxabi] [libunwind] [libunwind][libcxx][libcxxabi][compiler-rt-builtins] Fix Exception Handling build for wasm (PR #79667)
https://github.com/trcrsired updated https://github.com/llvm/llvm-project/pull/79667 >From 4f1ce895254dd9505150c1f5f5cb77454b9aca68 Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsi...@users.noreply.github.com> Date: Sat, 1 Jun 2024 02:55:50 -0400 Subject: [PATCH] [libunwind][libcxx][libcxxabi] Fix Exception Handling build for wasm The wasm unwind build appears to be dysfunctional, likely because the author has only supplied a customized LLVM build on request, rather than a fully functional patch. This patch fixes the build Apply formatting patch proposed by github bot use "" to prevent CMAKE_SYSTEM_PROCESSOR not defined [libunwind] logAPI functions should also be built [libcxxabi] Fix function signatures for wasm wasm does not define the function signatures correctly for cxxabi Fix them Fix formatting issues for libcxxabi's wasm eh change Merge remote-tracking branch 'parent/main' into wasmlibunwindfix remove unwanted changes in unwind-wasm.c Make Unwind-wasm.c compile correctly without workaround in CMakeLists.txt using __wasm__ macro to guard against all wasm eh build fix UnwindLevel.c's formatting issue ISO C requires a translation unit to contain at least one declaration [-Werror,-Wempty-translation-unit] compiler-rt does not define CMP_RESULT correct on wasm64 Fixed Merge code --- compiler-rt/lib/builtins/fp_compare_impl.inc | 2 +- libcxx/include/__exception/exception_ptr.h | 21 +- libcxxabi/include/cxxabi.h | 179 ++--- libcxxabi/src/cxa_exception.cpp | 712 --- libcxxabi/src/cxa_exception.h| 7 +- libunwind/include/libunwind.h| 2 + libunwind/src/Unwind-wasm.c | 13 +- libunwind/src/UnwindRegistersRestore.S | 3 +- libunwind/src/UnwindRegistersSave.S | 3 + libunwind/src/assembly.h | 2 + libunwind/src/cet_unwind.h | 3 + libunwind/src/config.h | 15 +- libunwind/src/libunwind.cpp | 2 + libunwind/src/libunwind_ext.h| 2 + 14 files changed, 423 insertions(+), 543 deletions(-) diff --git a/compiler-rt/lib/builtins/fp_compare_impl.inc b/compiler-rt/lib/builtins/fp_compare_impl.inc index a9a4f6fbf5dfe..83bdea46a45da 100644 --- a/compiler-rt/lib/builtins/fp_compare_impl.inc +++ b/compiler-rt/lib/builtins/fp_compare_impl.inc @@ -12,7 +12,7 @@ // functions. We need to ensure that the return value is sign-extended in the // same way as GCC expects (since otherwise GCC-generated __builtin_isinf // returns true for finite 128-bit floating-point numbers). -#ifdef __aarch64__ +#if defined(__aarch64__) || defined(__wasm__) // AArch64 GCC overrides libgcc_cmp_return to use int instead of long. typedef int CMP_RESULT; #elif __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 4 diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h index 0a8337fa39de3..01f340a587ec3 100644 --- a/libcxx/include/__exception/exception_ptr.h +++ b/libcxx/include/__exception/exception_ptr.h @@ -29,22 +29,21 @@ namespace __cxxabiv1 { +#if defined(__wasm__) +typedef void* (*__libcpp_exception_destructor_func)(void*); +#elif defined(_WIN32) +typedef void(__thiscall* __libcpp_exception_destructor_func)(void*); +#else +typedef void (*__libcpp_exception_destructor_func)(void*); +#endif + extern "C" { _LIBCPP_OVERRIDABLE_FUNC_VIS void* __cxa_allocate_exception(size_t) throw(); _LIBCPP_OVERRIDABLE_FUNC_VIS void __cxa_free_exception(void*) throw(); struct __cxa_exception; -_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception( -void*, -std::type_info*, -#if defined(_WIN32) -void(__thiscall*)(void*)) throw(); -#elif defined(__wasm__) -// In Wasm, a destructor returns its argument -void* (*)(void*)) throw(); -#else -void (*)(void*)) throw(); -#endif +_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* +__cxa_init_primary_exception(void*, std::type_info*, __libcpp_exception_destructor_func) throw(); } } // namespace __cxxabiv1 diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h index 0e3969084e04f..4162fd7ec2ba7 100644 --- a/libcxxabi/include/cxxabi.h +++ b/libcxxabi/include/cxxabi.h @@ -20,62 +20,51 @@ #include <__cxxabi_config.h> #define _LIBCPPABI_VERSION 15000 -#define _LIBCXXABI_NORETURN __attribute__((noreturn)) +#define _LIBCXXABI_NORETURN __attribute__((noreturn)) #define _LIBCXXABI_ALWAYS_COLD __attribute__((cold)) #ifdef __cplusplus namespace std { -#if defined(_WIN32) +# if defined(_WIN32) class _LIBCXXABI_TYPE_VIS type_info; // forward declaration -#else +# else class type_info; // forward declaration -#endif -} - +# endif +} // namespace std // runtime routines use C calling conventions, but are in __cxxabiv1 namespace namespace __cxxabiv1 { struct __cxa_exception; +# if defined(__wasm__) +typedef void*
[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() (PR #90043)
HerrCai0907 wrote: > To be clear and reiterate my previous comment: this check should NOT require > users to use at(). That behavior should be opt-in. It should only warn about > using operator[]. It's up to the users to figure out what the best > replacement is. I don't think it is a good solution. For this kind of projects, they should disable this check directly. Maybe it is optimization to disable this check if exception feature is disabled. https://github.com/llvm/llvm-project/pull/90043 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add an ownership change visitor to StreamChecker (PR #94957)
https://github.com/Szelethus updated https://github.com/llvm/llvm-project/pull/94957 From faf00d0e1286e053ba9fb457513bd8309eb541ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Umann?= Date: Fri, 7 Jun 2024 12:07:35 +0200 Subject: [PATCH 1/4] [analyzer] Add an ownership change visitor to StreamChecker This is very similar to https://reviews.llvm.org/D105553, in fact, I barely made any changes from MallocChecker's ownership visitor to this one. The new visitor emits a diagnostic note for function where a change in stream ownership was expected (for example, it had a fclose() call), but the ownership remained unchanged. This is similar to messages regarding ordinary values ("Returning without writing to x"). Change-Id: I7621c178dd35713d860d27bfc644fb56a42b0946 --- .../StaticAnalyzer/Checkers/StreamChecker.cpp | 106 ++- clang/test/Analysis/stream-visitor.cpp| 179 ++ 2 files changed, 282 insertions(+), 3 deletions(-) create mode 100644 clang/test/Analysis/stream-visitor.cpp diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp index d4e020f7a72a0..d726ab5eaa599 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -10,6 +10,9 @@ // //===--===// +#include "NoOwnershipChangeVisitor.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" @@ -74,6 +77,12 @@ struct StreamErrorState { /// Returns if the StreamErrorState is a valid object. operator bool() const { return NoError || FEof || FError; } + LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &os) const { +os << "NoError: " << NoError << ", FEof: " << FEof + << ", FError: " << FError; + } + void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddBoolean(NoError); ID.AddBoolean(FEof); @@ -98,6 +107,19 @@ struct StreamState { OpenFailed /// The last open operation has failed. } State; + StringRef getKindStr() const { +switch (State) { +case Opened: + return "Opened"; +case Closed: + return "Closed"; +case OpenFailed: + return "OpenFailed"; +default: + llvm_unreachable("Unknown StreamState!"); +} + } + /// State of the error flags. /// Ignored in non-opened stream state but must be NoError. StreamErrorState const ErrorState; @@ -146,6 +168,9 @@ struct StreamState { return StreamState{L, OpenFailed, {}, false}; } + LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &os) const; + void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddPointer(LastOperation); ID.AddInteger(State); @@ -168,8 +193,9 @@ REGISTER_MAP_WITH_PROGRAMSTATE(StreamMap, SymbolRef, StreamState) namespace { class StreamChecker; -using FnCheck = std::function; +using FnCheckTy = void(const StreamChecker *, const FnDescription *, + const CallEvent &, CheckerContext &); +using FnCheck = std::function; using ArgNoTy = unsigned int; static const ArgNoTy ArgNone = std::numeric_limits::max(); @@ -183,6 +209,14 @@ struct FnDescription { ArgNoTy StreamArgNo; }; +LLVM_DUMP_METHOD void StreamState::dumpToStream(llvm::raw_ostream &os) const { + os << "{Kind: " << getKindStr() << ", Last operation: " << LastOperation + << ", ErrorState: "; + ErrorState.dumpToStream(os); + os << ", FilePos: " << (FilePositionIndeterminate ? "Indeterminate" : "OK") + << '}'; +} + /// Get the value of the stream argument out of the passed call event. /// The call should contain a function that is described by Desc. SVal getStreamArg(const FnDescription *Desc, const CallEvent &Call) { @@ -300,6 +334,8 @@ class StreamChecker : public Checker FnDescriptions = { {{CDM::CLibrary, {"fopen"}, 2}, @@ -310,7 +346,7 @@ class StreamChecker : public Checker(&Checker); +if (StreamChk->FCloseDesc.matchesAsWritten(Call)) + return true; + +return false; + } + + bool doesFnIntendToHandleOwnership(const Decl *Callee, + ASTContext &ACtx) override { +using namespace clang::ast_matchers; +const FunctionDecl *FD = dyn_cast(Callee); + +auto Matches = +match(findAll(callExpr().bind("call")), *FD->getBody(), ACtx); +for (BoundNodes Match : Matches) { + if (const auto *Call = Match.getNodeAs("call")) +if (isFreeingCallAsWritten(*Call)) + return true; +} +// TODO: Ownership might change with an attempt to store stream object, not +// only through
[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)
pointhex wrote: @mydeveloperday @owenca Kind reminder. https://github.com/llvm/llvm-project/pull/91317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)
farzonl wrote: > This broke building wasi-libc, with a crash: > > ``` > Stack dump: > 0.Program arguments: /builds/worker/fetches/clang/bin/clang-19 -cc1 > -triple wasm32-unknown-wasi -emit-obj -disable-free -clear-ast-before-backend > -disable-llvm-verifier -discard-value-names -main-file-name ctanh.c > -mrelocation-model static -mthread-model single -mframe-pointer=none > -ffp-contract=on -fno-rounding-math -ffp-exception-behavior=ignore > -mconstructor-aliases -target-cpu generic -fvisibility=hidden > -debugger-tuning=gdb > -fdebug-compilation-dir=/builds/worker/fetches/wasi-sdk/src/wasi-libc > -fcoverage-compilation-dir=/builds/worker/fetches/wasi-sdk/src/wasi-libc > -sys-header-deps -D NDEBUG -O2 -Wall -Wextra -Wno-null-pointer-arithmetic > -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable > -Wno-unused-function -Wno-ignored-attributes -Wno-missing-braces > -Wno-ignored-pragmas -Wno-unused-but-set-variable -Wno-unknown-warning-option > -Wno-parentheses -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses > -Wno-logical-op-parentheses -Wno-string-plus-int -Wno-dangling-else > -Wno-unknown-pragmas -ferror-limit 19 -fgnuc-version=4.2.1 > -fskip-odr-check-in-gmf -vectorize-loops -vectorize-slp -x c ctanh-46a6c8.c > 1. parser at end of file > 2.Code generation > 3.Running pass 'Function Pass Manager' on module 'ctanh-46a6c8.c'. > 4.Running pass 'WebAssembly Assembly Printer' on function '@ctanh' > #0 0x7f2205ba35cd llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) > /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:723:11 > #1 0x7f2205ba3abb PrintStackTraceSignalHandler(void*) > /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:798:1 > #2 0x7f2205ba1b26 llvm::sys::RunSignalHandlers() > /tmp/llvm/llvm/lib/Support/Signals.cpp:105:5 > #3 0x7f2205ba4275 SignalHandler(int) > /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:413:1 > #4 0x7f2203ff4f90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90) > #5 0x7f2204043ccc (/lib/x86_64-linux-gnu/libc.so.6+0x8accc) > #6 0x7f2203ff4ef2 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3bef2) > #7 0x7f2203fdf472 abort (/lib/x86_64-linux-gnu/libc.so.6+0x26472) > #8 0x7f2205a7f300 llvm::install_out_of_memory_new_handler() > /tmp/llvm/llvm/lib/Support/ErrorHandling.cpp:194:0 > #9 0x7f220ba5052d > llvm::WebAssembly::getLibcallSignature(llvm::WebAssemblySubtarget const&, > llvm::StringRef, llvm::SmallVectorImpl&, > llvm::SmallVectorImpl&) > /tmp/llvm/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp:907:30 > #10 0x7f220b9c4e0f > llvm::WebAssemblyAsmPrinter::getOrCreateWasmSymbol(llvm::StringRef) > /tmp/llvm/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:0:5 > #11 0x7f220b9c4f46 llvm::WebAssemblyAsmPrinter::emitDecls(llvm::Module > const&) /tmp/llvm/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:310:40 > #12 0x7f220b9c7179 llvm::WebAssemblyAsmPrinter::emitConstantPool() > /tmp/llvm/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:604:3 > #13 0x7f2206ee9526 llvm::AsmPrinter::emitFunctionHeader() > /tmp/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:966:3 > ``` > > This file contains the script and preprocessed source that reproduce the > problem: > [ctanh.zip](https://github.com/user-attachments/files/15783347/ctanh.zip) This seems to be because the WASM backend does some non standard things setting up a libcall to type signature map. I put up a fix #95082. I typically would just revert, but the fix is so compact i think it makes more sense to merge a fix to unblock. That said i'm not a regular WASM contributor so i'm going to go back to bed and wait till i get some guidance from those folks. https://github.com/llvm/llvm-project/pull/94559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -484,10 +484,31 @@ MC/DC Instrumentation - When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the -clang option ``-fcoverage-mcdc``, users are limited to at most **six** leaf-level -conditions in a boolean expression. A warning will be generated for boolean -expressions that contain more than six, and they will not be instrumented for -MC/DC. +clang option ``-fcoverage-mcdc``, there are two hard limits. + +The maximum number of terms is limited to 32767, which is practical for +handwritten expressions. To be more restrictive in order to enforce coding rules, +use ``-Xclang -fmcdc-max-conditions=n``. Expressions with exceeded condition +counts ``n`` will generate warnings. + +The number of test vectors (the maximum number of possible combinations of +expressions) is limited to 2,147,483,646. In this case, approximately +256MiB (==2GiB/8) is used to record test vectors. + +To reduce memory usage, you can limit the maximum number of test vectors per chapuni wrote: Done -- s/you/users/ https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in annotating lambda l_square (PR #95084)
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/95084 Fixes #95072. >From b89f8a5bcbf525d779565219951359162655929e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 11 Jun 2024 01:32:32 -0700 Subject: [PATCH] [clang-format] Fix a bug in annotating lambda l_square Fixes #95072. --- clang/lib/Format/UnwrappedLineParser.cpp | 2 ++ clang/unittests/Format/TokenAnnotatorTest.cpp | 6 ++ 2 files changed, 8 insertions(+) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index eb96b54ec4c96..08387d2e08ee0 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2257,6 +2257,8 @@ bool UnwrappedLineParser::tryToParseLambda() { break; case tok::kw_auto: case tok::kw_class: +case tok::kw_struct: +case tok::kw_union: case tok::kw_template: case tok::kw_typename: case tok::amp: diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 3d609a1f041bc..0a1fb8c657ceb 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -1591,6 +1591,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) { EXPECT_TOKEN(Tokens[15], tok::arrow, TT_TrailingReturnArrow); EXPECT_TOKEN(Tokens[17], tok::l_brace, TT_LambdaLBrace); + Tokens = annotate("auto l = [] -> struct S { return {}; };"); + ASSERT_EQ(Tokens.size(), 16u) << Tokens; + EXPECT_TOKEN(Tokens[3], tok::l_square, TT_LambdaLSquare); + EXPECT_TOKEN(Tokens[5], tok::arrow, TT_TrailingReturnArrow); + EXPECT_TOKEN(Tokens[8], tok::l_brace, TT_LambdaLBrace); + Tokens = annotate("[] () {}"); ASSERT_EQ(Tokens.size(), 11u) << Tokens; EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in annotating lambda l_square (PR #95084)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) Changes Fixes #95072. --- Full diff: https://github.com/llvm/llvm-project/pull/95084.diff 2 Files Affected: - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+2) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+6) ``diff diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index eb96b54ec4c96..08387d2e08ee0 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2257,6 +2257,8 @@ bool UnwrappedLineParser::tryToParseLambda() { break; case tok::kw_auto: case tok::kw_class: +case tok::kw_struct: +case tok::kw_union: case tok::kw_template: case tok::kw_typename: case tok::amp: diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 3d609a1f041bc..0a1fb8c657ceb 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -1591,6 +1591,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) { EXPECT_TOKEN(Tokens[15], tok::arrow, TT_TrailingReturnArrow); EXPECT_TOKEN(Tokens[17], tok::l_brace, TT_LambdaLBrace); + Tokens = annotate("auto l = [] -> struct S { return {}; };"); + ASSERT_EQ(Tokens.size(), 16u) << Tokens; + EXPECT_TOKEN(Tokens[3], tok::l_square, TT_LambdaLSquare); + EXPECT_TOKEN(Tokens[5], tok::arrow, TT_TrailingReturnArrow); + EXPECT_TOKEN(Tokens[8], tok::l_brace, TT_LambdaLBrace); + Tokens = annotate("[] () {}"); ASSERT_EQ(Tokens.size(), 11u) << Tokens; EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare); `` https://github.com/llvm/llvm-project/pull/95084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Remove a redundant check in Mangle. NFC (PR #95071)
https://github.com/NagyDonat approved this pull request. https://github.com/llvm/llvm-project/pull/95071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)
owenca wrote: > Am I right that no one has a major issue with the patch? So fixing the > "const" issue and adding a unit test will let that in? Can you add a unit test? https://github.com/llvm/llvm-project/pull/91317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [RISCV] Make M imply Zmmul (PR #95070)
https://github.com/jacquesguan updated https://github.com/llvm/llvm-project/pull/95070 >From dfbbcec9140f625309f78ca98c45b26b89fb71b1 Mon Sep 17 00:00:00 2001 From: Jianjian GUAN Date: Thu, 6 Jun 2024 14:21:12 +0800 Subject: [PATCH] [RISCV] Make M imply Zmmul According to the spec, M implies Zmmul. --- clang/lib/Basic/Targets/RISCV.cpp | 2 +- .../CodeGen/RISCV/riscv-func-attr-target.c| 24 +++--- lld/test/ELF/lto/riscv-attributes.ll | 10 +++--- lld/test/ELF/riscv-attributes.s | 20 ++-- .../Target/RISCV/GISel/RISCVLegalizerInfo.cpp | 2 +- llvm/lib/Target/RISCV/RISCVFeatures.td| 20 ++-- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 7 ++-- llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 2 +- llvm/lib/Target/RISCV/RISCVInstrInfoM.td | 20 ++-- llvm/lib/Target/RISCV/RISCVInstrInfoZc.td | 6 ++-- .../CodeGen/RISCV/attributes-module-flag.ll | 4 +-- llvm/test/CodeGen/RISCV/attributes.ll | 22 ++--- llvm/test/MC/RISCV/attribute-arch.s | 14 llvm/test/MC/RISCV/attribute.s| 4 +-- llvm/test/MC/RISCV/default-build-attributes.s | 4 +-- llvm/test/MC/RISCV/rv32zcb-valid.s| 2 +- .../TargetParser/RISCVISAInfoTest.cpp | 32 --- 17 files changed, 101 insertions(+), 94 deletions(-) diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp index a7ce9dda34bdd..25ae7d64b577e 100644 --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -168,7 +168,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts, Twine(getVersionValue(ExtInfo.Major, ExtInfo.Minor))); } - if (ISAInfo->hasExtension("m") || ISAInfo->hasExtension("zmmul")) + if (ISAInfo->hasExtension("zmmul")) Builder.defineMacro("__riscv_mul"); if (ISAInfo->hasExtension("m")) { diff --git a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c index 1f8682179ea81..aeddbc4ebf689 100644 --- a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c +++ b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c @@ -66,16 +66,16 @@ void test_rvv_f64_type_w_zve64d() { } //. -// CHECK: attributes #0 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zifencei,-relax,-zbb,-zfa" } -// CHECK: attributes #1 = { {{.*}}"target-cpu"="rocket-rv64" "target-features"="+64bit,+a,+d,+f,+m,+save-restore,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-relax,-zbb,-zfa" "tune-cpu"="generic-rv64" } -// CHECK: attributes #2 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zbb,+zifencei,-relax,-zfa" } -// CHECK: attributes #3 = { {{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+v,+zbb,+zicond,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-relax,-zfa" } +// CHECK: attributes #0 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zifencei,+zmmul,-relax,-zbb,-zfa" } +// CHECK: attributes #1 = { {{.*}}"target-cpu"="rocket-rv64" "target-features"="+64bit,+a,+d,+f,+m,+save-restore,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-relax,-zbb,-zfa" "tune-cpu"="generic-rv64" } +// CHECK: attributes #2 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zbb,+zifencei,+zmmul,-relax,-zfa" } +// CHECK: attributes #3 = { {{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+v,+zbb,+zicond,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-relax,-zfa" } // Make sure we append negative features if we override the arch -// CHECK: attributes #4 = { {{.*}}"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zbb,+zicsr,+zifencei,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}" } -// CHECK: attributes #5 = { {{.*}}"target-features"="+64bit,+m,+save-restore,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}" } -// CHECK: attributes #6 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+a,+m,+save-restore,+zbb,+zifencei,-relax,-zfa" } -// CHECK: attributes #7 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+m,+save-restore,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}" } -// CHECK: attributes #8 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zicsr,+zifencei,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}" } -// CHECK: attributes #9 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zicsr,+zifencei,+zve32x,+zvl32b,-relax,-zbb,-zfa" } -// CHECK: attributes #11 = { {{.*}}"target-features"="+64bit,+a,+f,+m,+save-restore,+zicsr,+zifencei,+zve32f,+zve32x,+zvl32b,-relax,-zbb,-zfa" } -// CHECK: attributes #12 = { {{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl32b,+zvl64b,-relax,-zbb,-zfa" } +// CHECK: attributes #4 = { {{.*}}"target-features"="+64b
[libclc] [CMake][libclc] Improve dependencies to avoid build errors (PR #95018)
frasercrmck wrote: Hmm, isn't CMake fun? Thanks for looking into this. Unfortunately the file-level dependencies are there for a reason. With this patch, if I `rm builtins.link.nvptx64--.bc` and build `builtins.opt.nvptx64--` (with `ninja`), it builds the `link` target but doesn't actually rebuild the `opt` target. On `main`, it does do this. We need to preserve that behaviour, or developers will see stale builds and that will lead to all sorts of problems. I found [example #5 of this example](https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands) interesting when I was initially implementing this. CMake's dependencies are really strange. Going by the documentation you link, could we have _both_ the file- and the target-level dependency? Note how the [example](https://cmake.org/cmake/help/v3.29/command/add_custom_command.html#example-generating-files-for-multiple-targets) has `DEPENDS table.csv generate_table_csv` in *both* parallel targets, so the file-level dependency `foo.csv` *is* being used twice - but also supplying the target-level dependency prevents it from being a race condition? https://github.com/llvm/llvm-project/pull/95018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)
@@ -15883,6 +15883,95 @@ The returned value is completely identical to the input except for the sign bit; in particular, if the input is a NaN, then the quiet/signaling bit and payload are perfectly preserved. +.. _i_fminmax_family: + +'``llvm.min.*``' Intrinsics Comparation +^^^ + +Standard: +" + +IEEE754 and ISO C define some min/max operations, and they have some differences +on working with qNaN/sNaN and +0.0/-0.0. Here is the list: + +.. list-table:: + :header-rows: 2 + + * - ``ISO C`` + - fmin/fmax + - none + - fmininum/fmaximum + - fminimum_num/fmaximum_num + + * - ``IEEE754`` + - none + - nimNUM/maxNUM (2008) + - minimum/maximum (2019) + - minimumNumber/maximumNumber (2019) + + * - ``+0.0 vs -0.0`` + - either one + - +0.0 > -0.0 wzssyqa wrote: Thanks. You are right. I was confused by the hardware implementations of some hardware. ARM/MIPSr6/PowerPC implement +0.0>-0.0. https://github.com/llvm/llvm-project/pull/93841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 529b43c - [clang][Interp] Refine diagnostics for casts from void*
Author: Timm Bäder Date: 2024-06-11T11:19:06+02:00 New Revision: 529b43c1fd435e1544bbd581fcf7191c3edfa20e URL: https://github.com/llvm/llvm-project/commit/529b43c1fd435e1544bbd581fcf7191c3edfa20e DIFF: https://github.com/llvm/llvm-project/commit/529b43c1fd435e1544bbd581fcf7191c3edfa20e.diff LOG: [clang][Interp] Refine diagnostics for casts from void* This is still not perfect, but an improvement in general. Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/lib/AST/Interp/Interp.h clang/lib/AST/Interp/Opcodes.td Removed: diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 6654a27c92168..0899a98b3b95a 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -318,7 +318,8 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr *CE) { if (DiscardResult) return this->discard(SubExpr); -std::optional FromT = classify(SubExpr->getType()); +QualType SubExprTy = SubExpr->getType(); +std::optional FromT = classify(SubExprTy); std::optional ToT = classify(CE->getType()); if (!FromT || !ToT) return false; @@ -326,9 +327,14 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr *CE) { assert(isPtrType(*FromT)); assert(isPtrType(*ToT)); if (FromT == ToT) { - if (SubExpr->getType()->isVoidPointerType()) -return this->visit(SubExpr) && this->emitVoidPtrCast(CE); - return this->delegate(SubExpr); + if (CE->getType()->isVoidPointerType()) +return this->delegate(SubExpr); + + if (!this->visit(SubExpr)) +return false; + if (FromT == PT_Ptr) +return this->emitPtrPtrCast(SubExprTy->isVoidPointerType(), CE); + return true; } if (!this->visit(SubExpr)) diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index 0ad710c5ec1af..784e138e1467d 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -1980,10 +1980,25 @@ static inline bool CastPointerIntegralAPS(InterpState &S, CodePtr OpPC, return true; } -static inline bool VoidPtrCast(InterpState &S, CodePtr OpPC) { - const SourceInfo &E = S.Current->getSource(OpPC); - S.CCEDiag(E, diag::note_constexpr_invalid_cast) - << 2 << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC); +static inline bool PtrPtrCast(InterpState &S, CodePtr OpPC, bool SrcIsVoidPtr) { + const auto &Ptr = S.Stk.peek(); + + if (SrcIsVoidPtr && S.getLangOpts().CPlusPlus) { +bool HasValidResult = !Ptr.isZero(); + +if (HasValidResult) { + // FIXME: note_constexpr_invalid_void_star_cast +} else if (!S.getLangOpts().CPlusPlus26) { + const SourceInfo &E = S.Current->getSource(OpPC); + S.CCEDiag(E, diag::note_constexpr_invalid_cast) + << 3 << "'void *'" << S.Current->getRange(OpPC); +} + } else { +const SourceInfo &E = S.Current->getSource(OpPC); +S.CCEDiag(E, diag::note_constexpr_invalid_cast) +<< 2 << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC); + } + return true; } diff --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td index ac5426c87c212..45fc11e564576 100644 --- a/clang/lib/AST/Interp/Opcodes.td +++ b/clang/lib/AST/Interp/Opcodes.td @@ -665,7 +665,10 @@ def CastPointerIntegralAPS : Opcode { let HasGroup = 0; let Args = [ArgUint32]; } -def VoidPtrCast : Opcode; +def PtrPtrCast : Opcode { + let Args = [ArgBool]; + +} def DecayPtr : Opcode { let Types = [PtrTypeClass, PtrTypeClass]; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ec81c9b - [clang] Remove a redundant check in Mangle. NFC (#95071)
Author: Pavel Samolysov Date: 2024-06-11T12:24:46+03:00 New Revision: ec81c9b1dd856dbe77b042e7d293e437b587d914 URL: https://github.com/llvm/llvm-project/commit/ec81c9b1dd856dbe77b042e7d293e437b587d914 DIFF: https://github.com/llvm/llvm-project/commit/ec81c9b1dd856dbe77b042e7d293e437b587d914.diff LOG: [clang] Remove a redundant check in Mangle. NFC (#95071) This addresses a review comment for PR #94987 Because that PR is a big automatic change, this change was moved in a separate one. Added: Modified: clang/lib/AST/Mangle.cpp Removed: diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index 4af4d7c00c5cb..4fbf0e3b42dbc 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -301,9 +301,8 @@ void MangleContext::mangleBlock(const DeclContext *DC, const BlockDecl *BD, } else { assert((isa(DC) || isa(DC)) && "expected a NamedDecl or BlockDecl"); -if (isa(DC)) - for (; isa_and_nonnull(DC); DC = DC->getParent()) -(void) getBlockId(cast(DC), true); +for (; isa_and_nonnull(DC); DC = DC->getParent()) + (void)getBlockId(cast(DC), true); assert((isa(DC) || isa(DC)) && "expected a TranslationUnitDecl or a NamedDecl"); if (const auto *CD = dyn_cast(DC)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Remove a redundant check in Mangle. NFC (PR #95071)
https://github.com/samolisov closed https://github.com/llvm/llvm-project/pull/95071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)
pointhex wrote: > Can you add a unit test? Yes, no problem, I just didn't get if it is needed or not. Could you please tell me if you already have a unit test for that function and where? I didn't manage to find it. https://github.com/llvm/llvm-project/pull/91317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)
@@ -15883,6 +15883,95 @@ The returned value is completely identical to the input except for the sign bit; in particular, if the input is a NaN, then the quiet/signaling bit and payload are perfectly preserved. +.. _i_fminmax_family: + +'``llvm.min.*``' Intrinsics Comparation +^^^ + +Standard: +" + +IEEE754 and ISO C define some min/max operations, and they have some differences +on working with qNaN/sNaN and +0.0/-0.0. Here is the list: + +.. list-table:: + :header-rows: 2 + + * - ``ISO C`` + - fmin/fmax + - none + - fmininum/fmaximum + - fminimum_num/fmaximum_num + + * - ``IEEE754`` + - none + - nimNUM/maxNUM (2008) + - minimum/maximum (2019) + - minimumNumber/maximumNumber (2019) + + * - ``+0.0 vs -0.0`` + - either one + - +0.0 > -0.0 + - +0.0 > -0.0 + - +0.0 > -0.0 + + * - ``NUM/qNaN vs sNaN`` + - qNaN, invalid exception + - qNaN, invalid exception + - qNaN, invalid exception + - NUM/qNaN, invalid exception + + * - ``NUM/qNaN vs qNaN`` + - NUM/qNaN, no excpetion wzssyqa wrote: And I split it to `NUM vs qNaN` and `qNaN vs qNaN`. https://github.com/llvm/llvm-project/pull/93841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)
@@ -15883,6 +15883,95 @@ The returned value is completely identical to the input except for the sign bit; in particular, if the input is a NaN, then the quiet/signaling bit and payload are perfectly preserved. +.. _i_fminmax_family: + +'``llvm.min.*``' Intrinsics Comparation +^^^ + +Standard: +" + +IEEE754 and ISO C define some min/max operations, and they have some differences +on working with qNaN/sNaN and +0.0/-0.0. Here is the list: + +.. list-table:: + :header-rows: 2 + + * - ``ISO C`` + - fmin/fmax + - none + - fmininum/fmaximum + - fminimum_num/fmaximum_num + + * - ``IEEE754`` + - none + - nimNUM/maxNUM (2008) + - minimum/maximum (2019) + - minimumNumber/maximumNumber (2019) + + * - ``+0.0 vs -0.0`` + - either one + - +0.0 > -0.0 + - +0.0 > -0.0 + - +0.0 > -0.0 + + * - ``NUM/qNaN vs sNaN`` + - qNaN, invalid exception + - qNaN, invalid exception + - qNaN, invalid exception + - NUM/qNaN, invalid exception + + * - ``NUM/qNaN vs qNaN`` + - NUM/qNaN, no excpetion wzssyqa wrote: For more details about sNaN on constrained intrinsics, we may need to update them in future PRs. Since this PR is only about add `minimumnum and maximumnum`. https://github.com/llvm/llvm-project/pull/93841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)
@@ -15868,6 +15868,51 @@ The returned value is completely identical to the input except for the sign bit; in particular, if the input is a NaN, then the quiet/signaling bit and payload are perfectly preserved. +.. _i_fminmax_family: + +'``llvm.min.*``' Intrinsics Comparation +^^^ + +.. list-table:: + :header-rows: 1 + :widths: 16 28 28 28 + + * - Operation + - minnum/maxnum + - minimum/maximum + - minimumnum/maximumnum + + * - ``NUM vs qNaN`` + - NUM, no exception + - qNaN, no exception + - qNaN, no exception + + * - ``NUM vs sNaN`` + - qNaN, invalid exception + - qNaN, invalid exception + - NUM, invalid exception + + * - ``qNaN vs sNaN`` + - qNaN, invalid exception + - qNaN, invalid exception + - qNaN, invalid exception + + * - ``sNaN vs sNaN`` + - qNaN, invalid exception + - qNaN, invalid exception + - qNaN, invalid exception + + * - ``+0.0 vs -0.0`` + - either one + - +0.0(max)/-0.0(min) + - +0.0(max)/-0.0(min) + + * - ``NUM vs NUM`` + - larger(max)/smaller(min) + - larger(max)/smaller(min) + - larger(max)/smaller(min) wzssyqa wrote: Sorry, I guess that I am not full understanding "LLVM's NaN-handling policy". As my understanding, for fmax*, we should fellow the libc's semantics. https://github.com/llvm/llvm-project/pull/93841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)
@@ -15868,6 +15868,51 @@ The returned value is completely identical to the input except for the sign bit; in particular, if the input is a NaN, then the quiet/signaling bit and payload are perfectly preserved. +.. _i_fminmax_family: + +'``llvm.min.*``' Intrinsics Comparation +^^^ + +.. list-table:: + :header-rows: 1 + :widths: 16 28 28 28 + + * - Operation + - minnum/maxnum + - minimum/maximum + - minimumnum/maximumnum + + * - ``NUM vs qNaN`` + - NUM, no exception + - qNaN, no exception + - qNaN, no exception + + * - ``NUM vs sNaN`` + - qNaN, invalid exception + - qNaN, invalid exception + - NUM, invalid exception + + * - ``qNaN vs sNaN`` + - qNaN, invalid exception + - qNaN, invalid exception + - qNaN, invalid exception + + * - ``sNaN vs sNaN`` + - qNaN, invalid exception + - qNaN, invalid exception + - qNaN, invalid exception + + * - ``+0.0 vs -0.0`` + - either one + - +0.0(max)/-0.0(min) + - +0.0(max)/-0.0(min) + + * - ``NUM vs NUM`` + - larger(max)/smaller(min) + - larger(max)/smaller(min) + - larger(max)/smaller(min) wzssyqa wrote: For constrained ones, I guess that we should add more details in another PR(s). https://github.com/llvm/llvm-project/pull/93841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/95096 The same has been done in a couple other existing tests, that also are skipped on Windows (e.g. ld-path.c). Some tests that really do want to test setting the path on Windows does it differently, see e.g. ps4-ps5-linker-win.c. Since a65771fce4a2f25f16d4b3918ad6a11370637f7b, the spirv-toolchain.cl test does one test where PATH is set. Setting PATH does work in some build configurations - however, if built with e.g. llvm-mingw, the built Clang executable depends on libc++.dll (and libunwind.dll) which are found in PATH. If the PATH is overridden, the newly built Clang executable no longer can run. From 1608c828eaeb6ca37702817384930fa44b0612f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 11 Jun 2024 13:14:47 +0300 Subject: [PATCH] [clang] [test] Skip a test that sets PATH= on Windows The same has been done in a couple other existing tests, that also are skipped on Windows (e.g. ld-path.c). Some tests that really do want to test setting the path on Windows does it differently, see e.g. ps4-ps5-linker-win.c. Since a65771fce4a2f25f16d4b3918ad6a11370637f7b, the spirv-toolchain.cl test does one test where PATH is set. Setting PATH does work in some build configurations - however, if built with e.g. llvm-mingw, the built Clang executable depends on libc++.dll (and libunwind.dll) which are found in PATH. If the PATH is overridden, the newly built Clang executable no longer can run. --- clang/test/Driver/spirv-toolchain.cl | 5 + 1 file changed, 5 insertions(+) diff --git a/clang/test/Driver/spirv-toolchain.cl b/clang/test/Driver/spirv-toolchain.cl index de818177cb19f..2c9f9db80cad6 100644 --- a/clang/test/Driver/spirv-toolchain.cl +++ b/clang/test/Driver/spirv-toolchain.cl @@ -1,3 +1,8 @@ +/// One test uses the PATH environment variable; on Windows, we may need to retain +/// the original path for the built Clang binary to be able to execute (as it is +/// used for locating dependent DLLs). +// UNSUPPORTED: system-windows + // Check object emission. // RUN: %clang -### --target=spirv64 -x cl -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s // RUN: %clang -### --target=spirv64 %s 2>&1 | FileCheck --check-prefix=SPV64 %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
mstorsjo wrote: CC @linehill https://github.com/llvm/llvm-project/pull/95096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
llvmbot wrote: @llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Martin Storsjö (mstorsjo) Changes The same has been done in a couple other existing tests, that also are skipped on Windows (e.g. ld-path.c). Some tests that really do want to test setting the path on Windows does it differently, see e.g. ps4-ps5-linker-win.c. Since a65771fce4a2f25f16d4b3918ad6a11370637f7b, the spirv-toolchain.cl test does one test where PATH is set. Setting PATH does work in some build configurations - however, if built with e.g. llvm-mingw, the built Clang executable depends on libc++.dll (and libunwind.dll) which are found in PATH. If the PATH is overridden, the newly built Clang executable no longer can run. --- Full diff: https://github.com/llvm/llvm-project/pull/95096.diff 1 Files Affected: - (modified) clang/test/Driver/spirv-toolchain.cl (+5) ``diff diff --git a/clang/test/Driver/spirv-toolchain.cl b/clang/test/Driver/spirv-toolchain.cl index de818177cb19f..2c9f9db80cad6 100644 --- a/clang/test/Driver/spirv-toolchain.cl +++ b/clang/test/Driver/spirv-toolchain.cl @@ -1,3 +1,8 @@ +/// One test uses the PATH environment variable; on Windows, we may need to retain +/// the original path for the built Clang binary to be able to execute (as it is +/// used for locating dependent DLLs). +// UNSUPPORTED: system-windows + // Check object emission. // RUN: %clang -### --target=spirv64 -x cl -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s // RUN: %clang -### --target=spirv64 %s 2>&1 | FileCheck --check-prefix=SPV64 %s `` https://github.com/llvm/llvm-project/pull/95096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)
https://github.com/Andarwinux updated https://github.com/llvm/llvm-project/pull/94731 >From 5b1765b4609ab65c03bd6bed051672dc75872329 Mon Sep 17 00:00:00 2001 From: Andarwinux <144242044+andarwi...@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:07:40 + Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver fixes #91216 --- clang/include/clang/Driver/Options.td | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d44faa55c456f..1cce7a5146dd8 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">, Alias<_SLASH_winsdkdir>; def : Separate<["-"], "Xmicrosoft-windows-sdk-version">, Alias<_SLASH_winsdkversion>; +def : Separate<["-"], "Xmicrosoft-windows-sys-root">, +Alias<_SLASH_winsysroot>; // Ignored: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in annotating lambda l_square (PR #95084)
https://github.com/rymiel approved this pull request. https://github.com/llvm/llvm-project/pull/95084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)
https://github.com/Rajveer100 updated https://github.com/llvm/llvm-project/pull/94159 >From 765176a735a922c404502c927338d90853335923 Mon Sep 17 00:00:00 2001 From: Rajveer Date: Sun, 2 Jun 2024 18:33:37 +0530 Subject: [PATCH] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable Resolves #93066 --- .../clang/Basic/DiagnosticSemaKinds.td| 3 ++ clang/lib/Sema/SemaExpr.cpp | 23 - clang/test/C/drs/dr1xx.c | 1 + clang/test/Sema/debug-93066.cpp | 49 +++ clang/test/Sema/exprs.c | 2 + clang/test/Sema/va_arg_x86_32.c | 1 + clang/test/SemaObjCXX/sel-address.mm | 13 + 7 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 clang/test/Sema/debug-93066.cpp diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 270b0a1e01307..986d454decab6 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8777,6 +8777,9 @@ def err_typecheck_incomplete_type_not_modifiable_lvalue : Error< def err_typecheck_lvalue_casts_not_supported : Error< "assignment to cast is illegal, lvalue casts are not supported">; +def note_typecheck_add_deref_star_not_modifiable_lvalue : Note< + "add '*' to dereference it">; + def err_typecheck_duplicate_vector_components_not_mlvalue : Error< "vector is not assignable (contains duplicate components)">; def err_block_decl_ref_not_modifiable_lvalue : Error< diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ff9c5ead36dcf..b585d1c0270b9 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -13273,6 +13273,22 @@ enum { ConstUnknown, // Keep as last element }; +static void MaybeSuggestDerefFixIt(Sema &S, const Expr *E, SourceLocation Loc) { + ExprResult Deref; + Expr *TE = const_cast(E); + { +Sema::TentativeAnalysisScope Trap(S); +Deref = S.ActOnUnaryOp(S.getCurScope(), Loc, tok::star, TE); + } + if (Deref.isUsable() && + Deref.get()->isModifiableLvalue(S.Context, &Loc) == Expr::MLV_Valid && + !E->getType()->isObjCObjectPointerType()) { +S.Diag(Loc, diag::note_typecheck_add_deref_star_not_modifiable_lvalue) +<< E->getSourceRange() +<< FixItHint::CreateInsertion(E->getBeginLoc(), "*"); + } +} + /// Emit the "read-only variable not assignable" error and print notes to give /// more information about why the variable is not assignable, such as pointing /// to the declaration of a const variable, showing that a method is const, or @@ -13367,6 +13383,7 @@ static void DiagnoseConstAssignment(Sema &S, const Expr *E, if (!DiagnosticEmitted) { S.Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstVariable << VD << VD->getType(); + MaybeSuggestDerefFixIt(S, E, Loc); DiagnosticEmitted = true; } S.Diag(VD->getLocation(), diag::note_typecheck_assign_const) @@ -13587,10 +13604,12 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) { SourceRange Assign; if (Loc != OrigLoc) Assign = SourceRange(OrigLoc, OrigLoc); - if (NeedType) + if (NeedType) { S.Diag(Loc, DiagID) << E->getType() << E->getSourceRange() << Assign; - else + } else { S.Diag(Loc, DiagID) << E->getSourceRange() << Assign; +MaybeSuggestDerefFixIt(S, E, Loc); + } return true; } diff --git a/clang/test/C/drs/dr1xx.c b/clang/test/C/drs/dr1xx.c index 47538e44428c3..20e953b2c20ac 100644 --- a/clang/test/C/drs/dr1xx.c +++ b/clang/test/C/drs/dr1xx.c @@ -296,6 +296,7 @@ void dr126(void) { */ *object = 12; /* ok */ ++object; /* expected-error {{cannot assign to variable 'object' with const-qualified type 'const IP' (aka 'int *const')}} */ + /* expected-note@-1 {{add '*' to dereference it}} */ } /* WG14 DR128: yes diff --git a/clang/test/Sema/debug-93066.cpp b/clang/test/Sema/debug-93066.cpp new file mode 100644 index 0..48c5f9e27c211 --- /dev/null +++ b/clang/test/Sema/debug-93066.cpp @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s + +struct S { + void f() { +++this; // expected-error {{expression is not assignable}} +// expected-note@-1 {{add '*' to dereference it}} + } + + void g() const { +++this; // expected-error {{expression is not assignable}} + } +}; + +void f(int* a, int* const b, const int* const c, __UINTPTR_TYPE__ d) { + (int*)d = 4; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}} + // expected-note@-1 {{add '*' to dereference it}} + + ++a; + ++b; // expected-error {{cannot assign to variable 'b' with const-qualified type 'int *const'}} + // expected-note@-1 {{add '*' to dereference it}} + // expected-note@* {{variable 'b' declared const here}} + ++c; // expected-error {{ca
[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)
@@ -2220,23 +2220,103 @@ namespace { class ExtractTypeForDeductionGuide : public TreeTransform { llvm::SmallVectorImpl &MaterializedTypedefs; + ClassTemplateDecl *NestedPattern; + const MultiLevelTemplateArgumentList *OuterInstantiationArgs; public: typedef TreeTransform Base; ExtractTypeForDeductionGuide( Sema &SemaRef, - llvm::SmallVectorImpl &MaterializedTypedefs) - : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs) {} + llvm::SmallVectorImpl &MaterializedTypedefs, + ClassTemplateDecl *NestedPattern, + const MultiLevelTemplateArgumentList *OuterInstantiationArgs) + : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs), +NestedPattern(NestedPattern), +OuterInstantiationArgs(OuterInstantiationArgs) {} TypeSourceInfo *transform(TypeSourceInfo *TSI) { return TransformType(TSI); } + /// Returns true if it's safe to substitute \p Typedef with + /// \p OuterInstantiationArgs. + bool mightReferToOuterTemplateParameters(TypedefNameDecl *Typedef) { +if (!NestedPattern) + return false; + +static auto WalkUp = [](DeclContext *DC, DeclContext *TargetDC) { + if (DC->Equals(TargetDC)) +return true; + while (DC->isRecord()) { +if (DC->Equals(TargetDC)) + return true; +DC = DC->getParent(); + } + return false; +}; + +if (WalkUp(Typedef->getDeclContext(), NestedPattern->getTemplatedDecl())) + return true; +if (WalkUp(NestedPattern->getTemplatedDecl(), Typedef->getDeclContext())) + return true; +return false; + } + + QualType + RebuildTemplateSpecializationType(TemplateName Template, +SourceLocation TemplateNameLoc, +TemplateArgumentListInfo &TemplateArgs) { +if (!OuterInstantiationArgs || +!isa_and_present(Template.getAsTemplateDecl())) + return Base::RebuildTemplateSpecializationType(Template, TemplateNameLoc, + TemplateArgs); + +auto *TATD = cast(Template.getAsTemplateDecl()); +auto *Pattern = TATD; +while (Pattern->getInstantiatedFromMemberTemplate()) + Pattern = Pattern->getInstantiatedFromMemberTemplate(); +if (!mightReferToOuterTemplateParameters(Pattern->getTemplatedDecl())) + return Base::RebuildTemplateSpecializationType(Template, TemplateNameLoc, + TemplateArgs); + +Decl *NewD = SemaRef.SubstDecl( +TATD, SemaRef.getASTContext().getTranslationUnitDecl(), hokein wrote: Passing the `TranslationUnitDecl` seems wrong -- the NewD will be attached to the TU, I think we should use the `DC` member in `ConvertConstructorToDeductionGuideTransform`. https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)
@@ -16,3 +16,73 @@ using T = A::B; using Copy = decltype(copy); using Copy = A::B; + +namespace GH94614 { + +template struct S {}; hokein wrote: I wonder whether it is feasible to add an ast-dump test for this issue, I find seeing and verifying the shape of AST deduction guide is clearer. However, the ast-dump doesn't seem to dump much information about the type of the function parameter decl, which is the information we want to verify. https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)
https://github.com/hokein commented: Looks roughly good to me. https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)
@@ -2220,23 +2220,103 @@ namespace { class ExtractTypeForDeductionGuide : public TreeTransform { llvm::SmallVectorImpl &MaterializedTypedefs; + ClassTemplateDecl *NestedPattern; + const MultiLevelTemplateArgumentList *OuterInstantiationArgs; public: typedef TreeTransform Base; ExtractTypeForDeductionGuide( Sema &SemaRef, - llvm::SmallVectorImpl &MaterializedTypedefs) - : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs) {} + llvm::SmallVectorImpl &MaterializedTypedefs, + ClassTemplateDecl *NestedPattern, + const MultiLevelTemplateArgumentList *OuterInstantiationArgs) + : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs), +NestedPattern(NestedPattern), +OuterInstantiationArgs(OuterInstantiationArgs) {} TypeSourceInfo *transform(TypeSourceInfo *TSI) { return TransformType(TSI); } + /// Returns true if it's safe to substitute \p Typedef with + /// \p OuterInstantiationArgs. + bool mightReferToOuterTemplateParameters(TypedefNameDecl *Typedef) { +if (!NestedPattern) + return false; + +static auto WalkUp = [](DeclContext *DC, DeclContext *TargetDC) { + if (DC->Equals(TargetDC)) +return true; + while (DC->isRecord()) { +if (DC->Equals(TargetDC)) + return true; +DC = DC->getParent(); + } + return false; +}; + +if (WalkUp(Typedef->getDeclContext(), NestedPattern->getTemplatedDecl())) + return true; +if (WalkUp(NestedPattern->getTemplatedDecl(), Typedef->getDeclContext())) + return true; +return false; + } + + QualType + RebuildTemplateSpecializationType(TemplateName Template, +SourceLocation TemplateNameLoc, +TemplateArgumentListInfo &TemplateArgs) { +if (!OuterInstantiationArgs || +!isa_and_present(Template.getAsTemplateDecl())) + return Base::RebuildTemplateSpecializationType(Template, TemplateNameLoc, + TemplateArgs); + +auto *TATD = cast(Template.getAsTemplateDecl()); +auto *Pattern = TATD; +while (Pattern->getInstantiatedFromMemberTemplate()) + Pattern = Pattern->getInstantiatedFromMemberTemplate(); +if (!mightReferToOuterTemplateParameters(Pattern->getTemplatedDecl())) + return Base::RebuildTemplateSpecializationType(Template, TemplateNameLoc, + TemplateArgs); + +Decl *NewD = SemaRef.SubstDecl( +TATD, SemaRef.getASTContext().getTranslationUnitDecl(), +*OuterInstantiationArgs); +if (!NewD) + return QualType(); + +auto *NewTATD = cast(NewD); +MaterializedTypedefs.push_back(NewTATD->getTemplatedDecl()); + +return Base::RebuildTemplateSpecializationType( +TemplateName(NewTATD), TemplateNameLoc, TemplateArgs); + } + QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) { ASTContext &Context = SemaRef.getASTContext(); TypedefNameDecl *OrigDecl = TL.getTypedefNameDecl(); TypedefNameDecl *Decl = OrigDecl; // Transform the underlying type of the typedef and clone the Decl only if // the typedef has a dependent context. -if (OrigDecl->getDeclContext()->isDependentContext()) { +bool InDependentContext = OrigDecl->getDeclContext()->isDependentContext(); + +// A typedef/alias Decl within the NestedPattern may reference the outer +// template parameters. They're substituted with corresponding instantiation +// arguments here and in RebuildTemplateSpecializationType() above. +// Otherwise, we would have a CTAD guide with "dangling" template +// parameters. +// For example, +// template struct Outer { +// using Alias = S; +// template struct Inner { +// Inner(Alias); +// }; +// }; +if (OuterInstantiationArgs && InDependentContext) { + Decl = cast_if_present(SemaRef.SubstDecl( hokein wrote: We will perform the substitution even if the typedef/alias decl doesn't have any dependent template parameter references (e.g. `using Alias = S`.), this seems unnecessary. A simple idea to avoid it is to perform the substitution only if the type of `TypedefNameDecl` is dependent. https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)
@@ -2220,23 +2220,103 @@ namespace { class ExtractTypeForDeductionGuide : public TreeTransform { llvm::SmallVectorImpl &MaterializedTypedefs; + ClassTemplateDecl *NestedPattern; + const MultiLevelTemplateArgumentList *OuterInstantiationArgs; public: typedef TreeTransform Base; ExtractTypeForDeductionGuide( Sema &SemaRef, - llvm::SmallVectorImpl &MaterializedTypedefs) - : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs) {} + llvm::SmallVectorImpl &MaterializedTypedefs, + ClassTemplateDecl *NestedPattern, + const MultiLevelTemplateArgumentList *OuterInstantiationArgs) + : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs), +NestedPattern(NestedPattern), +OuterInstantiationArgs(OuterInstantiationArgs) {} TypeSourceInfo *transform(TypeSourceInfo *TSI) { return TransformType(TSI); } + /// Returns true if it's safe to substitute \p Typedef with + /// \p OuterInstantiationArgs. + bool mightReferToOuterTemplateParameters(TypedefNameDecl *Typedef) { +if (!NestedPattern) + return false; + +static auto WalkUp = [](DeclContext *DC, DeclContext *TargetDC) { + if (DC->Equals(TargetDC)) +return true; + while (DC->isRecord()) { +if (DC->Equals(TargetDC)) + return true; +DC = DC->getParent(); + } + return false; +}; + +if (WalkUp(Typedef->getDeclContext(), NestedPattern->getTemplatedDecl())) + return true; +if (WalkUp(NestedPattern->getTemplatedDecl(), Typedef->getDeclContext())) + return true; +return false; + } + + QualType + RebuildTemplateSpecializationType(TemplateName Template, +SourceLocation TemplateNameLoc, +TemplateArgumentListInfo &TemplateArgs) { +if (!OuterInstantiationArgs || +!isa_and_present(Template.getAsTemplateDecl())) + return Base::RebuildTemplateSpecializationType(Template, TemplateNameLoc, + TemplateArgs); + +auto *TATD = cast(Template.getAsTemplateDecl()); +auto *Pattern = TATD; +while (Pattern->getInstantiatedFromMemberTemplate()) + Pattern = Pattern->getInstantiatedFromMemberTemplate(); +if (!mightReferToOuterTemplateParameters(Pattern->getTemplatedDecl())) + return Base::RebuildTemplateSpecializationType(Template, TemplateNameLoc, + TemplateArgs); + +Decl *NewD = SemaRef.SubstDecl( +TATD, SemaRef.getASTContext().getTranslationUnitDecl(), +*OuterInstantiationArgs); +if (!NewD) + return QualType(); + +auto *NewTATD = cast(NewD); +MaterializedTypedefs.push_back(NewTATD->getTemplatedDecl()); + +return Base::RebuildTemplateSpecializationType( +TemplateName(NewTATD), TemplateNameLoc, TemplateArgs); + } + QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) { ASTContext &Context = SemaRef.getASTContext(); TypedefNameDecl *OrigDecl = TL.getTypedefNameDecl(); TypedefNameDecl *Decl = OrigDecl; // Transform the underlying type of the typedef and clone the Decl only if // the typedef has a dependent context. -if (OrigDecl->getDeclContext()->isDependentContext()) { +bool InDependentContext = OrigDecl->getDeclContext()->isDependentContext(); + +// A typedef/alias Decl within the NestedPattern may reference the outer +// template parameters. They're substituted with corresponding instantiation +// arguments here and in RebuildTemplateSpecializationType() above. +// Otherwise, we would have a CTAD guide with "dangling" template +// parameters. +// For example, +// template struct Outer { +// using Alias = S; +// template struct Inner { +// Inner(Alias); +// }; +// }; +if (OuterInstantiationArgs && InDependentContext) { + Decl = cast_if_present(SemaRef.SubstDecl( + OrigDecl, Context.getTranslationUnitDecl(), *OuterInstantiationArgs)); hokein wrote: and here as well. https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)
@@ -2630,7 +2711,8 @@ struct ConvertConstructorToDeductionGuideTransform { ParmVarDecl *transformFunctionTypeParam( ParmVarDecl *OldParam, MultiLevelTemplateArgumentList &Args, - llvm::SmallVectorImpl &MaterializedTypedefs) { + llvm::SmallVectorImpl &MaterializedTypedefs, + bool TransformingOuterPatterns = false) { hokein wrote: nit: remove this default argument for `TransformingOuterPatterns`, there is only 2 places calling this function (one for `true`, the other one for `false`) https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit distinct TBAA tags for pointers with different depths,types. (PR #76612)
https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/76612 >From 61c94b87858e51748a9664acab51ca4c964265a4 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 30 Dec 2023 10:39:58 + Subject: [PATCH] [TBAA] Emit distinct TBAA tags for pointers with different depths,types. This patch extends Clang's TBAA generation code to emit distinct tags for incompatible pointer types. Pointers with different element types are incompatible if the pointee types are also incompatible (modulo sugar/modifiers). Express this in TBAA by generating different tags for pointers based on the pointer depth and pointee type. To get the TBAA tag for the pointee type it uses getTypeInfoHelper on the pointee type. (Moved from https://reviews.llvm.org/D122573) --- clang/lib/CodeGen/CodeGenTBAA.cpp | 29 ++-- clang/test/CodeGen/tbaa-pointers.c | 72 +- 2 files changed, 67 insertions(+), 34 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index 284421f494711..d7a45173cdf8f 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/lib/CodeGen/CodeGenTBAA.cpp @@ -185,10 +185,31 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { return getChar(); // Handle pointers and references. - // TODO: Implement C++'s type "similarity" and consider dis-"similar" - // pointers distinct. - if (Ty->isPointerType() || Ty->isReferenceType()) -return createScalarTypeNode("any pointer", getChar(), Size); + if (Ty->isPointerType() || Ty->isReferenceType()) { +llvm::MDNode *AnyPtr = createScalarTypeNode("any pointer", getChar(), Size); +// Compute the depth of the pointer and generate a tag of the form "p +// ". +unsigned PtrDepth = 0; +do { + PtrDepth++; + Ty = Ty->getPointeeType().getTypePtr(); +} while (Ty->isPointerType() || Ty->isReferenceType()); +// TODO: Implement C++'s type "similarity" and consider dis-"similar" +// pointers distinct for non-builtin types. +if (isa(Ty)) { + llvm::MDNode *ScalarMD = getTypeInfoHelper(Ty); + StringRef Name = + cast( + ScalarMD->getOperand(CodeGenOpts.NewStructPathTBAA ? 2 : 0)) + ->getString(); + SmallString<256> OutName("p"); + OutName += std::to_string(PtrDepth); + OutName += " "; + OutName += Name; + return createScalarTypeNode(OutName, AnyPtr, Size); +} +return AnyPtr; + } // Accesses to arrays are accesses to objects of their element types. if (CodeGenOpts.NewStructPathTBAA && Ty->isArrayType()) diff --git a/clang/test/CodeGen/tbaa-pointers.c b/clang/test/CodeGen/tbaa-pointers.c index b9ebe87982001..a3a7aa0d66473 100644 --- a/clang/test/CodeGen/tbaa-pointers.c +++ b/clang/test/CodeGen/tbaa-pointers.c @@ -4,9 +4,9 @@ void p2unsigned(unsigned **ptr) { // CHECK-LABEL: define void @p2unsigned(ptr noundef %ptr) // CHECK-NEXT: entry: // CHECK-NEXT: %ptr.addr = alloca ptr, align 8 - // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0:!.+]] - // CHECK-NEXT: [[BASE:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]] - // CHECK-NEXT: store ptr null, ptr [[BASE]], align 8, !tbaa [[ANY_POINTER_0]] + // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[P2INT_0:!.+]] + // CHECK-NEXT: [[BASE:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[P2INT_0]] + // CHECK-NEXT: store ptr null, ptr [[BASE]], align 8, !tbaa [[P1INT_0:!.+]] // CHECK-NEXT: ret void // *ptr = 0; @@ -16,9 +16,9 @@ void p2unsigned_volatile(unsigned *volatile *ptr) { // CHECK-LABEL: define void @p2unsigned_volatile(ptr noundef %ptr) // CHECK-NEXT: entry: // CHECK-NEXT: %ptr.addr = alloca ptr, align 8 - // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]] - // CHECK-NEXT: [[BASE:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]] - // CHECK-NEXT: store volatile ptr null, ptr [[BASE]], align 8, !tbaa [[ANY_POINTER_0]] + // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[P2INT_0]] + // CHECK-NEXT: [[BASE:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[P2INT_0]] + // CHECK-NEXT: store volatile ptr null, ptr [[BASE]], align 8, !tbaa [[P1INT_0]] // CHECK-NEXT: ret void // *ptr = 0; @@ -28,10 +28,10 @@ void p3int(int ***ptr) { // CHECK-LABEL: define void @p3int(ptr noundef %ptr) // CHECK-NEXT: entry: // CHECK-NEXT: %ptr.addr = alloca ptr, align 8 - // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]] - // CHECK-NEXT: [[BASE_0:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]] - // CHECK-NEXT: [[BASE_1:%.+]] = load ptr, ptr [[BASE_0]], align 8, !tbaa [[ANY_POINTER_0]] - // CHECK-NEXT: store ptr null, ptr [[BASE_1]], align 8, !tbaa [[ANY_POINTER_0]] + // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[P3INT_0:!.+]] + // C
[clang] [DebugInfo] Change handling of structured bindings of bitfields (PR #94632)
https://github.com/john-brawn-arm updated https://github.com/llvm/llvm-project/pull/94632 >From c490a8c7d16e03066a3a4ef4985fa64fb28d Mon Sep 17 00:00:00 2001 From: John Brawn Date: Thu, 14 Mar 2024 16:17:03 + Subject: [PATCH] [DebugInfo] Change handling of structured bindings of bitfields Currently we use DW_OP_plus_uconst to handle the bitfield offset and handle the bitfield size by choosing a type size that matches, but this doesn't work if either offset or size aren't byte-aligned. Extracting the bits using DW_OP_LLVM_extract_bits means we can handle any kind of offset or size. --- clang/lib/CodeGen/CGDebugInfo.cpp | 68 +++- clang/lib/CodeGen/CGDebugInfo.h | 3 - ...debug-info-structured-binding-bitfield.cpp | 159 +++--- 3 files changed, 122 insertions(+), 108 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 11e2d549d8a45..20fd1b36ede27 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4874,40 +4874,6 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD, return D; } -llvm::DIType *CGDebugInfo::CreateBindingDeclType(const BindingDecl *BD) { - llvm::DIFile *Unit = getOrCreateFile(BD->getLocation()); - - // If the declaration is bound to a bitfield struct field, its type may have a - // size that is different from its deduced declaration type's. - if (const MemberExpr *ME = dyn_cast(BD->getBinding())) { -if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl())) { - if (FD->isBitField()) { -ASTContext &Context = CGM.getContext(); -const CGRecordLayout &RL = -CGM.getTypes().getCGRecordLayout(FD->getParent()); -const CGBitFieldInfo &Info = RL.getBitFieldInfo(FD); - -// Find an integer type with the same bitwidth as the bitfield size. If -// no suitable type is present in the target, give up on producing debug -// information as it would be wrong. It is certainly possible to produce -// correct debug info, but the logic isn't currently implemented. -uint64_t BitfieldSizeInBits = Info.Size; -QualType IntTy = -Context.getIntTypeForBitwidth(BitfieldSizeInBits, Info.IsSigned); -if (IntTy.isNull()) - return nullptr; -Qualifiers Quals = BD->getType().getQualifiers(); -QualType FinalTy = Context.getQualifiedType(IntTy, Quals); -llvm::DIType *Ty = getOrCreateType(FinalTy, Unit); -assert(Ty); -return Ty; - } -} - } - - return getOrCreateType(BD->getType(), Unit); -} - llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD, llvm::Value *Storage, std::optional ArgNo, @@ -4922,7 +4888,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD, if (isa(BD->getBinding())) return nullptr; - llvm::DIType *Ty = CreateBindingDeclType(BD); + llvm::DIFile *Unit = getOrCreateFile(BD->getLocation()); + llvm::DIType *Ty = getOrCreateType(BD->getType(), Unit); // If there is no debug info for this type then do not emit debug info // for this variable. @@ -4948,7 +4915,6 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD, unsigned Column = getColumnNumber(BD->getLocation()); StringRef Name = BD->getName(); auto *Scope = cast(LexicalBlockStack.back()); - llvm::DIFile *Unit = getOrCreateFile(BD->getLocation()); // Create the descriptor for the variable. llvm::DILocalVariable *D = DBuilder.createAutoVariable( Scope, Name, Unit, Line, Ty, CGM.getLangOpts().Optimize, @@ -4962,13 +4928,29 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD, const ASTRecordLayout &layout = CGM.getContext().getASTRecordLayout(parent); const uint64_t fieldOffset = layout.getFieldOffset(fieldIndex); - - if (fieldOffset != 0) { -// Currently if the field offset is not a multiple of byte, the produced -// location would not be accurate. Therefore give up. -if (fieldOffset % CGM.getContext().getCharWidth() != 0) - return nullptr; - + if (FD->isBitField()) { +const CGRecordLayout &RL = +CGM.getTypes().getCGRecordLayout(FD->getParent()); +const CGBitFieldInfo &Info = RL.getBitFieldInfo(FD); +// Use DW_OP_plus_uconst to adjust to the start of the bitfield +// storage. +if (!Info.StorageOffset.isZero()) { + Expr.push_back(llvm::dwarf::DW_OP_plus_uconst); + Expr.push_back(Info.StorageOffset.getQuantity()); +} +// Use LLVM_extract_bits to extract the appropriate bits from this +// bitfield. +Expr.push_back(Info.IsSigned + ? llvm::dwarf::DW_OP_LLVM_extract_bits_sext + : llvm::dwarf::
[clang] 2dc2290 - Revert new debug info format commits:
Author: Stephen Tozer Date: 2024-06-11T12:19:06+01:00 New Revision: 2dc2290860355dd2bac3b655eea895fe30fde257 URL: https://github.com/llvm/llvm-project/commit/2dc2290860355dd2bac3b655eea895fe30fde257 DIFF: https://github.com/llvm/llvm-project/commit/2dc2290860355dd2bac3b655eea895fe30fde257.diff LOG: Revert new debug info format commits: "[Flang] Update test to not check for tail calls on debug intrinsics" & "Reapply#3 "[RemoveDIs] Load into new debug info format by default in LLVM (#89799)" Recent updates to flang have added debug info generation via MLIR, a path which currently does not support debug records. The patch that enables debug records by default (and a small followup patch) are thus being reverted until the MLIR path has been fixed. This reverts commits: 21396be865b4640abf6afa0b05de6708a1a996e0 c5aeca732d1ff6769b0659efebd1cfb5f60487e4 Added: Modified: clang/test/CodeGen/instrument-objc-method.m flang/test/Transforms/debug-local-var-2.f90 llvm/docs/ReleaseNotes.rst llvm/include/llvm/AsmParser/LLParser.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/IR/BasicBlock.cpp llvm/lib/IR/DebugProgramInstruction.cpp llvm/lib/IR/Function.cpp llvm/lib/IR/Module.cpp llvm/tools/llvm-as/llvm-as.cpp llvm/tools/llvm-dis/llvm-dis.cpp llvm/tools/llvm-link/llvm-link.cpp llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp llvm/unittests/IR/BasicBlockDbgInfoTest.cpp llvm/unittests/IR/DebugInfoTest.cpp llvm/unittests/IR/IRBuilderTest.cpp llvm/unittests/IR/InstructionsTest.cpp llvm/unittests/IR/ValueTest.cpp llvm/unittests/Transforms/Utils/CloningTest.cpp llvm/unittests/Transforms/Utils/LocalTest.cpp Removed: diff --git a/clang/test/CodeGen/instrument-objc-method.m b/clang/test/CodeGen/instrument-objc-method.m index 2c9d1fc88554b..cfc0a0a98bec6 100644 --- a/clang/test/CodeGen/instrument-objc-method.m +++ b/clang/test/CodeGen/instrument-objc-method.m @@ -11,16 +11,16 @@ @implementation ObjCClass + (void)initialize { } -// BARE: @"\01+[ObjCClass load]"{{\(.*\)}} #1 +// PREINLINE: declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +// BARE: @"\01+[ObjCClass load]"{{\(.*\)}} #2 + (void)load __attribute__((no_instrument_function)) { } -// PREINLINE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #1 -// BARE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #1 +// PREINLINE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #2 +// BARE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #2 - (void)dealloc __attribute__((no_instrument_function)) { } -// PREINLINE: declare void @llvm.dbg.declare(metadata, metadata, metadata) #2 // PREINLINE: attributes #0 = { {{.*}}"instrument-function-entry"="__cyg_profile_func_enter" // PREINLINE-NOT: attributes #0 = { {{.*}}"instrument-function-entry"="__cyg_profile_func_enter_bare" // PREINLINE-NOT: attributes #2 = { {{.*}}"__cyg_profile_func_enter" diff --git a/flang/test/Transforms/debug-local-var-2.f90 b/flang/test/Transforms/debug-local-var-2.f90 index ee60a07cc4bee..0fe1b81c27e61 100644 --- a/flang/test/Transforms/debug-local-var-2.f90 +++ b/flang/test/Transforms/debug-local-var-2.f90 @@ -20,20 +20,20 @@ ! CHECK-LABEL: define {{.*}}i64 @_QFPfn1 ! CHECK-SAME: (ptr %[[ARG1:.*]], ptr %[[ARG2:.*]], ptr %[[ARG3:.*]]) -! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG1]], metadata ![[A1:.*]], metadata !DIExpression()) -! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG2]], metadata ![[B1:.*]], metadata !DIExpression()) -! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG3]], metadata ![[C1:.*]], metadata !DIExpression()) +! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[ARG1]], metadata ![[A1:.*]], metadata !DIExpression()) +! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[ARG2]], metadata ![[B1:.*]], metadata !DIExpression()) +! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[ARG3]], metadata ![[C1:.*]], metadata !DIExpression()) ! CHECK-DAG: %[[AL2:.*]] = alloca i64 -! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL2]], metadata ![[RES1:.*]], metadata !DIExpression()) +! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[AL2]], metadata ![[RES1:.*]], metadata !DIExpression()) ! CHECK-LABEL: } ! CHECK-LABEL: define {{.*}}i32 @_QFPfn2 ! CHECK-SAME: (ptr %[[FN2ARG1:.*]], ptr %[[FN2ARG2:.*]], ptr %[[FN2ARG3:.*]]) -! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG1]], metadata ![[A2:.*]], metadata !DIExpression()) -! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG2]], metadata ![[B2:.*]], metadata !DIExpression()) -! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG3]], metadata ![[C2:.*]], metadata !DIExpression()) +! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[FN2ARG1]], metadata ![[A2:.*]], metadata !DIExpression
[clang] [DebugInfo] Change handling of structured bindings of bitfields (PR #94632)
https://github.com/john-brawn-arm ready_for_review https://github.com/llvm/llvm-project/pull/94632 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [DebugInfo] Change handling of structured bindings of bitfields (PR #94632)
https://github.com/john-brawn-arm edited https://github.com/llvm/llvm-project/pull/94632 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [DebugInfo] Change handling of structured bindings of bitfields (PR #94632)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: John Brawn (john-brawn-arm) Changes Currently we use DW_OP_plus_uconst to handle the bitfield offset and handle the bitfield size by choosing a type size that matches, but this doesn't work if either offset or size aren't byte-aligned. Extracting the bits using DW_OP_LLVM_extract_bits means we can handle any kind of offset or size. TODO: test signed type, nonzero StorageOffset, oversized bitfield --- Patch is 25.57 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94632.diff 3 Files Affected: - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+25-43) - (modified) clang/lib/CodeGen/CGDebugInfo.h (-3) - (modified) clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp (+97-62) ``diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 11e2d549d8a45..20fd1b36ede27 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4874,40 +4874,6 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD, return D; } -llvm::DIType *CGDebugInfo::CreateBindingDeclType(const BindingDecl *BD) { - llvm::DIFile *Unit = getOrCreateFile(BD->getLocation()); - - // If the declaration is bound to a bitfield struct field, its type may have a - // size that is different from its deduced declaration type's. - if (const MemberExpr *ME = dyn_cast(BD->getBinding())) { -if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl())) { - if (FD->isBitField()) { -ASTContext &Context = CGM.getContext(); -const CGRecordLayout &RL = -CGM.getTypes().getCGRecordLayout(FD->getParent()); -const CGBitFieldInfo &Info = RL.getBitFieldInfo(FD); - -// Find an integer type with the same bitwidth as the bitfield size. If -// no suitable type is present in the target, give up on producing debug -// information as it would be wrong. It is certainly possible to produce -// correct debug info, but the logic isn't currently implemented. -uint64_t BitfieldSizeInBits = Info.Size; -QualType IntTy = -Context.getIntTypeForBitwidth(BitfieldSizeInBits, Info.IsSigned); -if (IntTy.isNull()) - return nullptr; -Qualifiers Quals = BD->getType().getQualifiers(); -QualType FinalTy = Context.getQualifiedType(IntTy, Quals); -llvm::DIType *Ty = getOrCreateType(FinalTy, Unit); -assert(Ty); -return Ty; - } -} - } - - return getOrCreateType(BD->getType(), Unit); -} - llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD, llvm::Value *Storage, std::optional ArgNo, @@ -4922,7 +4888,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD, if (isa(BD->getBinding())) return nullptr; - llvm::DIType *Ty = CreateBindingDeclType(BD); + llvm::DIFile *Unit = getOrCreateFile(BD->getLocation()); + llvm::DIType *Ty = getOrCreateType(BD->getType(), Unit); // If there is no debug info for this type then do not emit debug info // for this variable. @@ -4948,7 +4915,6 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD, unsigned Column = getColumnNumber(BD->getLocation()); StringRef Name = BD->getName(); auto *Scope = cast(LexicalBlockStack.back()); - llvm::DIFile *Unit = getOrCreateFile(BD->getLocation()); // Create the descriptor for the variable. llvm::DILocalVariable *D = DBuilder.createAutoVariable( Scope, Name, Unit, Line, Ty, CGM.getLangOpts().Optimize, @@ -4962,13 +4928,29 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD, const ASTRecordLayout &layout = CGM.getContext().getASTRecordLayout(parent); const uint64_t fieldOffset = layout.getFieldOffset(fieldIndex); - - if (fieldOffset != 0) { -// Currently if the field offset is not a multiple of byte, the produced -// location would not be accurate. Therefore give up. -if (fieldOffset % CGM.getContext().getCharWidth() != 0) - return nullptr; - + if (FD->isBitField()) { +const CGRecordLayout &RL = +CGM.getTypes().getCGRecordLayout(FD->getParent()); +const CGBitFieldInfo &Info = RL.getBitFieldInfo(FD); +// Use DW_OP_plus_uconst to adjust to the start of the bitfield +// storage. +if (!Info.StorageOffset.isZero()) { + Expr.push_back(llvm::dwarf::DW_OP_plus_uconst); + Expr.push_back(Info.StorageOffset.getQuantity()); +} +// Use LLVM_extract_bits to extract the appropriate bits from this +// bitfield. +Expr.push_back(Info.IsSigned + ? llvm::dwarf::DW_OP_LLVM_extract_bits_sext + : llvm::
[clang] [clang-tools-extra] [lld] [llvm] [FileCheck] forbid filecheck check prefix definitions to end with directive name (PR #92735)
https://github.com/klensy updated https://github.com/llvm/llvm-project/pull/92735 >From 21fc194add139509cf960f749166e8be423467d8 Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 15 May 2024 14:30:55 +0300 Subject: [PATCH 1/5] filecheck: forbid filecheck prefix definitions end with directive name --- llvm/lib/FileCheck/FileCheck.cpp | 18 ++ 1 file changed, 18 insertions(+) diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index 1719f8ef2b436..09446e506065f 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -2490,6 +2490,22 @@ static bool ValidatePrefixes(StringRef Kind, StringSet<> &UniquePrefixes, return true; } +static bool ValidateCheckPrefixesSuffix(StringRef Kind, +ArrayRef SuppliedPrefixes) { + static const char *Suffixes[] = {"-NEXT", "-SAME", "-EMPTY", "-NOT", + "-COUNT", "-DAG", "-LABEL"}; + for (StringRef Prefix : SuppliedPrefixes) { +for (StringRef Suffix : Suffixes) { + if (Prefix.ends_with(Suffix)) { +errs() << "error: supplied " << Kind << " prefix must not end with " + << "directive: '" << Suffix << "', prefix: '" << Prefix << "'\n"; +return false; + } +} + } + return true; +} + bool FileCheck::ValidateCheckPrefixes() { StringSet<> UniquePrefixes; // Add default prefixes to catch user-supplied duplicates of them below. @@ -2505,6 +2521,8 @@ bool FileCheck::ValidateCheckPrefixes() { // incorrectly indicate that they were supplied by the user. if (!ValidatePrefixes("check", UniquePrefixes, Req.CheckPrefixes)) return false; + if (!ValidateCheckPrefixesSuffix("check", Req.CheckPrefixes)) +return false; if (!ValidatePrefixes("comment", UniquePrefixes, Req.CommentPrefixes)) return false; return true; >From d29d6155ac17684277fa7d18f91f48e4a0477780 Mon Sep 17 00:00:00 2001 From: klensy Date: Sun, 19 May 2024 15:54:31 +0300 Subject: [PATCH 2/5] filecheck: fix self tests for "forbid check prefixes end with directive name" --- .../FileCheck/comment/bad-comment-prefix.txt | 10 +- llvm/test/FileCheck/numeric-expression.txt | 16 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/llvm/test/FileCheck/comment/bad-comment-prefix.txt b/llvm/test/FileCheck/comment/bad-comment-prefix.txt index 58a8873da3218..19be577618d00 100644 --- a/llvm/test/FileCheck/comment/bad-comment-prefix.txt +++ b/llvm/test/FileCheck/comment/bad-comment-prefix.txt @@ -3,17 +3,17 @@ # Check empty comment prefix. RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ RUN: -comment-prefixes= | \ -RUN: FileCheck -check-prefix=PREFIX-EMPTY %s +RUN: FileCheck -check-prefix=EMPTY-PREFIX %s RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ RUN: -comment-prefixes=,FOO | \ -RUN: FileCheck -check-prefix=PREFIX-EMPTY %s +RUN: FileCheck -check-prefix=EMPTY-PREFIX %s RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ RUN: -comment-prefixes=FOO, | \ -RUN: FileCheck -check-prefix=PREFIX-EMPTY %s +RUN: FileCheck -check-prefix=EMPTY-PREFIX %s RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ RUN: -comment-prefixes=FOO,,BAR | \ -RUN: FileCheck -check-prefix=PREFIX-EMPTY %s -PREFIX-EMPTY: error: supplied comment prefix must not be the empty string +RUN: FileCheck -check-prefix=EMPTY-PREFIX %s +EMPTY-PREFIX: error: supplied comment prefix must not be the empty string # Check invalid characters in comment prefix. RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ diff --git a/llvm/test/FileCheck/numeric-expression.txt b/llvm/test/FileCheck/numeric-expression.txt index 1430484d08ebc..f23628f5fbc9a 100644 --- a/llvm/test/FileCheck/numeric-expression.txt +++ b/llvm/test/FileCheck/numeric-expression.txt @@ -593,16 +593,16 @@ CALL-MISSING-ARGUMENT-MSG-NEXT: {{C}}ALL-MISSING-ARGUMENT-NEXT: {{\[\[#add\(NUMV CALL-MISSING-ARGUMENT-MSG-NEXT: {{^}} ^{{$}} RUN: %ProtectFileCheckOutput \ -RUN: not FileCheck -D#NUMVAR=10 --check-prefix CALL-WRONG-ARGUMENT-COUNT --input-file %s %s 2>&1 \ -RUN: | FileCheck --strict-whitespace --check-prefix CALL-WRONG-ARGUMENT-COUNT-MSG %s +RUN: not FileCheck -D#NUMVAR=10 --check-prefix CALL-WRONG-ARGUMENT-NUM --input-file %s %s 2>&1 \ +RUN: | FileCheck --strict-whitespace --check-prefix CALL-WRONG-ARGUMENT-NUM-MSG %s -CALL WRONG ARGUMENT COUNT +CALL WRONG ARGUMENT NUM 30 -CALL-WRONG-ARGUMENT-COUNT-LABEL: CALL WRONG ARGUMENT COUNT -CALL-WRONG-ARGUMENT-COUNT-NEXT: [[#add(NUMVAR)]] -CALL-WRONG-ARGUMENT-COUNT-MSG: numeric-expression.txt:[[#@LINE-1]]:36: error: function 'add' takes 2 argument
[clang] 424188a - [clang][Interp][test] Add test for void* diagnostics changes
Author: Timm Bäder Date: 2024-06-11T13:28:23+02:00 New Revision: 424188abe4956d51c852668d206dfc9919290fbf URL: https://github.com/llvm/llvm-project/commit/424188abe4956d51c852668d206dfc9919290fbf DIFF: https://github.com/llvm/llvm-project/commit/424188abe4956d51c852668d206dfc9919290fbf.diff LOG: [clang][Interp][test] Add test for void* diagnostics changes Added: clang/test/AST/Interp/cxx26.cpp Modified: clang/test/AST/Interp/cxx23.cpp Removed: diff --git a/clang/test/AST/Interp/cxx23.cpp b/clang/test/AST/Interp/cxx23.cpp index 1efd784abbbe8..d0991f3ffdff5 100644 --- a/clang/test/AST/Interp/cxx23.cpp +++ b/clang/test/AST/Interp/cxx23.cpp @@ -1,6 +1,6 @@ // UNSUPPORTED: target={{.*}}-zos{{.*}} -// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=ref20,all,all20 %s -// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=ref23,all %s +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=ref,ref20,all,all20 %s +// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=ref,ref23,all %s // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=expected20,all,all20 %s -fexperimental-new-constant-interpreter // RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=expected23,all %s -fexperimental-new-constant-interpreter @@ -200,3 +200,15 @@ namespace UndefinedThreeWay { static_assert(!(*test_a_threeway)(A(), A())); // all-error {{static assertion expression is not an integral constant expression}} \ // all-note {{undefined function 'operator<=>' cannot be used in a constant expression}} } + +/// FIXME: The new interpreter is missing the "initializer of q is not a constant expression" diagnostics.a +/// That's because the cast from void* to int* is considered fine, but diagnosed. So we don't consider +/// q to be uninitialized. +namespace VoidCast { + constexpr void* p = nullptr; + constexpr int* q = static_cast(p); // all-error {{must be initialized by a constant expression}} \ + // all-note {{cast from 'void *' is not allowed in a constant expression}} \ + // ref-note {{declared here}} + static_assert(q == nullptr); // ref-error {{not an integral constant expression}} \ + // ref-note {{initializer of 'q' is not a constant expression}} +} diff --git a/clang/test/AST/Interp/cxx26.cpp b/clang/test/AST/Interp/cxx26.cpp new file mode 100644 index 0..0b0e2b21e8201 --- /dev/null +++ b/clang/test/AST/Interp/cxx26.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -std=c++26 -fsyntax-only -fcxx-exceptions -verify=ref,both %s +// RUN: %clang_cc1 -std=c++26 -fsyntax-only -fcxx-exceptions -verify=expected,both %s -fexperimental-new-constant-interpreter + +// both-no-diagnostics + +namespace VoidCast { + constexpr void* p = nullptr; + constexpr int* q = static_cast(p); + static_assert(q == nullptr); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
linehill wrote: Could the single test with the PATH manipulation be moved to a separate test file which is disabled on Windows? That way we could keep running the other tests on Windows. https://github.com/llvm/llvm-project/pull/95096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Add option to select compiler-rt arch suffix (PR #89775)
pogo59 wrote: @MaskRay @tru How do we proceed with this? The current state is broken. https://github.com/llvm/llvm-project/pull/89775 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)
https://github.com/Andarwinux updated https://github.com/llvm/llvm-project/pull/94731 >From 8fba2123a1d545a573eb71d86de326655ae71d8a Mon Sep 17 00:00:00 2001 From: Andarwinux <144242044+andarwi...@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:07:40 + Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver fixes #91216 --- clang/include/clang/Driver/Options.td | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d44faa55c456f..1cce7a5146dd8 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">, Alias<_SLASH_winsdkdir>; def : Separate<["-"], "Xmicrosoft-windows-sdk-version">, Alias<_SLASH_winsdkversion>; +def : Separate<["-"], "Xmicrosoft-windows-sys-root">, +Alias<_SLASH_winsysroot>; // Ignored: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
mstorsjo wrote: > Could the single test with the PATH manipulation be moved to a separate test > file which is disabled on Windows? That way we could keep running the other > tests on Windows. That's certainly an option, too. https://github.com/llvm/llvm-project/pull/95096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fa9745e - [clang][Interp][NFC] Remove unneeded opcode initializers
Author: Timm Bäder Date: 2024-06-11T13:45:48+02:00 New Revision: fa9745e8d39498a7090b108dd2717ca0466189e3 URL: https://github.com/llvm/llvm-project/commit/fa9745e8d39498a7090b108dd2717ca0466189e3 DIFF: https://github.com/llvm/llvm-project/commit/fa9745e8d39498a7090b108dd2717ca0466189e3.diff LOG: [clang][Interp][NFC] Remove unneeded opcode initializers Added: Modified: clang/lib/AST/Interp/Opcodes.td Removed: diff --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td index 45fc11e564576..df362efd8b58b 100644 --- a/clang/lib/AST/Interp/Opcodes.td +++ b/clang/lib/AST/Interp/Opcodes.td @@ -139,7 +139,6 @@ class AluOpcode : Opcode { } class FloatOpcode : Opcode { - let Types = []; let Args = [ArgRoundingMode]; } @@ -195,17 +194,14 @@ def NoRet : Opcode {} def Call : Opcode { let Args = [ArgFunction, ArgUint32]; - let Types = []; } def CallVirt : Opcode { let Args = [ArgFunction, ArgUint32]; - let Types = []; } def CallBI : Opcode { let Args = [ArgFunction, ArgCallExpr]; - let Types = []; } def CallPtr : Opcode { @@ -214,7 +210,6 @@ def CallPtr : Opcode { def CallVar : Opcode { let Args = [ArgFunction, ArgUint32]; - let Types = []; } def OffsetOf : Opcode { @@ -399,8 +394,6 @@ def InitGlobalTemp : AccessOpcode { // [Pointer] -> [Pointer] def InitGlobalTempComp : Opcode { let Args = [ArgLETD]; - let Types = []; - let HasGroup = 0; } // [Value] -> [] def SetGlobal : AccessOpcode; @@ -505,13 +498,9 @@ def SubPtr : Opcode { } // [Pointer] -> [Pointer] -def IncPtr : Opcode { - let HasGroup = 0; -} +def IncPtr : Opcode; // [Pointer] -> [Pointer] -def DecPtr : Opcode { - let HasGroup = 0; -} +def DecPtr : Opcode; //===--===// // Function pointers. @@ -607,7 +596,6 @@ def Cast: Opcode { } def CastFP : Opcode { - let Types = []; let Args = [ArgFltSemantics, ArgRoundingMode]; } @@ -642,12 +630,10 @@ def CastFloatingIntegral : Opcode { } def CastFloatingIntegralAP : Opcode { - let Types = []; let Args = [ArgUint32]; } def CastFloatingIntegralAPS : Opcode { - let Types = []; let Args = [ArgUint32]; } @@ -656,13 +642,9 @@ def CastPointerIntegral : Opcode { let HasGroup = 1; } def CastPointerIntegralAP : Opcode { - let Types = []; - let HasGroup = 0; let Args = [ArgUint32]; } def CastPointerIntegralAPS : Opcode { - let Types = []; - let HasGroup = 0; let Args = [ArgUint32]; } def PtrPtrCast : Opcode { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Rearrange some Apple version testing (PR #94514)
https://github.com/pogo59 updated https://github.com/llvm/llvm-project/pull/94514 >From 19ddcbdf2eabb812b65bd194085777abc48eade4 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Wed, 5 Jun 2024 11:15:46 -0700 Subject: [PATCH 1/2] [Driver] Rearrange some Apple version testing There were four tests in Driver that actually tested bits of Driver and bits of CodeGen, and therefore had target restrictions. Rework those four tests into one Driver test (with no target restrictions) and two target-specific CodeGen tests. --- clang/test/Driver/apple-os-triples.c | 31 ++ clang/test/Driver/appletvos-version-min.c | 8 -- clang/test/Driver/driverkit-version-min.c | 5 clang/test/Driver/ios-version-min.c| 7 - clang/test/Driver/watchos-version-min.c| 7 - llvm/test/CodeGen/ARM/apple-version-min.ll | 9 +++ llvm/test/CodeGen/X86/apple-version-min.ll | 12 + 7 files changed, 52 insertions(+), 27 deletions(-) create mode 100644 clang/test/Driver/apple-os-triples.c delete mode 100644 clang/test/Driver/appletvos-version-min.c delete mode 100644 clang/test/Driver/driverkit-version-min.c delete mode 100644 clang/test/Driver/ios-version-min.c delete mode 100644 clang/test/Driver/watchos-version-min.c create mode 100644 llvm/test/CodeGen/ARM/apple-version-min.ll create mode 100644 llvm/test/CodeGen/X86/apple-version-min.ll diff --git a/clang/test/Driver/apple-os-triples.c b/clang/test/Driver/apple-os-triples.c new file mode 100644 index 0..49bee4a574197 --- /dev/null +++ b/clang/test/Driver/apple-os-triples.c @@ -0,0 +1,31 @@ +// Test triple manipulations. + +// RUN: %clang -### -c %s \ +// RUN: -target i386-apple-darwin10 -mappletvsimulator-version-min=9.0 -arch x86_64 2>&1 | \ +// RUN: FileCheck %s -DARCH=x86_64 -DOS=tvos9.0.0-simulator +// RUN: %clang -### -c %s \ +// RUN: -target armv7s-apple-darwin10 -mappletvos-version-min=9.0 -arch arm64 2>&1 | \ +// RUN: FileCheck %s -DARCH=arm64 -DOS=tvos9.0.0 +// RUN: env TVOS_DEPLOYMENT_TARGET=9.0 %clang -### -c %s \ +// RUN: -isysroot SDKs/MacOSX10.9.sdk -target i386-apple-darwin10 -arch x86_64 2>&1 | \ +// RUN: FileCheck %s -DARCH=x86_64 -DOS=tvos9.0.0 + +// RUN: %clang -### -c %s \ +// RUN: -target x86_64-apple-driverkit19.0 2>&1 | \ +// RUN: FileCheck %s -DARCH=x86_64 -DOS=driverkit19.0.0 + +// RUN: %clang -### -c %s \ +// RUN: -target i386-apple-darwin10 -miphonesimulator-version-min=7.0 -arch i386 2>&1 | \ +// RUN: FileCheck %s -DARCH=i386 -DOS=ios7.0.0-simulator +// RUN: %clang -### -c %s \ +// RUN: -target armv7s-apple-darwin10 -miphoneos-version-min=7.0 -arch armv7s 2>&1 | \ +// RUN: FileCheck %s -DARCH=thumbv7s -DOS=ios7.0.0 + +// RUN: %clang -### -c %s \ +// RUN: -target i386-apple-darwin10 -mwatchsimulator-version-min=2.0 -arch i386 2>&1 | \ +// RUN: FileCheck %s -DARCH=i386 -DOS=watchos2.0.0-simulator +// RUN: %clang -### -c %s \ +// RUN: -target armv7s-apple-darwin10 -mwatchos-version-min=2.0 -arch armv7k 2>&1 | \ +// RUN: FileCheck %s -DARCH=thumbv7k -DOS=watchos2.0.0 + +// CHECK: "-cc1" "-triple" "[[ARCH]]-apple-[[OS]]" diff --git a/clang/test/Driver/appletvos-version-min.c b/clang/test/Driver/appletvos-version-min.c deleted file mode 100644 index 7cbb2001a3ec2..0 --- a/clang/test/Driver/appletvos-version-min.c +++ /dev/null @@ -1,8 +0,0 @@ -// REQUIRES: x86-registered-target -// REQUIRES: aarch64-registered-target -// RUN: %clang -target i386-apple-darwin10 -mappletvsimulator-version-min=9.0 -arch x86_64 -S -o - %s | FileCheck %s -// RUN: %clang -target armv7s-apple-darwin10 -mappletvos-version-min=9.0 -arch arm64 -S -o - %s | FileCheck %s -// RUN: env TVOS_DEPLOYMENT_TARGET=9.0 %clang -isysroot SDKs/MacOSX10.9.sdk -target i386-apple-darwin10 -arch x86_64 -S -o - %s | FileCheck %s - -int main() { return 0; } -// CHECK: .tvos_version_min 9, 0 diff --git a/clang/test/Driver/driverkit-version-min.c b/clang/test/Driver/driverkit-version-min.c deleted file mode 100644 index 9966152f11ce8..0 --- a/clang/test/Driver/driverkit-version-min.c +++ /dev/null @@ -1,5 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: %clang -target x86_64-apple-driverkit19.0 -S -o - %s | FileCheck %s - -int main() { return 0; } -// CHECK: .build_version driverkit, 19, 0 diff --git a/clang/test/Driver/ios-version-min.c b/clang/test/Driver/ios-version-min.c deleted file mode 100644 index aa536cf7827b3..0 --- a/clang/test/Driver/ios-version-min.c +++ /dev/null @@ -1,7 +0,0 @@ -// REQUIRES: x86-registered-target -// REQUIRES: arm-registered-target -// RUN: %clang -target i386-apple-darwin10 -miphonesimulator-version-min=7.0 -arch i386 -S -o - %s | FileCheck %s -// RUN: %clang -target armv7s-apple-darwin10 -miphoneos-version-min=7.0 -arch armv7s -S -o - %s | FileCheck %s - -int main() { return 0; } -// CHECK: .ios_version_min 7, 0 diff --git a/clang/test/Driver/watchos-version-min.c
[clang] 3f88311 - [Driver] Rearrange some Apple version testing (#94514)
Author: Paul T Robinson Date: 2024-06-11T07:51:21-04:00 New Revision: 3f883111243c4abfc06670190771b9cafc092bd8 URL: https://github.com/llvm/llvm-project/commit/3f883111243c4abfc06670190771b9cafc092bd8 DIFF: https://github.com/llvm/llvm-project/commit/3f883111243c4abfc06670190771b9cafc092bd8.diff LOG: [Driver] Rearrange some Apple version testing (#94514) There were four tests in Driver that actually tested bits of Driver and bits of CodeGen, and therefore had target restrictions. Rework those four tests into one Driver test (with no target restrictions) and two target-specific CodeGen tests. Added: clang/test/Driver/apple-os-triples.c llvm/test/CodeGen/ARM/apple-version-min.ll llvm/test/CodeGen/X86/apple-version-min.ll Modified: Removed: clang/test/Driver/appletvos-version-min.c clang/test/Driver/driverkit-version-min.c clang/test/Driver/ios-version-min.c clang/test/Driver/watchos-version-min.c diff --git a/clang/test/Driver/apple-os-triples.c b/clang/test/Driver/apple-os-triples.c new file mode 100644 index 0..7664d3bc19fca --- /dev/null +++ b/clang/test/Driver/apple-os-triples.c @@ -0,0 +1,31 @@ +// Test triple manipulations. + +// RUN: %clang -### -c %s \ +// RUN: --target=i386-apple-darwin10 -mappletvsimulator-version-min=9.0 -arch x86_64 2>&1 | \ +// RUN: FileCheck %s -DARCH=x86_64 -DOS=tvos9.0.0-simulator +// RUN: %clang -### -c %s \ +// RUN: --target=armv7s-apple-darwin10 -mappletvos-version-min=9.0 -arch arm64 2>&1 | \ +// RUN: FileCheck %s -DARCH=arm64 -DOS=tvos9.0.0 +// RUN: env TVOS_DEPLOYMENT_TARGET=9.0 %clang -### -c %s \ +// RUN: -isysroot SDKs/MacOSX10.9.sdk -target i386-apple-darwin10 -arch x86_64 2>&1 | \ +// RUN: FileCheck %s -DARCH=x86_64 -DOS=tvos9.0.0 + +// RUN: %clang -### -c %s \ +// RUN: --target=x86_64-apple-driverkit19.0 2>&1 | \ +// RUN: FileCheck %s -DARCH=x86_64 -DOS=driverkit19.0.0 + +// RUN: %clang -### -c %s \ +// RUN: --target=i386-apple-darwin10 -miphonesimulator-version-min=7.0 -arch i386 2>&1 | \ +// RUN: FileCheck %s -DARCH=i386 -DOS=ios7.0.0-simulator +// RUN: %clang -### -c %s \ +// RUN: --target=armv7s-apple-darwin10 -miphoneos-version-min=7.0 -arch armv7s 2>&1 | \ +// RUN: FileCheck %s -DARCH=thumbv7s -DOS=ios7.0.0 + +// RUN: %clang -### -c %s \ +// RUN: --target=i386-apple-darwin10 -mwatchsimulator-version-min=2.0 -arch i386 2>&1 | \ +// RUN: FileCheck %s -DARCH=i386 -DOS=watchos2.0.0-simulator +// RUN: %clang -### -c %s \ +// RUN: --target=armv7s-apple-darwin10 -mwatchos-version-min=2.0 -arch armv7k 2>&1 | \ +// RUN: FileCheck %s -DARCH=thumbv7k -DOS=watchos2.0.0 + +// CHECK: "-cc1" "-triple" "[[ARCH]]-apple-[[OS]]" diff --git a/clang/test/Driver/appletvos-version-min.c b/clang/test/Driver/appletvos-version-min.c deleted file mode 100644 index 7cbb2001a3ec2..0 --- a/clang/test/Driver/appletvos-version-min.c +++ /dev/null @@ -1,8 +0,0 @@ -// REQUIRES: x86-registered-target -// REQUIRES: aarch64-registered-target -// RUN: %clang -target i386-apple-darwin10 -mappletvsimulator-version-min=9.0 -arch x86_64 -S -o - %s | FileCheck %s -// RUN: %clang -target armv7s-apple-darwin10 -mappletvos-version-min=9.0 -arch arm64 -S -o - %s | FileCheck %s -// RUN: env TVOS_DEPLOYMENT_TARGET=9.0 %clang -isysroot SDKs/MacOSX10.9.sdk -target i386-apple-darwin10 -arch x86_64 -S -o - %s | FileCheck %s - -int main() { return 0; } -// CHECK: .tvos_version_min 9, 0 diff --git a/clang/test/Driver/driverkit-version-min.c b/clang/test/Driver/driverkit-version-min.c deleted file mode 100644 index 9966152f11ce8..0 --- a/clang/test/Driver/driverkit-version-min.c +++ /dev/null @@ -1,5 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: %clang -target x86_64-apple-driverkit19.0 -S -o - %s | FileCheck %s - -int main() { return 0; } -// CHECK: .build_version driverkit, 19, 0 diff --git a/clang/test/Driver/ios-version-min.c b/clang/test/Driver/ios-version-min.c deleted file mode 100644 index aa536cf7827b3..0 --- a/clang/test/Driver/ios-version-min.c +++ /dev/null @@ -1,7 +0,0 @@ -// REQUIRES: x86-registered-target -// REQUIRES: arm-registered-target -// RUN: %clang -target i386-apple-darwin10 -miphonesimulator-version-min=7.0 -arch i386 -S -o - %s | FileCheck %s -// RUN: %clang -target armv7s-apple-darwin10 -miphoneos-version-min=7.0 -arch armv7s -S -o - %s | FileCheck %s - -int main() { return 0; } -// CHECK: .ios_version_min 7, 0 diff --git a/clang/test/Driver/watchos-version-min.c b/clang/test/Driver/watchos-version-min.c deleted file mode 100644 index 8f12285d4e473..0 --- a/clang/test/Driver/watchos-version-min.c +++ /dev/null @@ -1,7 +0,0 @@ -// REQUIRES: x86-registered-target -// REQUIRES: arm-registered-target -// RUN: %clang -target i386-apple-darwin10 -mwatchsimulator-version-min=2.0 -arch i386 -S -o - %s | FileCheck %s -// RUN: %clang -target arm
[clang] [llvm] [Driver] Rearrange some Apple version testing (PR #94514)
https://github.com/pogo59 closed https://github.com/llvm/llvm-project/pull/94514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
https://github.com/mstorsjo updated https://github.com/llvm/llvm-project/pull/95096 From 8e5e09f12124a361c06d833a9ade75bbb338be4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 11 Jun 2024 13:14:47 +0300 Subject: [PATCH] [clang] [test] Skip a test that sets PATH= on Windows The same has been done in a couple other existing tests, that also are skipped on Windows (e.g. ld-path.c). Some tests that really do want to test setting the path on Windows does it differently, see e.g. ps4-ps5-linker-win.c. Since a65771fce4a2f25f16d4b3918ad6a11370637f7b, the spirv-toolchain.cl test does one test where PATH is set. Setting PATH does work in some build configurations - however, if built with e.g. llvm-mingw, the built Clang executable depends on libc++.dll (and libunwind.dll) which are found in PATH. If the PATH is overridden, the newly built Clang executable no longer can run. Split the test that requires setting PATH to a separate file, and mark it as unsupported on Windows. --- clang/test/Driver/spirv-toolchain-version.cl | 14 ++ clang/test/Driver/spirv-toolchain.cl | 10 -- 2 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 clang/test/Driver/spirv-toolchain-version.cl diff --git a/clang/test/Driver/spirv-toolchain-version.cl b/clang/test/Driver/spirv-toolchain-version.cl new file mode 100644 index 0..b23c2b9ef5558 --- /dev/null +++ b/clang/test/Driver/spirv-toolchain-version.cl @@ -0,0 +1,14 @@ +/// This test uses the PATH environment variable; on Windows, we may need to retain +/// the original path for the built Clang binary to be able to execute (as it is +/// used for locating dependent DLLs). +// UNSUPPORTED: system-windows + +//- +// Check llvm-spirv- is used if it is found in PATH. +// RUN: mkdir -p %t/versioned +// RUN: touch %t/versioned/llvm-spirv-%llvm-version-major \ +// RUN: && chmod +x %t/versioned/llvm-spirv-%llvm-version-major +// RUN: env "PATH=%t/versioned" %clang -### --target=spirv64 -x cl -c %s 2>&1 \ +// RUN: | FileCheck -DVERSION=%llvm-version-major --check-prefix=VERSIONED %s + +// VERSIONED: {{.*}}llvm-spirv-[[VERSION]] diff --git a/clang/test/Driver/spirv-toolchain.cl b/clang/test/Driver/spirv-toolchain.cl index de818177cb19f..db3ee4d3fe02f 100644 --- a/clang/test/Driver/spirv-toolchain.cl +++ b/clang/test/Driver/spirv-toolchain.cl @@ -77,13 +77,3 @@ // XTOR: {{llvm-spirv.*"}} // BACKEND-NOT: {{llvm-spirv.*"}} - -//- -// Check llvm-spirv- is used if it is found in PATH. -// RUN: mkdir -p %t/versioned -// RUN: touch %t/versioned/llvm-spirv-%llvm-version-major \ -// RUN: && chmod +x %t/versioned/llvm-spirv-%llvm-version-major -// RUN: env "PATH=%t/versioned" %clang -### --target=spirv64 -x cl -c %s 2>&1 \ -// RUN: | FileCheck -DVERSION=%llvm-version-major --check-prefix=VERSIONED %s - -// VERSIONED: {{.*}}llvm-spirv-[[VERSION]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Offload][CUDA] Allow CUDA kernels to use LLVM/Offload (PR #94549)
https://github.com/jdoerfert updated https://github.com/llvm/llvm-project/pull/94549 >From 36618e65d94ffa3e83464b7d19ff6cd7d5855abf Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 5 Jun 2024 16:51:51 -0700 Subject: [PATCH 1/3] [Offload][NFCI] Initialize the KernelArgsTy to default values --- offload/include/Shared/APITypes.h | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/offload/include/Shared/APITypes.h b/offload/include/Shared/APITypes.h index e8fc27785b6c2..fd315c6b992b9 100644 --- a/offload/include/Shared/APITypes.h +++ b/offload/include/Shared/APITypes.h @@ -89,22 +89,26 @@ struct __tgt_async_info { /// This struct contains all of the arguments to a target kernel region launch. struct KernelArgsTy { - uint32_t Version; // Version of this struct for ABI compatibility. - uint32_t NumArgs; // Number of arguments in each input pointer. - void **ArgBasePtrs; // Base pointer of each argument (e.g. a struct). - void **ArgPtrs; // Pointer to the argument data. - int64_t *ArgSizes; // Size of the argument data in bytes. - int64_t *ArgTypes; // Type of the data (e.g. to / from). - void **ArgNames;// Name of the data for debugging, possibly null. - void **ArgMappers; // User-defined mappers, possibly null. - uint64_t Tripcount; // Tripcount for the teams / distribute loop, 0 otherwise. + uint32_t Version = 0; // Version of this struct for ABI compatibility. + uint32_t NumArgs = 0; // Number of arguments in each input pointer. + void **ArgBasePtrs = + nullptr; // Base pointer of each argument (e.g. a struct). + void **ArgPtrs = nullptr;// Pointer to the argument data. + int64_t *ArgSizes = nullptr; // Size of the argument data in bytes. + int64_t *ArgTypes = nullptr; // Type of the data (e.g. to / from). + void **ArgNames = nullptr; // Name of the data for debugging, possibly null. + void **ArgMappers = nullptr; // User-defined mappers, possibly null. + uint64_t Tripcount = + 0; // Tripcount for the teams / distribute loop, 0 otherwise. struct { uint64_t NoWait : 1; // Was this kernel spawned with a `nowait` clause. uint64_t Unused : 63; - } Flags; - uint32_t NumTeams[3];// The number of teams (for x,y,z dimension). - uint32_t ThreadLimit[3]; // The number of threads (for x,y,z dimension). - uint32_t DynCGroupMem; // Amount of dynamic cgroup memory requested. + } Flags = {0, 0}; + uint32_t NumTeams[3] = {0, 0, + 0}; // The number of teams (for x,y,z dimension). + uint32_t ThreadLimit[3] = {0, 0, + 0}; // The number of threads (for x,y,z dimension). + uint32_t DynCGroupMem = 0; // Amount of dynamic cgroup memory requested. }; static_assert(sizeof(KernelArgsTy().Flags) == sizeof(uint64_t), "Invalid struct size"); >From e593d163cd3a78bd1e64b1dc276ebc7e8baaeb0b Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Tue, 11 Jun 2024 01:49:34 -0700 Subject: [PATCH 2/3] [Offload] Use flat array for cuLaunchKernel We already used a flat array of kernel launch parameters for the AMD GPU launch but now we also use this scheme for the NVIDIA GPU launch. The only remaining/required use of the indirection is the host plugin (due ot ffi). This allows to us simplify the use for non-OpenMP kernel launch. --- offload/include/Shared/APITypes.h | 10 +++ offload/plugins-nextgen/amdgpu/src/rtl.cpp| 26 + .../common/include/PluginInterface.h | 14 + .../common/src/PluginInterface.cpp| 28 +- offload/plugins-nextgen/cuda/src/rtl.cpp | 29 --- offload/plugins-nextgen/host/src/rtl.cpp | 5 ++-- 6 files changed, 68 insertions(+), 44 deletions(-) diff --git a/offload/include/Shared/APITypes.h b/offload/include/Shared/APITypes.h index fd315c6b992b9..1dd69baa7b578 100644 --- a/offload/include/Shared/APITypes.h +++ b/offload/include/Shared/APITypes.h @@ -116,6 +116,16 @@ static_assert(sizeof(KernelArgsTy) == (8 * sizeof(int32_t) + 3 * sizeof(int64_t) + 4 * sizeof(void **) + 2 * sizeof(int64_t *)), "Invalid struct size"); + +/// Flat array of kernel launch parameters and their total size. +struct KernelLaunchParamsTy { + /// Size of the Data array. + size_t Size = 0; + /// Flat array of kernel parameters. + void *Data = nullptr; + /// Ptrs to the Data entries. Only strictly required for the host plugin. + void **Ptrs = nullptr; +}; } #endif // OMPTARGET_SHARED_API_TYPES_H diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp index c6dd954746e4a..43e0bbd85a9d3 100644 --- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp +++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp @@ -20,6 +20,7 @@ #include #include +#include "Shared/APITypes.h" #include "Shared/Debug.h" #include "Shared
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
https://github.com/mstorsjo edited https://github.com/llvm/llvm-project/pull/95096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)
@@ -2220,23 +2220,103 @@ namespace { class ExtractTypeForDeductionGuide : public TreeTransform { llvm::SmallVectorImpl &MaterializedTypedefs; + ClassTemplateDecl *NestedPattern; + const MultiLevelTemplateArgumentList *OuterInstantiationArgs; public: typedef TreeTransform Base; ExtractTypeForDeductionGuide( Sema &SemaRef, - llvm::SmallVectorImpl &MaterializedTypedefs) - : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs) {} + llvm::SmallVectorImpl &MaterializedTypedefs, + ClassTemplateDecl *NestedPattern, + const MultiLevelTemplateArgumentList *OuterInstantiationArgs) + : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs), +NestedPattern(NestedPattern), +OuterInstantiationArgs(OuterInstantiationArgs) {} TypeSourceInfo *transform(TypeSourceInfo *TSI) { return TransformType(TSI); } + /// Returns true if it's safe to substitute \p Typedef with + /// \p OuterInstantiationArgs. + bool mightReferToOuterTemplateParameters(TypedefNameDecl *Typedef) { +if (!NestedPattern) + return false; + +static auto WalkUp = [](DeclContext *DC, DeclContext *TargetDC) { + if (DC->Equals(TargetDC)) +return true; + while (DC->isRecord()) { +if (DC->Equals(TargetDC)) + return true; +DC = DC->getParent(); + } + return false; +}; + +if (WalkUp(Typedef->getDeclContext(), NestedPattern->getTemplatedDecl())) + return true; +if (WalkUp(NestedPattern->getTemplatedDecl(), Typedef->getDeclContext())) + return true; +return false; + } + + QualType + RebuildTemplateSpecializationType(TemplateName Template, +SourceLocation TemplateNameLoc, +TemplateArgumentListInfo &TemplateArgs) { +if (!OuterInstantiationArgs || +!isa_and_present(Template.getAsTemplateDecl())) + return Base::RebuildTemplateSpecializationType(Template, TemplateNameLoc, + TemplateArgs); + +auto *TATD = cast(Template.getAsTemplateDecl()); +auto *Pattern = TATD; +while (Pattern->getInstantiatedFromMemberTemplate()) + Pattern = Pattern->getInstantiatedFromMemberTemplate(); +if (!mightReferToOuterTemplateParameters(Pattern->getTemplatedDecl())) + return Base::RebuildTemplateSpecializationType(Template, TemplateNameLoc, + TemplateArgs); + +Decl *NewD = SemaRef.SubstDecl( +TATD, SemaRef.getASTContext().getTranslationUnitDecl(), zyn0217 wrote: This is what we've done since D80743, when @zygoloid [suggested](https://reviews.llvm.org/D80743?id=266940#inline-745424) that we delay setting the `DeclContext`s until the `CXXDeductionGuideDecl` is formed. This way, I *guess* (I didn't dig into the details) we could have template parameters attach to the right depths (e.g. presumably 1) rather than the depth relative to the outer class templates (`DC`). https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/94356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (PR #94356)
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/94356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Offload][CUDA] Allow CUDA kernels to use LLVM/Offload (PR #94549)
https://github.com/jdoerfert updated https://github.com/llvm/llvm-project/pull/94549 >From 36618e65d94ffa3e83464b7d19ff6cd7d5855abf Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 5 Jun 2024 16:51:51 -0700 Subject: [PATCH 1/3] [Offload][NFCI] Initialize the KernelArgsTy to default values --- offload/include/Shared/APITypes.h | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/offload/include/Shared/APITypes.h b/offload/include/Shared/APITypes.h index e8fc27785b6c2..fd315c6b992b9 100644 --- a/offload/include/Shared/APITypes.h +++ b/offload/include/Shared/APITypes.h @@ -89,22 +89,26 @@ struct __tgt_async_info { /// This struct contains all of the arguments to a target kernel region launch. struct KernelArgsTy { - uint32_t Version; // Version of this struct for ABI compatibility. - uint32_t NumArgs; // Number of arguments in each input pointer. - void **ArgBasePtrs; // Base pointer of each argument (e.g. a struct). - void **ArgPtrs; // Pointer to the argument data. - int64_t *ArgSizes; // Size of the argument data in bytes. - int64_t *ArgTypes; // Type of the data (e.g. to / from). - void **ArgNames;// Name of the data for debugging, possibly null. - void **ArgMappers; // User-defined mappers, possibly null. - uint64_t Tripcount; // Tripcount for the teams / distribute loop, 0 otherwise. + uint32_t Version = 0; // Version of this struct for ABI compatibility. + uint32_t NumArgs = 0; // Number of arguments in each input pointer. + void **ArgBasePtrs = + nullptr; // Base pointer of each argument (e.g. a struct). + void **ArgPtrs = nullptr;// Pointer to the argument data. + int64_t *ArgSizes = nullptr; // Size of the argument data in bytes. + int64_t *ArgTypes = nullptr; // Type of the data (e.g. to / from). + void **ArgNames = nullptr; // Name of the data for debugging, possibly null. + void **ArgMappers = nullptr; // User-defined mappers, possibly null. + uint64_t Tripcount = + 0; // Tripcount for the teams / distribute loop, 0 otherwise. struct { uint64_t NoWait : 1; // Was this kernel spawned with a `nowait` clause. uint64_t Unused : 63; - } Flags; - uint32_t NumTeams[3];// The number of teams (for x,y,z dimension). - uint32_t ThreadLimit[3]; // The number of threads (for x,y,z dimension). - uint32_t DynCGroupMem; // Amount of dynamic cgroup memory requested. + } Flags = {0, 0}; + uint32_t NumTeams[3] = {0, 0, + 0}; // The number of teams (for x,y,z dimension). + uint32_t ThreadLimit[3] = {0, 0, + 0}; // The number of threads (for x,y,z dimension). + uint32_t DynCGroupMem = 0; // Amount of dynamic cgroup memory requested. }; static_assert(sizeof(KernelArgsTy().Flags) == sizeof(uint64_t), "Invalid struct size"); >From e593d163cd3a78bd1e64b1dc276ebc7e8baaeb0b Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Tue, 11 Jun 2024 01:49:34 -0700 Subject: [PATCH 2/3] [Offload] Use flat array for cuLaunchKernel We already used a flat array of kernel launch parameters for the AMD GPU launch but now we also use this scheme for the NVIDIA GPU launch. The only remaining/required use of the indirection is the host plugin (due ot ffi). This allows to us simplify the use for non-OpenMP kernel launch. --- offload/include/Shared/APITypes.h | 10 +++ offload/plugins-nextgen/amdgpu/src/rtl.cpp| 26 + .../common/include/PluginInterface.h | 14 + .../common/src/PluginInterface.cpp| 28 +- offload/plugins-nextgen/cuda/src/rtl.cpp | 29 --- offload/plugins-nextgen/host/src/rtl.cpp | 5 ++-- 6 files changed, 68 insertions(+), 44 deletions(-) diff --git a/offload/include/Shared/APITypes.h b/offload/include/Shared/APITypes.h index fd315c6b992b9..1dd69baa7b578 100644 --- a/offload/include/Shared/APITypes.h +++ b/offload/include/Shared/APITypes.h @@ -116,6 +116,16 @@ static_assert(sizeof(KernelArgsTy) == (8 * sizeof(int32_t) + 3 * sizeof(int64_t) + 4 * sizeof(void **) + 2 * sizeof(int64_t *)), "Invalid struct size"); + +/// Flat array of kernel launch parameters and their total size. +struct KernelLaunchParamsTy { + /// Size of the Data array. + size_t Size = 0; + /// Flat array of kernel parameters. + void *Data = nullptr; + /// Ptrs to the Data entries. Only strictly required for the host plugin. + void **Ptrs = nullptr; +}; } #endif // OMPTARGET_SHARED_API_TYPES_H diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp index c6dd954746e4a..43e0bbd85a9d3 100644 --- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp +++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp @@ -20,6 +20,7 @@ #include #include +#include "Shared/APITypes.h" #include "Shared/Debug.h" #include "Shared
[clang] [clang][dataflow] Fix handling of cyclical data structures in HTMLLogger. (PR #66887)
@@ -88,10 +88,12 @@ class ModelDumper { void dump(Value &V) { JOS.attribute("value_id", llvm::to_string(&V)); -if (!Visited.insert(&V).second) - return; - JOS.attribute("kind", debugString(V.getKind())); +if (!Visited.insert(&V).second) { + JOS.attribute("[in_cycle]", " "); + return; +} +auto EraseVisited = llvm::make_scope_exit([&] { Visited.erase(&V); }); sam-mccall wrote: (Less invasive ideas that might be useful either way: "undefined" is a bug which can be fixed. Duplicate nodes could/should also be made a different color) I think showing a subtree twice is a pretty serious misrepresentation of the data, probably more so than pruning children from a duplicated node. There's no easy + perfect way to show a DAG in a tree-browser. It'd be possible to make this more explicit (e.g. have a "duplicate node" box contain a link to an anchor on the original node). But it's complexity, and if you *don't* care about the DAG structure then it's still not ideal. > I assume your concern is that we could have data structures with lots and > lots of repeated values, and this would bloat the JSON? Do we actually know > that this is a problem though? Yes, I believe I saw this. I don't remember the details though, and it might have involved the old BoolValue subclasses that bloated the tree. https://github.com/llvm/llvm-project/pull/66887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95102)
https://github.com/Lukacma created https://github.com/llvm/llvm-project/pull/95102 To enable function multi-versioning (FMV), current checks which rely on cmd line options or global macros to see if target feature is present need to be removed. This patch removes those for NEON and also implements changes to NEON header file as proposed in [ACLE](https://github.com/ARM-software/acle/pull/321). >From cdffede6773ae1bdbe759d636f582a9218522c32 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Tue, 11 Jun 2024 11:00:42 + Subject: [PATCH] [Clang] Remove preprocessor guards and global feature checks for NEON --- clang/lib/Sema/SemaType.cpp| 23 -- clang/test/Sema/arm-vector-types-support.c | 2 -- clang/test/SemaCUDA/neon-attrs.cu | 22 - clang/utils/TableGen/NeonEmitter.cpp | 5 - 4 files changed, 52 deletions(-) delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..65b87f62e294f 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8084,29 +8084,6 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM()); } - // Target must have NEON (or MVE, whose vectors are similar enough - // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; -Attr.setInvalid(); -return; - } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; -Attr.setInvalid(); -return; - } - // Check the attribute arguments. if (Attr.getNumArgs() != 1) { S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..1d2e1c9336fc6 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -2,6 +2,4 @@ // RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify // RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -x c++ -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -x c++ -fsyntax-only -verify %s - -// quiet-no-diagnostics -typedef __attribute__((neon_vector_type(4))) float float32x4_t; -// expected-error@-1 {{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'}} -// expect -typedef unsigned char poly8_t; -typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t; -// expected-error@-1 {{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'}}
[clang-tools-extra] [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (PR #94356)
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/94356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95102)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (Lukacma) Changes To enable function multi-versioning (FMV), current checks which rely on cmd line options or global macros to see if target feature is present need to be removed. This patch removes those for NEON and also implements changes to NEON header file as proposed in [ACLE](https://github.com/ARM-software/acle/pull/321). --- Full diff: https://github.com/llvm/llvm-project/pull/95102.diff 4 Files Affected: - (modified) clang/lib/Sema/SemaType.cpp (-23) - (modified) clang/test/Sema/arm-vector-types-support.c (-2) - (removed) clang/test/SemaCUDA/neon-attrs.cu (-22) - (modified) clang/utils/TableGen/NeonEmitter.cpp (-5) ``diff diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..65b87f62e294f 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8084,29 +8084,6 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM()); } - // Target must have NEON (or MVE, whose vectors are similar enough - // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; -Attr.setInvalid(); -return; - } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; -Attr.setInvalid(); -return; - } - // Check the attribute arguments. if (Attr.getNumArgs() != 1) { S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..1d2e1c9336fc6 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -2,6 +2,4 @@ // RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify // RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -x c++ -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -x c++ -fsyntax-only -verify %s - -// quiet-no-diagnostics -typedef __attribute__((neon_vector_type(4))) float float32x4_t; -// expected-error@-1 {{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'}} -// expect -typedef unsigned char poly8_t; -typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t; -// expected-error@-1 {{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'}} diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 56f1fdf9ef574..626031d38cf00 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -2370,10 +2370,6 @@
[clang-tools-extra] 546c816 - [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (#94356)
Author: Donát Nagy Date: 2024-06-11T14:16:42+02:00 New Revision: 546c816a529835a4cf89deecff957ea336a94fa2 URL: https://github.com/llvm/llvm-project/commit/546c816a529835a4cf89deecff957ea336a94fa2 DIFF: https://github.com/llvm/llvm-project/commit/546c816a529835a4cf89deecff957ea336a94fa2.diff LOG: [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (#94356) This commit reimplements the functionality of the Clang Static Analyzer checker `alpha.core.SizeofPointer` within clang-tidy by adding a new (off-by-default) option to bugprone-sizeof-expression which activates reporting all the `sizeof(ptr)` expressions (where ptr is an expression that produces a pointer). The main motivation for this change is that `alpha.core.SizeofPointer` was an AST-based checker, which did not rely on the path sensitive capabilities of the Static Analyzer, so there was no reason to keep it in the Static Analyzer instead of the more lightweight clang-tidy. After this commit I'm planning to create a separate commit that deletes `alpha.core.SizeofPointer` from Clang Static Analyzer. It was natural to place this moved logic in bugprone-sizeof-expression, because that check already provided several heuristics that reported various especially suspicious classes of `sizeof(ptr)` expressions. The new mode `WarnOnSizeOfPointer` is off-by-default, so it won't surprise the existing users; but it can provide a more through coverage for the vulnerability CWE-467 ("Use of sizeof() on a Pointer Type") than the existing partial heuristics. Previously this checker had an exception that the RHS of a `sizeof(array) / sizeof(array[0])` expression is not reported; I generalized this to an exception that the check doesn't report `sizeof(expr[0])` and `sizeof(*expr)`. This idea is taken from the Static Analyzer checker `alpha.core.SizeofPointer` (which had an exception for `*expr`), but analysis of open source projects confirmed that this indeed eliminates lots of unwanted results. Note that the suppression of `sizeof(expr[0])` and `sizeof(*expr)` reports also affects the "old" mode `WarnOnSizeOfPointerToAggregate` which is enabled by default. This commit also replaces the old message "suspicious usage of 'sizeof(A*)'; pointer to aggregate" with two more concrete messages; but I feel that this tidy check would deserve a through cleanup of all the diagnostic messages that it can produce. (I added a FIXME to mark one outright misleading message.) Added: clang-tools-extra/test/clang-tidy/checkers/bugprone/sizeof-expression-any-pointer.cpp Modified: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.h clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/bugprone/sizeof-expression.rst clang-tools-extra/test/clang-tidy/checkers/bugprone/sizeof-expression-2.c clang-tools-extra/test/clang-tidy/checkers/bugprone/sizeof-expression.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp index 5e64d23874ec1..c25ee42d0899a 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp @@ -67,7 +67,8 @@ SizeofExpressionCheck::SizeofExpressionCheck(StringRef Name, WarnOnSizeOfCompareToConstant( Options.get("WarnOnSizeOfCompareToConstant", true)), WarnOnSizeOfPointerToAggregate( - Options.get("WarnOnSizeOfPointerToAggregate", true)) {} + Options.get("WarnOnSizeOfPointerToAggregate", true)), + WarnOnSizeOfPointer(Options.get("WarnOnSizeOfPointer", false)) {} void SizeofExpressionCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "WarnOnSizeOfConstant", WarnOnSizeOfConstant); @@ -78,6 +79,7 @@ void SizeofExpressionCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { WarnOnSizeOfCompareToConstant); Options.store(Opts, "WarnOnSizeOfPointerToAggregate", WarnOnSizeOfPointerToAggregate); + Options.store(Opts, "WarnOnSizeOfPointer", WarnOnSizeOfPointer); } void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { @@ -127,17 +129,30 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { const auto ConstStrLiteralDecl = varDecl(isDefinition(), hasType(hasCanonicalType(CharPtrType)), hasInitializer(ignoringParenImpCasts(stringLiteral(; + const auto VarWithConstStrLiteralDecl = expr( + hasType(hasCanonicalType(CharPtrType)), + ignoringParenImpCasts(declRefExpr(hasDeclaration(ConstStrLiteralDecl; Finder->addMatcher( - sizeOfExpr(has(ignoringParenImpCasts( - expr(hasType(hasCanonicalType(CharPtrType)), -
[clang-tools-extra] [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (PR #94356)
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/94356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Fix handling of cyclical data structures in HTMLLogger. (PR #66887)
https://github.com/sam-mccall approved this pull request. The code looks good for the changes you want to make. Personally I'd keep the existing pruning behavior for all duplicated nodes, and use cosmetic/navigation changes to clarify. But I think you probably know better than me what's useful, and at this point it isn't my call either way :-) https://github.com/llvm/llvm-project/pull/66887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lld] [llvm] [FileCheck] forbid filecheck check prefix definitions to end with directive name (PR #92735)
https://github.com/klensy updated https://github.com/llvm/llvm-project/pull/92735 >From 21fc194add139509cf960f749166e8be423467d8 Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 15 May 2024 14:30:55 +0300 Subject: [PATCH 1/5] filecheck: forbid filecheck prefix definitions end with directive name --- llvm/lib/FileCheck/FileCheck.cpp | 18 ++ 1 file changed, 18 insertions(+) diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index 1719f8ef2b436..09446e506065f 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -2490,6 +2490,22 @@ static bool ValidatePrefixes(StringRef Kind, StringSet<> &UniquePrefixes, return true; } +static bool ValidateCheckPrefixesSuffix(StringRef Kind, +ArrayRef SuppliedPrefixes) { + static const char *Suffixes[] = {"-NEXT", "-SAME", "-EMPTY", "-NOT", + "-COUNT", "-DAG", "-LABEL"}; + for (StringRef Prefix : SuppliedPrefixes) { +for (StringRef Suffix : Suffixes) { + if (Prefix.ends_with(Suffix)) { +errs() << "error: supplied " << Kind << " prefix must not end with " + << "directive: '" << Suffix << "', prefix: '" << Prefix << "'\n"; +return false; + } +} + } + return true; +} + bool FileCheck::ValidateCheckPrefixes() { StringSet<> UniquePrefixes; // Add default prefixes to catch user-supplied duplicates of them below. @@ -2505,6 +2521,8 @@ bool FileCheck::ValidateCheckPrefixes() { // incorrectly indicate that they were supplied by the user. if (!ValidatePrefixes("check", UniquePrefixes, Req.CheckPrefixes)) return false; + if (!ValidateCheckPrefixesSuffix("check", Req.CheckPrefixes)) +return false; if (!ValidatePrefixes("comment", UniquePrefixes, Req.CommentPrefixes)) return false; return true; >From d29d6155ac17684277fa7d18f91f48e4a0477780 Mon Sep 17 00:00:00 2001 From: klensy Date: Sun, 19 May 2024 15:54:31 +0300 Subject: [PATCH 2/5] filecheck: fix self tests for "forbid check prefixes end with directive name" --- .../FileCheck/comment/bad-comment-prefix.txt | 10 +- llvm/test/FileCheck/numeric-expression.txt | 16 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/llvm/test/FileCheck/comment/bad-comment-prefix.txt b/llvm/test/FileCheck/comment/bad-comment-prefix.txt index 58a8873da3218..19be577618d00 100644 --- a/llvm/test/FileCheck/comment/bad-comment-prefix.txt +++ b/llvm/test/FileCheck/comment/bad-comment-prefix.txt @@ -3,17 +3,17 @@ # Check empty comment prefix. RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ RUN: -comment-prefixes= | \ -RUN: FileCheck -check-prefix=PREFIX-EMPTY %s +RUN: FileCheck -check-prefix=EMPTY-PREFIX %s RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ RUN: -comment-prefixes=,FOO | \ -RUN: FileCheck -check-prefix=PREFIX-EMPTY %s +RUN: FileCheck -check-prefix=EMPTY-PREFIX %s RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ RUN: -comment-prefixes=FOO, | \ -RUN: FileCheck -check-prefix=PREFIX-EMPTY %s +RUN: FileCheck -check-prefix=EMPTY-PREFIX %s RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ RUN: -comment-prefixes=FOO,,BAR | \ -RUN: FileCheck -check-prefix=PREFIX-EMPTY %s -PREFIX-EMPTY: error: supplied comment prefix must not be the empty string +RUN: FileCheck -check-prefix=EMPTY-PREFIX %s +EMPTY-PREFIX: error: supplied comment prefix must not be the empty string # Check invalid characters in comment prefix. RUN: %ProtectFileCheckOutput not FileCheck /dev/null < /dev/null 2>&1 \ diff --git a/llvm/test/FileCheck/numeric-expression.txt b/llvm/test/FileCheck/numeric-expression.txt index 1430484d08ebc..f23628f5fbc9a 100644 --- a/llvm/test/FileCheck/numeric-expression.txt +++ b/llvm/test/FileCheck/numeric-expression.txt @@ -593,16 +593,16 @@ CALL-MISSING-ARGUMENT-MSG-NEXT: {{C}}ALL-MISSING-ARGUMENT-NEXT: {{\[\[#add\(NUMV CALL-MISSING-ARGUMENT-MSG-NEXT: {{^}} ^{{$}} RUN: %ProtectFileCheckOutput \ -RUN: not FileCheck -D#NUMVAR=10 --check-prefix CALL-WRONG-ARGUMENT-COUNT --input-file %s %s 2>&1 \ -RUN: | FileCheck --strict-whitespace --check-prefix CALL-WRONG-ARGUMENT-COUNT-MSG %s +RUN: not FileCheck -D#NUMVAR=10 --check-prefix CALL-WRONG-ARGUMENT-NUM --input-file %s %s 2>&1 \ +RUN: | FileCheck --strict-whitespace --check-prefix CALL-WRONG-ARGUMENT-NUM-MSG %s -CALL WRONG ARGUMENT COUNT +CALL WRONG ARGUMENT NUM 30 -CALL-WRONG-ARGUMENT-COUNT-LABEL: CALL WRONG ARGUMENT COUNT -CALL-WRONG-ARGUMENT-COUNT-NEXT: [[#add(NUMVAR)]] -CALL-WRONG-ARGUMENT-COUNT-MSG: numeric-expression.txt:[[#@LINE-1]]:36: error: function 'add' takes 2 argument
[clang] [clang-tools-extra] [lld] [llvm] [FileCheck] forbid filecheck check prefix definitions to end with directive name (PR #92735)
@@ -1,5 +1,5 @@ // RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s --implicit-check-not='call{{.*}}dtor' -// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-CXX23,CHECK-CXX23-NEXT,CHECK-CXX23-LABEL +// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-CXX23 klensy wrote: Currently there error only with that test. https://github.com/llvm/llvm-project/pull/92735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
https://github.com/ergawy approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95102)
@@ -8084,29 +8084,6 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM()); } - // Target must have NEON (or MVE, whose vectors are similar enough - // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; -Attr.setInvalid(); -return; - } - if (!(S.Context.getTargetInfo().hasFeature("neon") || CarolineConcatto wrote: I believe we may need to leave still the test for MVE. We need to leave a comment in the ACLE stating that the MVE header is still needed. https://github.com/llvm/llvm-project/pull/95102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Cover CWG issues about `export template` (PR #94876)
AaronBallman wrote: The goal of the status page is to convey implementation status to our users, and so from that perspective I think N/A provides the least information to users because it basically says "this entry doesn't apply to us". So in these kinds of cases, `sup` conveys more information because the DRs would apply to us, except another DR superseded the need for making the changes. In terms of the color used, we want green to mean "we're behaving in a conforming way" so users can tell at a glance where the edge cases are. This case is a bit weird because "conform" means we *don't* implement something rather than we *do* implement it, but I still think green is appropriate because we're following the standard. It might be fine to give a different color to superseded, but I would guess we'd want that to be a lighter form version of whatever the superseding issue is colored. e.g., given that conforming = green and non-conforming = red, if we have a superseded issue we conform to, it would be light green, and if we didn't conform it would be pink. WDYT? https://github.com/llvm/llvm-project/pull/94876 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95102)
@@ -8084,29 +8084,6 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM()); } - // Target must have NEON (or MVE, whose vectors are similar enough - // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; -Attr.setInvalid(); -return; - } - if (!(S.Context.getTargetInfo().hasFeature("neon") || Lukacma wrote: Do we ? From my understanding this checks are Neon vector types and are unrelated to MVE. The only reason MVE is used is because MVE vectors are similar enough so we can use them as neon vectors https://github.com/llvm/llvm-project/pull/95102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][SME] Save VG for unwind info when changing streaming-mode (PR #83301)
@@ -196,12 +196,14 @@ bool AArch64FunctionInfo::needsAsyncDwarfUnwindInfo( const MachineFunction &MF) const { if (!NeedsAsyncDwarfUnwindInfo) { const Function &F = MF.getFunction(); +const AArch64FunctionInfo *AFI = MF.getInfo(); // The check got "minsize" is because epilogue unwind info is not emitted // (yet) for homogeneous epilogues, outlined functions, and functions // outlined from. -NeedsAsyncDwarfUnwindInfo = needsDwarfUnwindInfo(MF) && -F.getUWTableKind() == UWTableKind::Async && -!F.hasMinSize(); +NeedsAsyncDwarfUnwindInfo = +(needsDwarfUnwindInfo(MF) && F.getUWTableKind() == UWTableKind::Async && kmclaughlin-arm wrote: I think outlining from functions with streaming-mode changes needs more investigation. I don't think this is just a concern for async unwind; I noticed that when passing `-enable-machine-outliner` to sme-vg-to-stack.ll that some calls are outlined with only one of the smstart/smstop instructions surrounding the call. I'm not sure if this is safe yet, so for now I've disabled outlining for these functions in `isFunctionSafeToOutlineFrom`. https://github.com/llvm/llvm-project/pull/83301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Cover CWG issues about `export template` (PR #94876)
Endilll wrote: Thank you for chiming in! > It might be fine to give a different color to superseded, but I would guess > we'd want that to be a lighter form version of whatever the superseding issue > is colored. e.g., given that conforming = green and non-conforming = red, if > we have a superseded issue we conform to, it would be light green, and if we > didn't conform it would be pink. WDYT? I'm thinking of reducing opacity of the color instead of picking exact shades, but yeah, we can definitely do something of this sort. https://github.com/llvm/llvm-project/pull/94876 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95102)
@@ -8084,29 +8084,6 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM()); } - // Target must have NEON (or MVE, whose vectors are similar enough - // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; -Attr.setInvalid(); -return; - } - if (!(S.Context.getTargetInfo().hasFeature("neon") || momchil-velikov wrote: You can preserve the behaviour for MVE if you alter the diagnostics condition to be `"NEON type seen" && "no MVE" && "compiling for M-class".` https://github.com/llvm/llvm-project/pull/95102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Rearrange some Apple version testing (PR #94514)
@@ -0,0 +1,9 @@ +; Test emitting version_min directives. + +; RUN: llc %s -filetype=asm -o - --mtriple arm64-apple-tvos9.0.0 | FileCheck %s --check-prefix=TVOS lenary wrote: This is not the right directory for AArch64 tests (which apple calls `arm64` in its triples), these tests will only be run if the ARM backend is enabled, whereas I think this line only wants to be run if the AArch64 backend is enabled. https://github.com/llvm/llvm-project/pull/94514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] fix false positives for the functions with the same name as standard library functions in misc-include-cleaner (PR #94923)
https://github.com/HerrCai0907 closed https://github.com/llvm/llvm-project/pull/94923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 1bae108 - [clang-tidy] fix false positives for the functions with the same name as standard library functions in misc-include-cleaner (#94923)
Author: Congcong Cai Date: 2024-06-11T21:01:52+08:00 New Revision: 1bae10879d9183c5edfb709c36b55086ebc772f0 URL: https://github.com/llvm/llvm-project/commit/1bae10879d9183c5edfb709c36b55086ebc772f0 DIFF: https://github.com/llvm/llvm-project/commit/1bae10879d9183c5edfb709c36b55086ebc772f0.diff LOG: [clang-tidy] fix false positives for the functions with the same name as standard library functions in misc-include-cleaner (#94923) Fixes: #93335 For decl with body, we should provide physical locations also. Because it may be the function which have the same name as std library. Added: Modified: clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp Removed: diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 2dc39d0ad74af..6bf70c5cf4f8a 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -337,6 +337,10 @@ Changes in existing checks ` check by avoiding crash for self include cycles. +- Improved :doc:`misc-include-cleaner + ` check by avoiding false positives for + the functions with the same name as standard library functions. + - Improved :doc:`misc-unused-using-decls ` check by replacing the local option `HeaderFileExtensions` by the global option of the same name. diff --git a/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp b/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp index 78e783a62eb27..9148d36a5038f 100644 --- a/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp +++ b/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp @@ -14,6 +14,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/Tooling/Inclusions/StandardLibrary.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/raw_ostream.h" #include #include @@ -40,8 +41,11 @@ Hints declHints(const Decl *D) { std::vector> locateDecl(const Decl &D) { std::vector> Result; // FIXME: Should we also provide physical locations? - if (auto SS = tooling::stdlib::Recognizer()(&D)) -return {{*SS, Hints::CompleteSymbol}}; + if (auto SS = tooling::stdlib::Recognizer()(&D)) { +Result.push_back({*SS, Hints::CompleteSymbol}); +if (!D.hasBody()) + return Result; + } // FIXME: Signal foreign decls, e.g. a forward declaration not owned by a // library. Some useful signals could be derived by checking the DeclContext. // Most incidental forward decls look like: diff --git a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp index 07302142a13e3..fdcbf25fd628c 100644 --- a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp @@ -628,6 +628,17 @@ TEST_F(HeadersForSymbolTest, StandardHeaders) { tooling::stdlib::Header::named(""))); } +TEST_F(HeadersForSymbolTest, NonStandardHeaders) { + Inputs.Code = "void assert() {}"; + buildAST(); + EXPECT_THAT( + headersFor("assert"), + // Respect the ordering from the stdlib mapping. + UnorderedElementsAre(physicalHeader("input.mm"), + tooling::stdlib::Header::named(""), + tooling::stdlib::Header::named(""))); +} + TEST_F(HeadersForSymbolTest, ExporterNoNameMatch) { Inputs.Code = R"cpp( #include "exporter/foo.h" diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp index e10ac3f46e2e9..d5ea96b00254c 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp @@ -15,3 +15,11 @@ std::string HelloString; // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" is directly included [misc-include-cleaner] int FooBarResult = foobar(); // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is directly included [misc-include-cleaner] + +namespace valid { + +namespace gh93335 { +void log2() {} +} // namespace gh93335 + +} // namespace valid ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Add option to select compiler-rt arch suffix (PR #89775)
tru wrote: I don't have the bandwidth to get a RFC through right now. If this is broken and no-one wants to take care of getting consensus for something new, I suggest you revert to the previous state. For my toolchain I can continue to carry a patch until this is all sorted. https://github.com/llvm/llvm-project/pull/89775 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e805b77 - [clang][Interp] Support ObjCEncodeExprs
Author: Timm Bäder Date: 2024-06-11T15:07:28+02:00 New Revision: e805b77107c8a26ad129fb2a46cdec01c90628be URL: https://github.com/llvm/llvm-project/commit/e805b77107c8a26ad129fb2a46cdec01c90628be DIFF: https://github.com/llvm/llvm-project/commit/e805b77107c8a26ad129fb2a46cdec01c90628be.diff LOG: [clang][Interp] Support ObjCEncodeExprs Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/lib/AST/Interp/ByteCodeExprGen.h clang/test/CodeGenObjC/encode-test-3.m Removed: diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 0899a98b3b95a..0385ca4b3a063 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1688,6 +1688,17 @@ bool ByteCodeExprGen::VisitObjCStringLiteral( return this->delegate(E->getString()); } +template +bool ByteCodeExprGen::VisitObjCEncodeExpr(const ObjCEncodeExpr *E) { + auto &A = Ctx.getASTContext(); + std::string Str; + A.getObjCEncodingForType(E->getEncodedType(), Str); + StringLiteral *SL = + StringLiteral::Create(A, Str, StringLiteralKind::Ordinary, +/*Pascal=*/false, E->getType(), E->getAtLoc()); + return this->delegate(SL); +} + template bool ByteCodeExprGen::VisitSYCLUniqueStableNameExpr( const SYCLUniqueStableNameExpr *E) { diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h index 7ab14b6ab383e..295cfef0525cd 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -91,6 +91,7 @@ class ByteCodeExprGen : public ConstStmtVisitor, bool>, bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E); bool VisitStringLiteral(const StringLiteral *E); bool VisitObjCStringLiteral(const ObjCStringLiteral *E); + bool VisitObjCEncodeExpr(const ObjCEncodeExpr *E); bool VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E); bool VisitCharacterLiteral(const CharacterLiteral *E); bool VisitCompoundAssignOperator(const CompoundAssignOperator *E); diff --git a/clang/test/CodeGenObjC/encode-test-3.m b/clang/test/CodeGenObjC/encode-test-3.m index 0856b770d65a5..30557fccf02df 100644 --- a/clang/test/CodeGenObjC/encode-test-3.m +++ b/clang/test/CodeGenObjC/encode-test-3.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o - %s -fexperimental-new-constant-interpreter | FileCheck %s int main(void) { int n; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Rearrange some Apple version testing (PR #94514)
@@ -0,0 +1,9 @@ +; Test emitting version_min directives. + +; RUN: llc %s -filetype=asm -o - --mtriple arm64-apple-tvos9.0.0 | FileCheck %s --check-prefix=TVOS pogo59 wrote: Right, this test has one arm64 command and two thumb commands. I just now pushed #95106 to add aarch64-registered-target to this test. I did that because the different options are thematically related and splitting into two tests seemed not in the best interests of test coherency. https://github.com/llvm/llvm-project/pull/94514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Rearrange some Apple version testing (PR #94514)
@@ -0,0 +1,9 @@ +; Test emitting version_min directives. + +; RUN: llc %s -filetype=asm -o - --mtriple arm64-apple-tvos9.0.0 | FileCheck %s --check-prefix=TVOS lenary wrote: That fix makes sense to me. Thanks! https://github.com/llvm/llvm-project/pull/94514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)
https://github.com/Endilll commented: Thank you for your great work! However, I don't think this can be merged as is: 1) I have maintainability concerns about `ClangLib` protocol. From what I see, `clang_`-prefixed functions are not really intended to be a user-facing interface, and instead wrapped in Python code that has type annotations. When a new function is added to `libclang`, we won't just add a wrapper, implement it, and annotate, but also add the `clang_`-prefixed function into `ClangLib`, and basically duplicate the annotation for it. 2) I see several bugfixes that you highlighted with your comments. I believe they should be done as a separate PR, because they do something else than just add typing annotations. 3) Changes to enums are massive, and feel somewhat out of place in this PR as well. Splitting things out would also help reviewing. Several times I found myself in a "this is indented, but which scope I'm in again? Need to scroll all the way up to find out" situation. https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
https://github.com/zahiraam updated https://github.com/llvm/llvm-project/pull/88978 >From 3acc848f4fcc68445dfc849f9c6f8d384d3692af Mon Sep 17 00:00:00 2001 From: Zahira Ammarguellat Date: Tue, 16 Apr 2024 13:09:58 -0700 Subject: [PATCH 1/9] Adding C23 constexpr math functions fmin and frexp. --- clang/include/clang/Basic/Builtins.td | 4 +-- clang/lib/AST/ExprConstant.cpp| 16 - clang/test/CodeGen/constexpr-math.cpp | 51 +++ 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 clang/test/CodeGen/constexpr-math.cpp diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 52c0dd52c28b1..a35c77286229f 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -3440,7 +3440,7 @@ def Fmod : FPMathTemplate, LibBuiltin<"math.h"> { def Frexp : FPMathTemplate, LibBuiltin<"math.h"> { let Spellings = ["frexp"]; - let Attributes = [NoThrow]; + let Attributes = [NoThrow, Constexpr]; let Prototype = "T(T, int*)"; let AddBuiltinPrefixedAlias = 1; } @@ -3618,7 +3618,7 @@ def Fmax : FPMathTemplate, LibBuiltin<"math.h"> { def Fmin : FPMathTemplate, LibBuiltin<"math.h"> { let Spellings = ["fmin"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, Constexpr]; let Prototype = "T(T, T)"; let AddBuiltinPrefixedAlias = 1; let OnlyBuiltinPrefixedAliasIsConstexpr = 1; diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5a36621dc5cce..506621ac7e9c1 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo &Info, const BinaryOperator *E, // If during the evaluation of an expression, the result is not // mathematically defined [...], the behavior is undefined. // FIXME: C++ rules require us to not conform to IEEE 754 here. - if (LHS.isNaN()) { + if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) { Info.CCEDiag(E, diag::note_constexpr_float_arithmetic) << LHS.isNaN(); return Info.noteUndefinedBehavior(); } @@ -14547,6 +14547,18 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { default: return false; + case Builtin::BI__builtin_frexpf: + case Builtin::BI__builtin_frexp: { +LValue Pointer; +if (!EvaluateFloat(E->getArg(0), Result, Info) || +!EvaluatePointer(E->getArg(1), Pointer, Info)) + return false; +llvm::RoundingMode RM = +E->getFPFeaturesInEffect(Info.Ctx.getLangOpts()).getRoundingMode(); +int FrexpExp; +Result = llvm::frexp(Result, FrexpExp, RM); +return true; + } case Builtin::BI__builtin_huge_val: case Builtin::BI__builtin_huge_valf: case Builtin::BI__builtin_huge_vall: @@ -14638,6 +14650,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { return true; } + case Builtin::BIfmin: + case Builtin::BIfminf: case Builtin::BI__builtin_fmin: case Builtin::BI__builtin_fminf: case Builtin::BI__builtin_fminl: diff --git a/clang/test/CodeGen/constexpr-math.cpp b/clang/test/CodeGen/constexpr-math.cpp new file mode 100644 index 0..446bf3f4f7a50 --- /dev/null +++ b/clang/test/CodeGen/constexpr-math.cpp @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -std=c++23 \ +// RUN: -emit-llvm -o - %s | FileCheck %s + +// RUN %clang_cc1 -x c++ -triple x86_64-linux-gnu -emit-llvm -o - %s \ +// RUN -std=c++23 + +#define INFINITY ((float)(1e+300 * 1e+300)) +#define NAN (-(float)(INFINITY * 0.0F)) + +//constexpr double frexp ( double num, int* exp ); +//constexpr float foo ( float num, int* exp ); + +int func() +{ + int i; + + // fmin + constexpr double f1 = __builtin_fmin(15.24, 1.3); + constexpr double f2 = __builtin_fmin(-0.0, +0.0); + constexpr double f3 = __builtin_fmin(+0.0, -0.0); + constexpr float f4 = __builtin_fminf(NAN, NAN); + constexpr float f5 = __builtin_fminf(NAN, -1); + constexpr float f6 = __builtin_fminf(-INFINITY, 0); + constexpr float f7 = __builtin_fminf(INFINITY, 0); + + // frexp + constexpr double f8 = __builtin_frexp(123.45, &i); + constexpr double f9 = __builtin_frexp(0.0, &i); + constexpr double f10 = __builtin_frexp(-0.0, &i); + constexpr double f11 = __builtin_frexpf(NAN, &i); + constexpr double f12 = __builtin_frexpf(-NAN, &i); + constexpr double f13 = __builtin_frexpf(INFINITY, &i); + constexpr double f14 = __builtin_frexpf(INFINITY, &i); + + return 0; +} + +// CHECK: store double 1.30e+00, ptr {{.*}} +// CHECK: store double -0.00e+00, ptr {{.*}} +// CHECK: store double -0.00e+00, ptr {{.*}} +// CHECK: store float 0xFFF8, ptr {{.*}} +// CHECK: store float -1.00e+00, ptr {{.*}} +// CHECK: store float 0xFFF0, ptr {{.*}} + +// CHECK: store double 0x3FEEDCCD, ptr {{.*}} +// CHECK: store double 0.00e+00, ptr {{.*}} +// CHECK: store double -0.00e+00, ptr {{.*}}
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
@@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo &Info, const BinaryOperator *E, // If during the evaluation of an expression, the result is not // mathematically defined [...], the behavior is undefined. // FIXME: C++ rules require us to not conform to IEEE 754 here. - if (LHS.isNaN()) { + if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) { zahiraam wrote: Removed and edit the SemaCXX/constexpr-math.cpp to reflect the change. https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
@@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -DWIN -verify -std=c++23 -fsyntax-only %s +// RUN: %clang_cc1 -verify -std=c++23 -fsyntax-only %s zahiraam wrote: Done. https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
@@ -14683,6 +14710,23 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { default: return false; + case Builtin::BI__builtin_frexp: zahiraam wrote: Added the non-`__builtin_ prefixed cases. https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
@@ -3452,9 +3452,10 @@ def Fmod : FPMathTemplate, LibBuiltin<"math.h"> { def Frexp : FPMathTemplate, LibBuiltin<"math.h"> { let Spellings = ["frexp"]; - let Attributes = [NoThrow]; + let Attributes = [NoThrow, Constexpr]; zahiraam wrote: Done. https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Add option to select compiler-rt arch suffix (PR #89775)
pogo59 wrote: > For my toolchain I can continue to carry a patch until this is all sorted. Same here; I'm just professionally offended by the brokenness. But I'm not the right person to drive an RFC. If nobody else is willing to, I'll abandon this and we'll do what we need to downstream to hack around it. https://github.com/llvm/llvm-project/pull/89775 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
https://github.com/zahiraam updated https://github.com/llvm/llvm-project/pull/88978 >From 3acc848f4fcc68445dfc849f9c6f8d384d3692af Mon Sep 17 00:00:00 2001 From: Zahira Ammarguellat Date: Tue, 16 Apr 2024 13:09:58 -0700 Subject: [PATCH 01/10] Adding C23 constexpr math functions fmin and frexp. --- clang/include/clang/Basic/Builtins.td | 4 +-- clang/lib/AST/ExprConstant.cpp| 16 - clang/test/CodeGen/constexpr-math.cpp | 51 +++ 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 clang/test/CodeGen/constexpr-math.cpp diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 52c0dd52c28b1..a35c77286229f 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -3440,7 +3440,7 @@ def Fmod : FPMathTemplate, LibBuiltin<"math.h"> { def Frexp : FPMathTemplate, LibBuiltin<"math.h"> { let Spellings = ["frexp"]; - let Attributes = [NoThrow]; + let Attributes = [NoThrow, Constexpr]; let Prototype = "T(T, int*)"; let AddBuiltinPrefixedAlias = 1; } @@ -3618,7 +3618,7 @@ def Fmax : FPMathTemplate, LibBuiltin<"math.h"> { def Fmin : FPMathTemplate, LibBuiltin<"math.h"> { let Spellings = ["fmin"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, Constexpr]; let Prototype = "T(T, T)"; let AddBuiltinPrefixedAlias = 1; let OnlyBuiltinPrefixedAliasIsConstexpr = 1; diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5a36621dc5cce..506621ac7e9c1 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo &Info, const BinaryOperator *E, // If during the evaluation of an expression, the result is not // mathematically defined [...], the behavior is undefined. // FIXME: C++ rules require us to not conform to IEEE 754 here. - if (LHS.isNaN()) { + if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) { Info.CCEDiag(E, diag::note_constexpr_float_arithmetic) << LHS.isNaN(); return Info.noteUndefinedBehavior(); } @@ -14547,6 +14547,18 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { default: return false; + case Builtin::BI__builtin_frexpf: + case Builtin::BI__builtin_frexp: { +LValue Pointer; +if (!EvaluateFloat(E->getArg(0), Result, Info) || +!EvaluatePointer(E->getArg(1), Pointer, Info)) + return false; +llvm::RoundingMode RM = +E->getFPFeaturesInEffect(Info.Ctx.getLangOpts()).getRoundingMode(); +int FrexpExp; +Result = llvm::frexp(Result, FrexpExp, RM); +return true; + } case Builtin::BI__builtin_huge_val: case Builtin::BI__builtin_huge_valf: case Builtin::BI__builtin_huge_vall: @@ -14638,6 +14650,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { return true; } + case Builtin::BIfmin: + case Builtin::BIfminf: case Builtin::BI__builtin_fmin: case Builtin::BI__builtin_fminf: case Builtin::BI__builtin_fminl: diff --git a/clang/test/CodeGen/constexpr-math.cpp b/clang/test/CodeGen/constexpr-math.cpp new file mode 100644 index 0..446bf3f4f7a50 --- /dev/null +++ b/clang/test/CodeGen/constexpr-math.cpp @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -std=c++23 \ +// RUN: -emit-llvm -o - %s | FileCheck %s + +// RUN %clang_cc1 -x c++ -triple x86_64-linux-gnu -emit-llvm -o - %s \ +// RUN -std=c++23 + +#define INFINITY ((float)(1e+300 * 1e+300)) +#define NAN (-(float)(INFINITY * 0.0F)) + +//constexpr double frexp ( double num, int* exp ); +//constexpr float foo ( float num, int* exp ); + +int func() +{ + int i; + + // fmin + constexpr double f1 = __builtin_fmin(15.24, 1.3); + constexpr double f2 = __builtin_fmin(-0.0, +0.0); + constexpr double f3 = __builtin_fmin(+0.0, -0.0); + constexpr float f4 = __builtin_fminf(NAN, NAN); + constexpr float f5 = __builtin_fminf(NAN, -1); + constexpr float f6 = __builtin_fminf(-INFINITY, 0); + constexpr float f7 = __builtin_fminf(INFINITY, 0); + + // frexp + constexpr double f8 = __builtin_frexp(123.45, &i); + constexpr double f9 = __builtin_frexp(0.0, &i); + constexpr double f10 = __builtin_frexp(-0.0, &i); + constexpr double f11 = __builtin_frexpf(NAN, &i); + constexpr double f12 = __builtin_frexpf(-NAN, &i); + constexpr double f13 = __builtin_frexpf(INFINITY, &i); + constexpr double f14 = __builtin_frexpf(INFINITY, &i); + + return 0; +} + +// CHECK: store double 1.30e+00, ptr {{.*}} +// CHECK: store double -0.00e+00, ptr {{.*}} +// CHECK: store double -0.00e+00, ptr {{.*}} +// CHECK: store float 0xFFF8, ptr {{.*}} +// CHECK: store float -1.00e+00, ptr {{.*}} +// CHECK: store float 0xFFF0, ptr {{.*}} + +// CHECK: store double 0x3FEEDCCD, ptr {{.*}} +// CHECK: store double 0.00e+00, ptr {{.*}} +// CHECK: store double -0.00e+00, ptr {{.*
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
@@ -6,17 +6,21 @@ // RUN: %clang_cc1 -triple powerpc-ibm-aix -mlong-double-64 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK %s // RUN: %clang_cc1 -triple powerpc64-ibm-aix -mlong-double-64 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK %s +long double input = 0.0L; + int main() { int DummyInt; long double DummyLongDouble; long double returnValue; returnValue = __builtin_modfl(1.0L, &DummyLongDouble); - returnValue = __builtin_frexpl(0.0L, &DummyInt); + returnValue = __builtin_frexpl(input, &DummyInt); zahiraam wrote: Done. https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)
https://github.com/Andarwinux updated https://github.com/llvm/llvm-project/pull/94731 >From 15ae0f6f3f03f3fcf32bc93c16258dc79d61b222 Mon Sep 17 00:00:00 2001 From: Andarwinux <144242044+andarwi...@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:07:40 + Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver fixes #91216 --- clang/include/clang/Driver/Options.td | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d44faa55c456f..1cce7a5146dd8 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">, Alias<_SLASH_winsdkdir>; def : Separate<["-"], "Xmicrosoft-windows-sdk-version">, Alias<_SLASH_winsdkversion>; +def : Separate<["-"], "Xmicrosoft-windows-sys-root">, +Alias<_SLASH_winsysroot>; // Ignored: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits