[clang] 1b3a78d - [clang] Use std::size instead of llvm::array_lengthof
Author: Joe Loser Date: 2022-09-08T17:20:25-06:00 New Revision: 1b3a78d1d534550b2f85a81b2e9ac6d7a94a478e URL: https://github.com/llvm/llvm-project/commit/1b3a78d1d534550b2f85a81b2e9ac6d7a94a478e DIFF: https://github.com/llvm/llvm-project/commit/1b3a78d1d534550b2f85a81b2e9ac6d7a94a478e.diff LOG: [clang] Use std::size instead of llvm::array_lengthof LLVM contains a helpful function for getting the size of a C-style array: `llvm::array_lengthof`. This is useful prior to C++17, but not as helpful for C++17 or later: `std::size` already has support for C-style arrays. Change call sites to use `std::size` instead. Leave the few call sites that use a locally defined `array_lengthof` that are meant to test previous bugs with NTTPs in clang analyzer and SemaTemplate. Differential Revision: https://reviews.llvm.org/D133520 Added: Modified: clang/include/clang/AST/OpenMPClause.h clang/lib/AST/AttrDocTable.cpp clang/lib/AST/CommentCommandTraits.cpp clang/lib/Basic/DiagnosticIDs.cpp clang/lib/Basic/Targets/NVPTX.h clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGObjC.cpp clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/Types.cpp clang/lib/Frontend/PrintPreprocessedOutput.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Sema/DeclSpec.cpp clang/lib/Sema/ParsedAttr.cpp clang/unittests/AST/CommentLexer.cpp clang/unittests/AST/CommentParser.cpp clang/unittests/AST/DeclPrinterTest.cpp clang/unittests/Tooling/CompilationDatabaseTest.cpp Removed: diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h index fd6f50e31bfe1..23b4a9517192c 100644 --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -5785,12 +5785,11 @@ class OMPMapClause final : public OMPMappableExprListClause, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo), MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) { -assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size() && +assert(std::size(MapTypeModifiers) == MapModifiers.size() && "Unexpected number of map type modifiers."); llvm::copy(MapModifiers, std::begin(MapTypeModifiers)); -assert(llvm::array_lengthof(MapTypeModifiersLoc) == - MapModifiersLoc.size() && +assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() && "Unexpected number of map type modifier locations."); llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc)); } @@ -6707,12 +6706,11 @@ class OMPToClause final : public OMPMappableExprListClause, : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo) { -assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && +assert(std::size(MotionModifiers) == TheMotionModifiers.size() && "Unexpected number of motion modifiers."); llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); -assert(llvm::array_lengthof(MotionModifiersLoc) == - TheMotionModifiersLoc.size() && +assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() && "Unexpected number of motion modifier locations."); llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); } @@ -6909,12 +6907,11 @@ class OMPFromClause final : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo) { -assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && +assert(std::size(MotionModifiers) == TheMotionModifiers.size() && "Unexpected number of motion modifiers."); llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); -assert(llvm::array_lengthof(MotionModifiersLoc) == - TheMotionModifiersLoc.size() && +assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() && "Unexpected number of motion modifier locations."); llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); } diff --git a/clang/lib/AST/AttrDocTable.cpp b/clang/lib/AST/AttrDocTable.cpp index 3bfedac8b8f13..df7e3d63a6c35 100644 --- a/clang/lib/AST/AttrDocTable.cpp +++ b/clang/lib/AST/AttrDocTable.cpp @@ -21,7 +21,7 @@ static const llvm::StringRef AttrDoc[] = { }; llvm::StringRef clang::Attr::getDocumentation(clang::attr::Kind K) { - if(K < llvm::array_lengthof(AttrDoc)) + if (K < std::size(AttrDoc)) return AttrDoc[K]; return ""; } diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTrait
[clang] e857896 - [ADT] Replace STLForwardCompat.h's C++17 equivalents
Author: Joe Loser Date: 2022-08-12T06:55:59-06:00 New Revision: e8578968f684997840f680ed62bff5cad0accc13 URL: https://github.com/llvm/llvm-project/commit/e8578968f684997840f680ed62bff5cad0accc13 DIFF: https://github.com/llvm/llvm-project/commit/e8578968f684997840f680ed62bff5cad0accc13.diff LOG: [ADT] Replace STLForwardCompat.h's C++17 equivalents STLForwardCompat.h defines several utilities and type traits to mimic that of the ones in the C++17 standard library. Now that LLVM is built with the C++17 standards mode, remove use of these equivalents in favor of the ones from the standard library. Differential Revision: https://reviews.llvm.org/D131717 Added: Modified: clang/include/clang/Basic/DirectoryEntry.h clang/include/clang/Basic/FileEntry.h llvm/include/llvm/ADT/Any.h llvm/include/llvm/ADT/FunctionExtras.h llvm/include/llvm/ADT/Optional.h llvm/include/llvm/ADT/STLExtras.h llvm/include/llvm/Support/HashBuilder.h llvm/unittests/ADT/OptionalTest.cpp Removed: diff --git a/clang/include/clang/Basic/DirectoryEntry.h b/clang/include/clang/Basic/DirectoryEntry.h index f1ec63d975a37..19d52c09dbcce 100644 --- a/clang/include/clang/Basic/DirectoryEntry.h +++ b/clang/include/clang/Basic/DirectoryEntry.h @@ -22,6 +22,8 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorOr.h" +#include + namespace clang { namespace FileMgr { @@ -125,7 +127,7 @@ template class MapEntryOptionalStorage { MapEntryOptionalStorage() : MaybeRef(optional_none_tag()) {} template - explicit MapEntryOptionalStorage(llvm::in_place_t, ArgTypes &&...Args) + explicit MapEntryOptionalStorage(std::in_place_t, ArgTypes &&...Args) : MaybeRef(std::forward(Args)...) {} void reset() { MaybeRef = optional_none_tag(); } @@ -189,8 +191,8 @@ class OptionalStorage OptionalStorage() = default; template - explicit OptionalStorage(in_place_t, ArgTypes &&...Args) - : StorageImpl(in_place_t{}, std::forward(Args)...) {} + explicit OptionalStorage(std::in_place_t, ArgTypes &&...Args) + : StorageImpl(std::in_place_t{}, std::forward(Args)...) {} OptionalStorage &operator=(clang::DirectoryEntryRef Ref) { StorageImpl::operator=(Ref); diff --git a/clang/include/clang/Basic/FileEntry.h b/clang/include/clang/Basic/FileEntry.h index 3ca07cb422b64..d9b92a73a1d82 100644 --- a/clang/include/clang/Basic/FileEntry.h +++ b/clang/include/clang/Basic/FileEntry.h @@ -24,6 +24,8 @@ #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem/UniqueID.h" +#include + namespace llvm { class MemoryBuffer; @@ -222,8 +224,8 @@ class OptionalStorage OptionalStorage() = default; template - explicit OptionalStorage(in_place_t, ArgTypes &&...Args) - : StorageImpl(in_place_t{}, std::forward(Args)...) {} + explicit OptionalStorage(std::in_place_t, ArgTypes &&...Args) + : StorageImpl(std::in_place_t{}, std::forward(Args)...) {} OptionalStorage &operator=(clang::FileEntryRef Ref) { StorageImpl::operator=(Ref); diff --git a/llvm/include/llvm/ADT/Any.h b/llvm/include/llvm/ADT/Any.h index 1c7ba03717816..649a9986c0a41 100644 --- a/llvm/include/llvm/ADT/Any.h +++ b/llvm/include/llvm/ADT/Any.h @@ -68,8 +68,8 @@ class LLVM_EXTERNAL_VISIBILITY Any { // instead. template , Any>>, +std::conjunction< +std::negation, Any>>, // We also disable this overload when an `Any` object can be // converted to the parameter type because in that case, // this constructor may combine with that conversion during @@ -80,7 +80,7 @@ class LLVM_EXTERNAL_VISIBILITY Any { // DR in `std::any` as well, but we're going ahead and // adopting it to work-around usage of `Any` with types that // need to be implicitly convertible from an `Any`. -llvm::negation>>, +std::negation>>, std::is_copy_constructible>>::value, int> = 0> Any(T &&Value) { diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h index 5a37417ddde5d..8ff0fb787a77d 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h @@ -65,7 +65,7 @@ template using EnableUnlessSameType = std::enable_if_t, ThisT>::value>; template -using EnableIfCallable = std::enable_if_t, std::is_same()(std::declval()...)), Ret>, diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h index 09770c4f94a0e..1862a2d703aad 100644 --- a/llvm/include/llvm/ADT/Optional.h +++ b/llvm/include/llvm/ADT/Optional.h @@ -81,7 +81,7 @@ class OptionalStorage { } template - constexpr explicit OptionalStorage(in_place_t, Args &&...args) + constexpr explicit
[clang] cf77333 - [clang][docs] Fix supported element types for __builtin_reduce_(add|mul)
Author: Joe Loser Date: 2022-09-22T07:52:22-06:00 New Revision: cf77333da986720e9aded4301d81a581e2be9611 URL: https://github.com/llvm/llvm-project/commit/cf77333da986720e9aded4301d81a581e2be9611 DIFF: https://github.com/llvm/llvm-project/commit/cf77333da986720e9aded4301d81a581e2be9611.diff LOG: [clang][docs] Fix supported element types for __builtin_reduce_(add|mul) The docs mention that `__builtin_reduce_add` and `__builtin_reduce_mul` support both integer and floating point element types, but only integer element types are actually supported. See https://github.com/llvm/llvm-project/issues/57847, and specifically, https://github.com/llvm/llvm-project/blob/00874c48ea4d291908517afaab50d1dcbfb016c3/clang/lib/Sema/SemaChecking.cpp#L2631 for the fact that floating point element types are not supported yet. Fix the docs to only mention support for integer element types. Added: Modified: clang/docs/LanguageExtensions.rst Removed: diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 6522e0492f8b..17b2f8a00297 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -648,8 +648,8 @@ Let ``VT`` be a vector type and ``ET`` the element type of ``VT``. ET __builtin_reduce_min(VT a) return x or y, whichever is smaller; If exactly one argument integer and floating point types is a NaN, return the other argument. If both arguments are NaNs, fmax() return a NaN. - ET __builtin_reduce_add(VT a) \+ integer and floating point types - ET __builtin_reduce_mul(VT a) \* integer and floating point types + ET __builtin_reduce_add(VT a) \+ integer types + ET __builtin_reduce_mul(VT a) \* integer types ET __builtin_reduce_and(VT a) & integer types ET __builtin_reduce_or(VT a)\| integer types ET __builtin_reduce_xor(VT a) ^ integer types ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8998fa6 - [clang] Change AMX macros to match names from GCC
Author: Joe Loser Date: 2023-02-03T07:00:16-07:00 New Revision: 8998fa6c14f1e19957858aa0e4b592d62ae56041 URL: https://github.com/llvm/llvm-project/commit/8998fa6c14f1e19957858aa0e4b592d62ae56041 DIFF: https://github.com/llvm/llvm-project/commit/8998fa6c14f1e19957858aa0e4b592d62ae56041.diff LOG: [clang] Change AMX macros to match names from GCC The current behavior for AMX macros is: ``` gcc -march=native -dM -E - < /dev/null | grep TILE clang -march=native -dM -E - < /dev/null | grep TILE ``` which is not ideal. Change `__AMXTILE__` and friends to `__AMX_TILE__` (i.e. have an underscore in them). This makes GCC and Clang agree on the naming of these AMX macros to simplify downstream user code. Fix this for `__AMXTILE__`, `__AMX_INT8__`, `__AMX_BF16__`, and `__AMX_FP16__`. Differential Revision: https://reviews.llvm.org/D143094 Added: Modified: clang/lib/Basic/Targets/X86.cpp clang/lib/Headers/immintrin.h clang/test/Preprocessor/predefined-arch-macros.c clang/test/Preprocessor/x86_amx_target_features.c clang/test/Preprocessor/x86_target_features.c Removed: diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index cb31712275301..490e20ce4514e 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -795,13 +795,13 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, if (HasHRESET) Builder.defineMacro("__HRESET__"); if (HasAMXTILE) -Builder.defineMacro("__AMXTILE__"); +Builder.defineMacro("__AMX_TILE__"); if (HasAMXINT8) -Builder.defineMacro("__AMXINT8__"); +Builder.defineMacro("__AMX_INT8__"); if (HasAMXBF16) -Builder.defineMacro("__AMXBF16__"); +Builder.defineMacro("__AMX_BF16__"); if (HasAMXFP16) -Builder.defineMacro("__AMXFP16__"); +Builder.defineMacro("__AMX_FP16__"); if (HasCMPCCXADD) Builder.defineMacro("__CMPCCXADD__"); if (HasRAOINT) diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h index 6967b46fdb241..0d2e8be6e4862 100644 --- a/clang/lib/Headers/immintrin.h +++ b/clang/lib/Headers/immintrin.h @@ -524,7 +524,7 @@ _storebe_i64(void * __P, long long __D) { #include #endif #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \ -defined(__AMXFP16__) +defined(__AMX_FP16__) #include #endif @@ -534,7 +534,7 @@ _storebe_i64(void * __P, long long __D) { #endif #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \ -defined(__AMXTILE__) || defined(__AMXINT8__) || defined(__AMXBF16__) +defined(__AMX_TILE__) || defined(__AMX_INT8__) || defined(__AMX_BF16__) #include #endif diff --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c index a78bac132db15..a64e5afa7aac3 100644 --- a/clang/test/Preprocessor/predefined-arch-macros.c +++ b/clang/test/Preprocessor/predefined-arch-macros.c @@ -1649,9 +1649,9 @@ // RUN: -target i386-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M32 // CHECK_SPR_M32: #define __AES__ 1 -// CHECK_SPR_M32: #define __AMXBF16__ 1 -// CHECK_SPR_M32: #define __AMXINT8__ 1 -// CHECK_SPR_M32: #define __AMXTILE__ 1 +// CHECK_SPR_M32: #define __AMX_BF16__ 1 +// CHECK_SPR_M32: #define __AMX_INT8__ 1 +// CHECK_SPR_M32: #define __AMX_TILE__ 1 // CHECK_SPR_M32: #define __AVX2__ 1 // CHECK_SPR_M32: #define __AVX512BF16__ 1 // CHECK_SPR_M32: #define __AVX512BITALG__ 1 @@ -1724,9 +1724,9 @@ // RUN: -target i386-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M64 // CHECK_SPR_M64: #define __AES__ 1 -// CHECK_SPR_M64: #define __AMXBF16__ 1 -// CHECK_SPR_M64: #define __AMXINT8__ 1 -// CHECK_SPR_M64: #define __AMXTILE__ 1 +// CHECK_SPR_M64: #define __AMX_BF16__ 1 +// CHECK_SPR_M64: #define __AMX_INT8__ 1 +// CHECK_SPR_M64: #define __AMX_TILE__ 1 // CHECK_SPR_M64: #define __AVX2__ 1 // CHECK_SPR_M64: #define __AVX512BF16__ 1 // CHECK_SPR_M64: #define __AVX512BITALG__ 1 @@ -1797,10 +1797,10 @@ // RUN: --target=i386 \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M32 // CHECK_GNR_M32: #define __AES__ 1 -// CHECK_GNR_M32: #define __AMXBF16__ 1 -// CHECK_GNR_M32: #define __AMXFP16__ 1 -// CHECK_GNR_M32: #define __AMXINT8__ 1 -// CHECK_GNR_M32: #define __AMXTILE__ 1 +// CHECK_GNR_M32: #define __AMX_BF16__ 1 +// CHECK_GNR_M32: #define __AMX_FP16__ 1 +// CHECK_GNR_M32: #define __AMX_INT8__ 1 +// CHECK_GNR_M32: #define __AMX_TILE__ 1 // CHECK_GNR_M32: #define __AVX2__ 1 // CHECK_GNR_M32: #define __AVX512BF16__ 1 // CHECK_GNR_M32: #define __AVX512BITALG__ 1 @@ -1871,10 +1871,10 @@ // RUN: --target=x86_64 \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M64 // CHECK_GNR_M64: #define __AES__ 1 -// CHECK_GNR_M64: #define __AMXBF16__ 1 -// CHECK_GNR
[clang] Pass QualifiedRenameRule strings by reference to reduce copies (PR #69848)
https://github.com/JoeLoser approved this pull request. https://github.com/llvm/llvm-project/pull/69848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits