[clang] [clang][NFC] Remove unused MacroDirective PCH origin tracking (PR #240171)

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 8 10:27:32 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Chen Miao (ChenMiaoi)

<details>
<summary>Changes</summary>

`MacroDirective::IsFromPCH` is never set, and its accessors have no callers. Macro history serialization instead uses the identifier's deserialization and change state.

Remove the unused flag, accessors, and corresponding `dump()` output.

---
Full diff: https://github.com/llvm/llvm-project/pull/240171.diff


2 Files Affected:

- (modified) clang/include/clang/Lex/MacroInfo.h (+1-10) 
- (modified) clang/lib/Lex/MacroInfo.cpp (-1) 


``````````diff
diff --git a/clang/include/clang/Lex/MacroInfo.h b/clang/include/clang/Lex/MacroInfo.h
index e5dbc7f92a9ac1..53888e3d960e5c 100644
--- a/clang/include/clang/Lex/MacroInfo.h
+++ b/clang/include/clang/Lex/MacroInfo.h
@@ -329,10 +329,6 @@ class MacroDirective {
   LLVM_PREFERRED_TYPE(Kind)
   unsigned MDKind : 2;
 
-  /// True if the macro directive was loaded from a PCH file.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned IsFromPCH : 1;
-
   // Used by VisibilityMacroDirective ----------------------------------------//
 
   /// Whether the macro has public visibility (when described in a
@@ -341,7 +337,7 @@ class MacroDirective {
   unsigned IsPublic : 1;
 
   MacroDirective(Kind K, SourceLocation Loc)
-      : Loc(Loc), MDKind(K), IsFromPCH(false), IsPublic(true) {}
+      : Loc(Loc), MDKind(K), IsPublic(true) {}
 
 public:
   Kind getKind() const { return Kind(MDKind); }
@@ -357,11 +353,6 @@ class MacroDirective {
   /// Get previous definition of the macro with the same name.
   MacroDirective *getPrevious() { return Previous; }
 
-  /// Return true if the macro directive was loaded from a PCH file.
-  bool isFromPCH() const { return IsFromPCH; }
-
-  void setIsFromPCH() { IsFromPCH = true; }
-
   class DefInfo {
     DefMacroDirective *DefDirective = nullptr;
     SourceLocation UndefLoc;
diff --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp
index 8b296d5b22748b..471f911cddd12e 100644
--- a/clang/lib/Lex/MacroInfo.cpp
+++ b/clang/lib/Lex/MacroInfo.cpp
@@ -237,7 +237,6 @@ LLVM_DUMP_METHOD void MacroDirective::dump() const {
   // FIXME: Dump SourceLocation.
   if (auto *Prev = getPrevious())
     Out << " prev " << Prev;
-  if (IsFromPCH) Out << " from_pch";
 
   if (isa<VisibilityMacroDirective>(this))
     Out << (IsPublic ? " public" : " private");

``````````

</details>


https://github.com/llvm/llvm-project/pull/240171


More information about the cfe-commits mailing list