From 0e26e50d38d48f6ea9a01837b60449ba333f4a55 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Aug 14 2019 21:43:42 +0000 Subject: Pull spec file from clang package --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..526f1ad --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/cfe-8.0.0.src.tar.xz diff --git a/0001-Fix-isInSystemMacro-to-handle-pasted-macros.patch b/0001-Fix-isInSystemMacro-to-handle-pasted-macros.patch new file mode 100644 index 0000000..9480f42 --- /dev/null +++ b/0001-Fix-isInSystemMacro-to-handle-pasted-macros.patch @@ -0,0 +1,137 @@ +From cb7fd3caeee52fe94461b717294c4db4056853e3 Mon Sep 17 00:00:00 2001 +From: Serge Guelton +Date: Fri, 1 Feb 2019 06:11:44 +0000 +Subject: [PATCH 1/3] Fix isInSystemMacro to handle pasted macros + +Token pasted by the preprocessor (through ##) have a Spelling pointing to scratch buffer. +As a result they are not recognized at system macro, even though the pasting happened in +a system macro. Fix that by looking into the parent macro if the original lookup finds a +scratch buffer. + +Differential Revision: https://reviews.llvm.org/D55782 + +This effectively fixes https://bugs.llvm.org/show_bug.cgi?id=35268, + +git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352838 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + include/clang/Basic/SourceManager.h | 18 +++++++++++++++++- + test/Misc/no-warn-in-system-macro.c | 13 +++++++++++++ + test/Misc/no-warn-in-system-macro.c.inc | 9 +++++++++ + test/Misc/warn-in-system-macro-def.c | 21 +++++++++++++++++++++ + test/Misc/warn-in-system-macro-def.c.inc | 4 ++++ + 5 files changed, 64 insertions(+), 1 deletion(-) + create mode 100644 test/Misc/no-warn-in-system-macro.c + create mode 100644 test/Misc/no-warn-in-system-macro.c.inc + create mode 100644 test/Misc/warn-in-system-macro-def.c + create mode 100644 test/Misc/warn-in-system-macro-def.c.inc + +diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h +index dcc4a37e23..c6b92f9000 100644 +--- a/include/clang/Basic/SourceManager.h ++++ b/include/clang/Basic/SourceManager.h +@@ -1441,6 +1441,12 @@ public: + return Filename.equals(""); + } + ++ /// Returns whether \p Loc is located in a file. ++ bool isWrittenInScratchSpace(SourceLocation Loc) const { ++ StringRef Filename(getPresumedLoc(Loc).getFilename()); ++ return Filename.equals(""); ++ } ++ + /// Returns if a SourceLocation is in a system header. + bool isInSystemHeader(SourceLocation Loc) const { + return isSystem(getFileCharacteristic(Loc)); +@@ -1453,7 +1459,17 @@ public: + + /// Returns whether \p Loc is expanded from a macro in a system header. + bool isInSystemMacro(SourceLocation loc) const { +- return loc.isMacroID() && isInSystemHeader(getSpellingLoc(loc)); ++ if(!loc.isMacroID()) ++ return false; ++ ++ // This happens when the macro is the result of a paste, in that case ++ // its spelling is the scratch memory, so we take the parent context. ++ if (isWrittenInScratchSpace(getSpellingLoc(loc))) { ++ return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc))); ++ } ++ else { ++ return isInSystemHeader(getSpellingLoc(loc)); ++ } + } + + /// The size of the SLocEntry that \p FID represents. +diff --git a/test/Misc/no-warn-in-system-macro.c b/test/Misc/no-warn-in-system-macro.c +new file mode 100644 +index 0000000000..a319b14c9c +--- /dev/null ++++ b/test/Misc/no-warn-in-system-macro.c +@@ -0,0 +1,13 @@ ++// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s 2>&1 | FileCheck -allow-empty %s ++// CHECK-NOT: warning: ++ ++#include ++ ++int main(void) ++{ ++ double foo = 1.0; ++ ++ if (isnan(foo)) ++ return 1; ++ return 0; ++} +diff --git a/test/Misc/no-warn-in-system-macro.c.inc b/test/Misc/no-warn-in-system-macro.c.inc +new file mode 100644 +index 0000000000..3cbe7dfc16 +--- /dev/null ++++ b/test/Misc/no-warn-in-system-macro.c.inc +@@ -0,0 +1,9 @@ ++extern int __isnanf(float f); ++extern int __isnan(double f); ++extern int __isnanl(long double f); ++#define isnan(x) \ ++ (sizeof (x) == sizeof (float) \ ++ ? __isnanf (x) \ ++ : sizeof (x) == sizeof (double) \ ++ ? __isnan (x) : __isnanl (x)) ++ +diff --git a/test/Misc/warn-in-system-macro-def.c b/test/Misc/warn-in-system-macro-def.c +new file mode 100644 +index 0000000000..b295130702 +--- /dev/null ++++ b/test/Misc/warn-in-system-macro-def.c +@@ -0,0 +1,21 @@ ++// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s 2>&1 | FileCheck -allow-empty %s ++// CHECK: warning: ++// CHECK: expanded from macro 'ISNAN' ++// CHECK: expanded from macro 'isnan' ++ ++#include ++ ++#define isnan(x) \ ++ (sizeof (x) == sizeof (float) \ ++ ? __isnanf (x) \ ++ : sizeof (x) == sizeof (double) \ ++ ? __isnan (x) : __isnanl (x)) ++ ++int main(void) ++{ ++ double foo = 1.0; ++ ++ if (ISNAN(foo)) ++ return 1; ++ return 0; ++} +diff --git a/test/Misc/warn-in-system-macro-def.c.inc b/test/Misc/warn-in-system-macro-def.c.inc +new file mode 100644 +index 0000000000..5c7e60275a +--- /dev/null ++++ b/test/Misc/warn-in-system-macro-def.c.inc +@@ -0,0 +1,4 @@ ++extern int __isnanf(float f); ++extern int __isnan(double f); ++extern int __isnanl(long double f); ++#define ISNAN isnan +-- +2.20.1 + diff --git a/0001-Fix-uninitialized-value-in-ABIArgInfo.patch b/0001-Fix-uninitialized-value-in-ABIArgInfo.patch new file mode 100644 index 0000000..9755200 --- /dev/null +++ b/0001-Fix-uninitialized-value-in-ABIArgInfo.patch @@ -0,0 +1,38 @@ +From 565b9633ee68b311c1a954022869d9e99fee7286 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Fri, 1 Feb 2019 06:39:13 +0000 +Subject: [PATCH] Fix uninitialized value in ABIArgInfo + +GCC-9 takes advantage of this uninitialized values to optimize stuff, +which ends up in failing validation when compiling clang. +--- + include/clang/CodeGen/CGFunctionInfo.h | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/include/clang/CodeGen/CGFunctionInfo.h b/include/clang/CodeGen/CGFunctionInfo.h +index cf64e9f3ee..131eb38393 100644 +--- a/include/clang/CodeGen/CGFunctionInfo.h ++++ b/include/clang/CodeGen/CGFunctionInfo.h +@@ -112,14 +112,13 @@ private: + } + + ABIArgInfo(Kind K) +- : TheKind(K), PaddingInReg(false), InReg(false), SuppressSRet(false) { +- } ++ : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), ++ TheKind(K), PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false), ++ IndirectRealign(false), SRetAfterThis(false), InReg(false), ++ CanBeFlattened(false), SignExt(false), SuppressSRet(false) {} + + public: +- ABIArgInfo() +- : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), +- TheKind(Direct), PaddingInReg(false), InReg(false), +- SuppressSRet(false) {} ++ ABIArgInfo() : ABIArgInfo(Direct) {} + + static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0, + llvm::Type *Padding = nullptr, +-- +2.19.2 + diff --git a/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch b/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch new file mode 100644 index 0000000..f4f0fa3 --- /dev/null +++ b/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch @@ -0,0 +1,50 @@ +From 09ae3ef5710a89505318ec721c65b6c838147276 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Thu, 7 Feb 2019 21:05:37 -0800 +Subject: [PATCH] ToolChain: Add -lgcc_s to the linker flags when using libc++ + +The libc++ build for Fedora does not include an implementation of +libunwind, so we need to explicitly link against something that +provides this implementation. +--- + clang/lib/Driver/ToolChain.cpp | 1 + + clang/test/Driver/netbsd.cpp | 4 ++-- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp +index 88a627e..cb99844 100644 +--- a/lib/Driver/ToolChain.cpp ++++ b/lib/Driver/ToolChain.cpp +@@ -767,6 +767,7 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, + switch (Type) { + case ToolChain::CST_Libcxx: + CmdArgs.push_back("-lc++"); ++ CmdArgs.push_back("-lgcc_s"); + break; + + case ToolChain::CST_Libstdcxx: +diff --git a/test/Driver/netbsd.cpp b/test/Driver/netbsd.cpp +index 4af7d83..ff18c62 100644 +--- a/test/Driver/netbsd.cpp ++++ b/test/Driver/netbsd.cpp +@@ -131,7 +131,7 @@ + // ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" + // ARM-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" + // ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o" +-// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc" ++// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc" + // ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o" + + // AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd" +@@ -250,7 +250,7 @@ + // S-ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" + // S-ARM-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic" + // S-ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o" +-// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc" ++// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc" + // S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o" + + // S-AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd" +-- +1.8.3.1 + diff --git a/0002-Format-isInSystemMacro-after-D55782.patch b/0002-Format-isInSystemMacro-after-D55782.patch new file mode 100644 index 0000000..e5004fb --- /dev/null +++ b/0002-Format-isInSystemMacro-after-D55782.patch @@ -0,0 +1,39 @@ +From 49b29ff9feafd8b9041e2a76cbe843115d263ced Mon Sep 17 00:00:00 2001 +From: Fangrui Song +Date: Mon, 11 Feb 2019 13:30:04 +0000 +Subject: [PATCH 2/3] Format isInSystemMacro after D55782 + +git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353697 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + include/clang/Basic/SourceManager.h | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h +index c6b92f9000..f44239d9ce 100644 +--- a/include/clang/Basic/SourceManager.h ++++ b/include/clang/Basic/SourceManager.h +@@ -1459,17 +1459,15 @@ public: + + /// Returns whether \p Loc is expanded from a macro in a system header. + bool isInSystemMacro(SourceLocation loc) const { +- if(!loc.isMacroID()) ++ if (!loc.isMacroID()) + return false; + + // This happens when the macro is the result of a paste, in that case + // its spelling is the scratch memory, so we take the parent context. +- if (isWrittenInScratchSpace(getSpellingLoc(loc))) { ++ if (isWrittenInScratchSpace(getSpellingLoc(loc))) + return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc))); +- } +- else { +- return isInSystemHeader(getSpellingLoc(loc)); +- } ++ ++ return isInSystemHeader(getSpellingLoc(loc)); + } + + /// The size of the SLocEntry that \p FID represents. +-- +2.20.1 + diff --git a/0002-gtest-reorg.patch b/0002-gtest-reorg.patch new file mode 100644 index 0000000..121ac46 --- /dev/null +++ b/0002-gtest-reorg.patch @@ -0,0 +1,42 @@ +From 1f26a0284925859b72ee520ce74452d77d822409 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Mon, 28 Jan 2019 19:12:27 +0000 +Subject: [PATCH 2/2] [PATCH] gtest reorg + +--- + CMakeLists.txt | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c2016a45ca..48ea3c3bb9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -157,12 +157,6 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") + set(LLVM_UTILS_PROVIDED ON) + set(CLANG_TEST_DEPS FileCheck count not) + endif() +- set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) +- if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h +- AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} +- AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) +- add_subdirectory(${UNITTEST_DIR} utils/unittest) +- endif() + else() + # Seek installed Lit. + find_program(LLVM_LIT +@@ -507,7 +501,11 @@ endif() + + + if( CLANG_INCLUDE_TESTS ) +- if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) ++ set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) ++ if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h ++ AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} ++ AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) ++ add_subdirectory(${UNITTEST_DIR} utils/unittest) + add_subdirectory(unittests) + list(APPEND CLANG_TEST_DEPS ClangUnitTests) + list(APPEND CLANG_TEST_PARAMS +-- +2.19.2 + diff --git a/0003-Fix-isInSystemMacro-in-presence-of-macro-and-pasted-.patch b/0003-Fix-isInSystemMacro-in-presence-of-macro-and-pasted-.patch new file mode 100644 index 0000000..c27dfd9 --- /dev/null +++ b/0003-Fix-isInSystemMacro-in-presence-of-macro-and-pasted-.patch @@ -0,0 +1,63 @@ +From a6b7f0946df82ca207b27f1931d4b430ab77e5e0 Mon Sep 17 00:00:00 2001 +From: Serge Guelton +Date: Thu, 16 May 2019 12:40:00 +0000 +Subject: [PATCH 3/3] Fix isInSystemMacro in presence of macro and pasted token + +When a warning is raised from the expansion of a system macro that +involves pasted token, there was still situations were they were not +skipped, as showcased by this issue: +https://bugzilla.redhat.com/show_bug.cgi?id=1472437 + +Differential Revision: https://reviews.llvm.org/D59413 + +git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360885 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + include/clang/Basic/SourceManager.h | 9 +++++++-- + test/Misc/no-warn-in-system-macro.c | 7 ++++++- + 2 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h +index f44239d9ce..c964c64faf 100644 +--- a/include/clang/Basic/SourceManager.h ++++ b/include/clang/Basic/SourceManager.h +@@ -1464,8 +1464,13 @@ public: + + // This happens when the macro is the result of a paste, in that case + // its spelling is the scratch memory, so we take the parent context. +- if (isWrittenInScratchSpace(getSpellingLoc(loc))) +- return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc))); ++ // There can be several level of token pasting. ++ if (isWrittenInScratchSpace(getSpellingLoc(loc))) { ++ do { ++ loc = getImmediateMacroCallerLoc(loc); ++ } while (isWrittenInScratchSpace(getSpellingLoc(loc))); ++ return isInSystemMacro(loc); ++ } + + return isInSystemHeader(getSpellingLoc(loc)); + } +diff --git a/test/Misc/no-warn-in-system-macro.c b/test/Misc/no-warn-in-system-macro.c +index a319b14c9c..a351b89256 100644 +--- a/test/Misc/no-warn-in-system-macro.c ++++ b/test/Misc/no-warn-in-system-macro.c +@@ -3,11 +3,16 @@ + + #include + ++#define MACRO(x) x ++ + int main(void) + { + double foo = 1.0; + + if (isnan(foo)) + return 1; +- return 0; ++ ++ MACRO(isnan(foo)); ++ ++ return 0; + } +-- +2.20.1 + diff --git a/sources b/sources new file mode 100644 index 0000000..3af1223 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (cfe-8.0.0.src.tar.xz) = 98e540222719716985e5d8439116e47469cb01201ea91d1da7e46cb6633da099688d9352c3b65e5c5f660cbbae353b3d79bb803fc66b3be663f2b04b1feed1c3