From e81e4c384979d4c93da7718b7ec39510b878657c Mon Sep 17 00:00:00 2001 From: Mattias Ellert Date: Sep 01 2023 12:27:22 +0000 Subject: Backport support for LLVM 17 from upstream --- diff --git a/0001-Port-to-LLVM-Clang-Git-release-17.x-as-of-2023-08-15.patch b/0001-Port-to-LLVM-Clang-Git-release-17.x-as-of-2023-08-15.patch new file mode 100644 index 0000000..f41d6b9 --- /dev/null +++ b/0001-Port-to-LLVM-Clang-Git-release-17.x-as-of-2023-08-15.patch @@ -0,0 +1,69 @@ +From 2368262d83fcafbf08d52179d99de0191d49c42c Mon Sep 17 00:00:00 2001 +From: Brad King +Date: Wed, 16 Aug 2023 12:41:00 -0400 +Subject: [PATCH] Port to LLVM/Clang Git release/17.x as of 2023-08-15 + (2f0fb9346d0) + +Since commit 825cca7d (RunClang: Delay class implicit members until end +of parsing, 2014-12-08, v0.2.0~211) we `enableIncrementalProcessing()` +to defer parser tear down. + +Since LLVM/Clang commit `247fa04116a6` ([clang] Add a new annotation +token: annot_repl_input_end, 2023-05-16), incremental processing causes +preprocessing to get stuck at the end of a file because it never gets an +`eof` token. See `clang/lib/Frontend/PrintPreprocessedOutput.cpp` in +`DoPrintPreprocessedInput` and `DoPrintMacros`. + +Fortunately we do not need incremental processing in preprocessing +modes. +--- + src/RunClang.cxx | 26 ++++++++++++++++++++++---- + 1 file changed, 22 insertions(+), 4 deletions(-) + +diff --git a/src/RunClang.cxx b/src/RunClang.cxx +index fb09ada..01d60fe 100644 +--- a/src/RunClang.cxx ++++ b/src/RunClang.cxx +@@ -476,10 +476,6 @@ protected: + ) override + { + CI.getPreprocessor().setPredefines(this->UpdatePredefines(CI)); +- +- // Tell Clang not to tear down the parser at EOF. +- CI.getPreprocessor().enableIncrementalProcessing(); +- + return true; + } + }; +@@ -517,6 +513,28 @@ class CastXMLSyntaxOnlyAction + } + } + ++protected: ++ bool BeginSourceFileAction(clang::CompilerInstance& CI ++#if LLVM_VERSION_MAJOR < 5 ++ , ++ llvm::StringRef Filename ++#endif ++ ) override ++ { ++ this->CastXMLPredefines::BeginSourceFileAction(CI ++#if LLVM_VERSION_MAJOR < 5 ++ , ++ Filename ++#endif ++ ); ++ ++ // Tell Clang not to tear down the parser at EOF. ++ // We need it in ASTConsumer::HandleTranslationUnit. ++ CI.getPreprocessor().enableIncrementalProcessing(); ++ ++ return true; ++ } ++ + public: + CastXMLSyntaxOnlyAction(Options const& opts) + : CastXMLPredefines(opts) +-- +2.41.0 + diff --git a/castxml.spec b/castxml.spec index 88c50a1..03137e5 100644 --- a/castxml.spec +++ b/castxml.spec @@ -2,12 +2,13 @@ Name: castxml Version: 0.6.1 -Release: 3%{?dist} +Release: 4%{?dist} Summary: C-family abstract syntax tree XML output tool License: Apache-2.0 URL: https://github.com/CastXML/CastXML Source0: https://github.com/CastXML/CastXML/archive/v%{version}/%{name}-%{version}.tar.gz +Patch0: 0001-Port-to-LLVM-Clang-Git-release-17.x-as-of-2023-08-15.patch BuildRequires: cmake BuildRequires: make @@ -30,6 +31,7 @@ may support alternative output formats. %prep %setup -q -n CastXML-%{version} +%patch -P 0 -p1 %build %cmake -DCastXML_INSTALL_DOC_DIR:STRING=share/doc/%{name} \ @@ -61,6 +63,9 @@ rm %{buildroot}%{_pkgdocdir}/NOTICE %license LICENSE NOTICE %changelog +* Fri Sep 01 2023 Mattias Ellert - 0.6.1-4 +- Backport support for LLVM 17 from upstream + * Wed Jul 19 2023 Fedora Release Engineering - 0.6.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild