[PATCH] D133044: [Frontend] Restore Preprocessor::getPredefines()

Roy Jacobson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 31 12:34:00 PDT 2022


royjacobson created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A patch from May removed Preprocessor::getPredefines() from Clang's API, probably as a cleanup because
this method was 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133044

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


Index: clang/include/clang/Lex/Preprocessor.h
===================================================================
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -1375,6 +1375,10 @@
   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.
+  const std::string &getPredefines() const { return Predefines; }
+
   /// Set the predefines for this Preprocessor.
   ///
   /// These predefines are automatically injected when parsing the main file.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133044.457060.patch
Type: text/x-patch
Size: 676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220831/790f5f30/attachment.bin>


More information about the cfe-commits mailing list