[llvm-branch-commits] [clang] 0b644cb - [Frontend] Restore Preprocessor::getPredefines()

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Sep 1 02:01:09 PDT 2022


Author: Roy Jacobson
Date: 2022-09-01T11:00:15+02:00
New Revision: 0b644cb1cc35dc29420b36c6715518d7430c6538

URL: https://github.com/llvm/llvm-project/commit/0b644cb1cc35dc29420b36c6715518d7430c6538
DIFF: https://github.com/llvm/llvm-project/commit/0b644cb1cc35dc29420b36c6715518d7430c6538.diff

LOG: [Frontend] Restore Preprocessor::getPredefines()

https://reviews.llvm.org/rG6bbf51f3ed59ae37f0fec729f25af002111c9e74 from May removed Preprocessor::getPredefines() from Clang's API, presumably as a cleanup because this method is unused in the LLVM codebase.

However, it was/is used by a small number of third-party tools and is pretty harmless, so this patch adds it back and documents why it's here.

The issue was raised in https://github.com/llvm/llvm-project/issues/57483, it would be nice to be able to land it into Clang 15 as it breaks those third-party tools and we can't easily add it back in bug fix releases.

Reviewed By: brad.king, thieta

Differential Revision: https://reviews.llvm.org/D133044

(cherry picked from commit bb9dedce5d01f5608acd784942481f386c710c0d)

Added: 
    

Modified: 
    clang/include/clang/Lex/Preprocessor.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 79454b5addea..bed486658ee0 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1353,6 +1353,11 @@ class Preprocessor {
   StringRef getLastMacroWithSpelling(SourceLocation Loc,
                                      ArrayRef<TokenValue> Tokens) const;
 
+  /// Get the predefines for this processor.
+  /// Used by some third-party tools to inspect and add predefines (see
+  /// https://github.com/llvm/llvm-project/issues/57483).
+  const std::string &getPredefines() const { return Predefines; }
+
   /// Set the predefines for this Preprocessor.
   ///
   /// These predefines are automatically injected when parsing the main file.


        


More information about the llvm-branch-commits mailing list