[clang] 1724a16 - [NFC][clang] Move IR-independent parts of target MV support to X86TargetParser.cpp
Author: Andrei Elovikov Date: 2021-08-30T09:48:48-07:00 New Revision: 1724a164378f1fb5210771680eb577ddf13c5a47 URL: https://github.com/llvm/llvm-project/commit/1724a164378f1fb5210771680eb577ddf13c5a47 DIFF: https://github.com/llvm/llvm-project/commit/1724a164378f1fb5210771680eb577ddf13c5a47.diff LOG: [NFC][clang] Move IR-independent parts of target MV support to X86TargetParser.cpp ...that is located under llvm/lib/Support/. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D108423 Added: Modified: clang/lib/Basic/Targets/X86.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenModule.cpp llvm/include/llvm/Support/X86TargetParser.h llvm/lib/Support/X86TargetParser.cpp Removed: diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 5b259c95d80df..01965725bb32f 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -18,7 +18,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/X86TargetParser.h" -#include namespace clang { namespace targets { @@ -1058,34 +1057,6 @@ static llvm::X86::ProcessorFeatures getFeature(StringRef Name) { // correct, so it asserts if the value is out of range. } -static unsigned getFeaturePriority(llvm::X86::ProcessorFeatures Feat) { -#ifndef NDEBUG - // Check that priorities are set properly in the .def file. We expect that - // "compat" features are assigned non-duplicate consecutive priorities - // starting from zero (0, 1, ..., num_features - 1). -#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) PRIORITY, - unsigned Priorities[] = { -#include "llvm/Support/X86TargetParser.def" - std::numeric_limits::max() // Need to consume last comma. - }; - std::array HelperList; - std::iota(HelperList.begin(), HelperList.end(), 0); - assert(std::is_permutation(HelperList.begin(), HelperList.end(), - std::begin(Priorities), - std::prev(std::end(Priorities))) && - "Priorities don't form consecutive range!"); -#endif - - switch (Feat) { -#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) \ - case llvm::X86::FEATURE_##ENUM: \ -return PRIORITY; -#include "llvm/Support/X86TargetParser.def" - default: -llvm_unreachable("No Feature Priority for non-CPUSupports Features"); - } -} - unsigned X86TargetInfo::multiVersionSortPriority(StringRef Name) const { // Valid CPUs have a 'key feature' that compares just better than its key // feature. diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index ca6987b378a85..4e0863ab94664 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -12404,24 +12404,8 @@ Value *CodeGenFunction::EmitX86CpuSupports(const CallExpr *E) { return EmitX86CpuSupports(FeatureStr); } -uint64_t -CodeGenFunction::GetX86CpuSupportsMask(ArrayRef FeatureStrs) { - // Processor features and mapping to processor feature value. - uint64_t FeaturesMask = 0; - for (const StringRef : FeatureStrs) { -unsigned Feature = -StringSwitch(FeatureStr) -#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) \ - .Case(STR, llvm::X86::FEATURE_##ENUM) -#include "llvm/Support/X86TargetParser.def" -; -FeaturesMask |= (1ULL << Feature); - } - return FeaturesMask; -} - Value *CodeGenFunction::EmitX86CpuSupports(ArrayRef FeatureStrs) { - return EmitX86CpuSupports(GetX86CpuSupportsMask(FeatureStrs)); + return EmitX86CpuSupports(llvm::X86::getCpuSupportsMask(FeatureStrs)); } llvm::Value *CodeGenFunction::EmitX86CpuSupports(uint64_t FeaturesMask) { diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 7255c385bf163..1f05877ed6f9d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4728,8 +4728,6 @@ class CodeGenFunction : public CodeGenTypeCache { void EmitMultiVersionResolver(llvm::Function *Resolver, ArrayRef Options); - static uint64_t GetX86CpuSupportsMask(ArrayRef FeatureStrs); - private: QualType getVarArgType(const Expr *Arg); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 664acefd1815c..49d6cdf779b71 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -63,6 +63,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MD5.h" #include "llvm/Support/TimeProfiler.h" +#include "llvm/Support/X86TargetParser.h" using namespace clang; using namespace CodeGen; @@ -3402,8 +3403,8 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) { llvm::stable_sort(
[clang] 4c418c1 - Try to fix build with modules enabled after D108422
Author: Andrei Elovikov Date: 2021-08-24T10:18:15-07:00 New Revision: 4c418c1bfbc544e24b9614efc3926fe2c6218b0c URL: https://github.com/llvm/llvm-project/commit/4c418c1bfbc544e24b9614efc3926fe2c6218b0c DIFF: https://github.com/llvm/llvm-project/commit/4c418c1bfbc544e24b9614efc3926fe2c6218b0c.diff LOG: Try to fix build with modules enabled after D108422 D108422 removed Basic/X86Target.def but didn't delete the entry in module.modulemap. Do it now. Hopefully it will fix the build. Added: Modified: clang/include/clang/module.modulemap Removed: diff --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap index 33fcf9dc7576..e99b8d4f5c63 100644 --- a/clang/include/clang/module.modulemap +++ b/clang/include/clang/module.modulemap @@ -67,7 +67,6 @@ module Clang_Basic { textual header "Basic/Sanitizers.def" textual header "Basic/TargetCXXABI.def" textual header "Basic/TokenKinds.def" - textual header "Basic/X86Target.def" module * { export * } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f387a36 - [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def
Author: Andrei Elovikov Date: 2021-08-24T09:16:31-07:00 New Revision: f387a361786081f8aadf079aa32e73ed05386242 URL: https://github.com/llvm/llvm-project/commit/f387a361786081f8aadf079aa32e73ed05386242 DIFF: https://github.com/llvm/llvm-project/commit/f387a361786081f8aadf079aa32e73ed05386242.diff LOG: [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D108422 Added: Modified: clang/lib/Basic/Targets/X86.cpp llvm/include/llvm/Support/X86TargetParser.def Removed: clang/include/clang/Basic/X86Target.def diff --git a/clang/include/clang/Basic/X86Target.def b/clang/include/clang/Basic/X86Target.def deleted file mode 100644 index 3a5d5b2183f2d..0 --- a/clang/include/clang/Basic/X86Target.def +++ /dev/null @@ -1,59 +0,0 @@ -//===--- X86Target.def - X86 Feature/Processor Database -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// -// -// This file defines the X86-specific Features and Processors, as used by -// the X86 Targets. -// -//===--===// - -#ifndef CPU_SPECIFIC -#define CPU_SPECIFIC(NAME, MANGLING, FEATURES) -#endif - -#ifndef CPU_SPECIFIC_ALIAS -#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME) -#endif - -// FIXME: When commented out features are supported in LLVM, enable them here. -CPU_SPECIFIC("generic", 'A', "") -CPU_SPECIFIC("pentium", 'B', "") -CPU_SPECIFIC("pentium_pro", 'C', "+cmov") -CPU_SPECIFIC("pentium_mmx", 'D', "+mmx") -CPU_SPECIFIC("pentium_ii", 'E', "+cmov,+mmx") -CPU_SPECIFIC("pentium_iii", 'H', "+cmov,+mmx,+sse") -CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium_iii") -CPU_SPECIFIC("pentium_4", 'J', "+cmov,+mmx,+sse,+sse2") -CPU_SPECIFIC("pentium_m", 'K', "+cmov,+mmx,+sse,+sse2") -CPU_SPECIFIC("pentium_4_sse3", 'L', "+cmov,+mmx,+sse,+sse2,+sse3") -CPU_SPECIFIC("core_2_duo_ssse3", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3") -CPU_SPECIFIC("core_2_duo_sse4_1", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1") -CPU_SPECIFIC("atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe") -CPU_SPECIFIC("atom_sse4_2", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt") -CPU_SPECIFIC("core_i7_sse4_2", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt") -CPU_SPECIFIC("core_aes_pclmulqdq", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt") -CPU_SPECIFIC("atom_sse4_2_movbe", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt") -CPU_SPECIFIC("goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt") -CPU_SPECIFIC("sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx") -CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge") -CPU_SPECIFIC("ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx") -CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge") -CPU_SPECIFIC("haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2") -CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell") -CPU_SPECIFIC("core_4th_gen_avx_tsx", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2") -CPU_SPECIFIC("broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx") -CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell") -CPU_SPECIFIC("core_5th_gen_avx_tsx", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx") -CPU_SPECIFIC("knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd") -CPU_SPECIFIC_ALIAS("mic_avx512", "knl") -CPU_SPECIFIC("skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx") -CPU_SPECIFIC( "skylake_avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb") -CPU_SPECIFIC("cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi") -CPU_SPECIFIC("knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")
[clang] f5c2889 - [NFC][clang] Use X86 Features declaration from X86TargetParser
Author: Andrei Elovikov Date: 2021-08-23T12:30:28-07:00 New Revision: f5c28894884488d236d66b766fe5da557cd1ac88 URL: https://github.com/llvm/llvm-project/commit/f5c28894884488d236d66b766fe5da557cd1ac88 DIFF: https://github.com/llvm/llvm-project/commit/f5c28894884488d236d66b766fe5da557cd1ac88.diff LOG: [NFC][clang] Use X86 Features declaration from X86TargetParser ...instead of redeclaring them in clang's own X86Target.def. They were already required to be in sync (IIUC), so no reason to maintain two identical lists. Reviewed By: erichkeane, craig.topper Differential Revision: https://reviews.llvm.org/D108151 Added: Modified: clang/include/clang/Basic/X86Target.def clang/lib/Basic/Targets/X86.cpp clang/lib/CodeGen/CGBuiltin.cpp llvm/include/llvm/Support/X86TargetParser.def Removed: diff --git a/clang/include/clang/Basic/X86Target.def b/clang/include/clang/Basic/X86Target.def index 70f3879f33a14..3a5d5b2183f2d 100644 --- a/clang/include/clang/Basic/X86Target.def +++ b/clang/include/clang/Basic/X86Target.def @@ -11,10 +11,6 @@ // //===--===// -#ifndef FEATURE -#define FEATURE(ENUM) -#endif - #ifndef CPU_SPECIFIC #define CPU_SPECIFIC(NAME, MANGLING, FEATURES) #endif @@ -23,50 +19,6 @@ #define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME) #endif -// List of CPU Supports features in order. These need to remain in the order -// required by attribute 'target' checking. Note that not all are supported/ -// prioritized by GCC, so synchronization with GCC's implementation may require -// changing some existing values. -FEATURE(FEATURE_CMOV) -FEATURE(FEATURE_MMX) -FEATURE(FEATURE_SSE) -FEATURE(FEATURE_SSE2) -FEATURE(FEATURE_SSE3) -FEATURE(FEATURE_SSSE3) -FEATURE(FEATURE_SSE4_A) -FEATURE(FEATURE_SSE4_1) -FEATURE(FEATURE_SSE4_2) -FEATURE(FEATURE_POPCNT) -FEATURE(FEATURE_AES) -FEATURE(FEATURE_PCLMUL) -FEATURE(FEATURE_AVX) -FEATURE(FEATURE_BMI) -FEATURE(FEATURE_FMA4) -FEATURE(FEATURE_XOP) -FEATURE(FEATURE_FMA) -FEATURE(FEATURE_BMI2) -FEATURE(FEATURE_AVX2) -FEATURE(FEATURE_AVX512F) -FEATURE(FEATURE_AVX512VL) -FEATURE(FEATURE_AVX512BW) -FEATURE(FEATURE_AVX512DQ) -FEATURE(FEATURE_AVX512CD) -FEATURE(FEATURE_AVX512ER) -FEATURE(FEATURE_AVX512PF) -FEATURE(FEATURE_AVX512VBMI) -FEATURE(FEATURE_AVX512IFMA) -FEATURE(FEATURE_AVX5124VNNIW) -FEATURE(FEATURE_AVX5124FMAPS) -FEATURE(FEATURE_AVX512VPOPCNTDQ) -FEATURE(FEATURE_AVX512VBMI2) -FEATURE(FEATURE_GFNI) -FEATURE(FEATURE_VPCLMULQDQ) -FEATURE(FEATURE_AVX512VNNI) -FEATURE(FEATURE_AVX512BITALG) -FEATURE(FEATURE_AVX512BF16) -FEATURE(FEATURE_AVX512VP2INTERSECT) - - // FIXME: When commented out features are supported in LLVM, enable them here. CPU_SPECIFIC("generic", 'A', "") CPU_SPECIFIC("pentium", 'B', "") @@ -105,6 +57,3 @@ CPU_SPECIFIC("knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+mo #undef CPU_SPECIFIC_ALIAS #undef CPU_SPECIFIC -#undef PROC_64_BIT -#undef PROC_32_BIT -#undef FEATURE diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 84bb7882621ec..c00e74a40 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/X86TargetParser.h" +#include namespace clang { namespace targets { @@ -1041,14 +1042,16 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const { // X86TargetInfo::hasFeature for a somewhat comprehensive list). bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const { return llvm::StringSwitch(FeatureStr) -#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, true) +#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) .Case(STR, true) #include "llvm/Support/X86TargetParser.def" .Default(false); } static llvm::X86::ProcessorFeatures getFeature(StringRef Name) { return llvm::StringSwitch(Name) -#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, llvm::X86::FEATURE_##ENUM) +#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) \ + .Case(STR, llvm::X86::FEATURE_##ENUM) + #include "llvm/Support/X86TargetParser.def" ; // Note, this function should only be used after ensuring the value is @@ -1056,15 +1059,28 @@ static llvm::X86::ProcessorFeatures getFeature(StringRef Name) { } static unsigned getFeaturePriority(llvm::X86::ProcessorFeatures Feat) { - enum class FeatPriority { -#define FEATURE(FEAT) FEAT, -#include "clang/Basic/X86Target.def" +#ifndef NDEBUG + // Check that priorities are set properly in the .def file. We expect that + // "compat" features are assigned non-duplicate consecutive priorities + // starting from zero (0, 1, ..., num_features - 1). +#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) PRIORITY, + unsigned Priorities[] = { +#include "llvm/Support/X86TargetParser.def" +
r340174 - [NFC] Don't define static function in header (UninitializedObject.h)
Author: a.elovikov Date: Mon Aug 20 06:45:38 2018 New Revision: 340174 URL: http://llvm.org/viewvc/llvm-project?rev=340174=rev Log: [NFC] Don't define static function in header (UninitializedObject.h) Summary: See also http://lists.llvm.org/pipermail/cfe-users/2016-January/000854.html for the reasons why it's bad. Reviewers: Szelethus, erichkeane Reviewed By: Szelethus Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50963 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=340174=340173=340174=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Mon Aug 20 06:45:38 2018 @@ -233,7 +233,7 @@ private: /// value is undefined or not, such as ints and doubles, can be analyzed with /// ease. This also helps ensuring that every special field type is handled /// correctly. -static bool isPrimitiveType(const QualType ) { +inline bool isPrimitiveType(const QualType ) { return T->isBuiltinType() || T->isEnumeralType() || T->isMemberPointerType(); } Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp?rev=340174=340173=340174=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp Mon Aug 20 06:45:38 2018 @@ -215,12 +215,10 @@ bool FindUninitializedFields::isPointerO llvm_unreachable("All cases are handled!"); } - // Temporary variable to avoid warning from -Wunused-function. - bool IsPrimitive = isPrimitiveType(DynT->getPointeeType()); - assert((IsPrimitive || DynT->isAnyPointerType() || DynT->isReferenceType()) && + assert((isPrimitiveType(DynT->getPointeeType()) || DynT->isAnyPointerType() || + DynT->isReferenceType()) && "At this point FR must either have a primitive dynamic type, or it " "must be a null, undefined, unknown or concrete pointer!"); - (void)IsPrimitive; if (isPrimitiveUninit(DerefdV)) { if (NeedsCastBack) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338551 - [NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle-llvm/handle_llvm.cpp.
Author: a.elovikov Date: Wed Aug 1 06:34:18 2018 New Revision: 338551 URL: http://llvm.org/viewvc/llvm-project?rev=338551=rev Log: [NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle-llvm/handle_llvm.cpp. Summary: I don't have the whole list of GCC binaries available so I determined the exact version where the warning disappeared via: https://github.com/gcc-mirror/gcc/blob/gcc-4_9_0-release/gcc/cp/typeck.c#L6863 https://github.com/gcc-mirror/gcc/blob/gcc-4_8_5-release/gcc/cp/typeck.c#L6652 Reviewers: emmettneyman, erichkeane Reviewed By: emmettneyman, erichkeane Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50056 Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp?rev=338551=338550=338551=diff == --- cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp (original) +++ cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp Wed Aug 1 06:34:18 2018 @@ -149,7 +149,23 @@ void CreateAndRunJITFun(const std::strin EE->runStaticConstructorsDestructors(false); typedef void (*func)(int*, int*, int*, int); - func f = reinterpret_cast(EE->getPointerToFunction(EntryFunc)); +#if defined(__GNUC__) && !defined(__clang) && \ +((__GNUC__ == 4) && (__GNUC_MINOR__ < 9)) +// Silence +// +// warning: ISO C++ forbids casting between pointer-to-function and +// pointer-to-object [-Wpedantic] +// +// Since C++11 this casting is conditionally supported and GCC versions +// starting from 4.9.0 don't warn about the cast. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + func f = reinterpret_cast(EE->getPointerToFunction(EntryFunc)); +#if defined(__GNUC__) && !defined(__clang) && \ +((__GNUC__ == 4) && (__GNUC_MINOR__ < 9)) +#pragma GCC diagnostic pop +#endif // Define some dummy arrays to use an input for now int a[] = {1}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits