[clang] [clang][NFC] Remove unused MacroDirective PCH origin tracking (PR #240171)
Chen Miao via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 8 10:26:58 PST 2026
https://github.com/ChenMiaoi created https://github.com/llvm/llvm-project/pull/240171
`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.
>From 9f843e0b4c501c81237e1fbb0474f9d61483e099 Mon Sep 17 00:00:00 2001
From: Chen Miao <chenmiao.ku at gmail.com>
Date: Mon, 9 Nov 2026 02:22:45 +0800
Subject: [PATCH] [clang][NFC] Remove unused MacroDirective PCH origin tracking
`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.
---
clang/include/clang/Lex/MacroInfo.h | 11 +----------
clang/lib/Lex/MacroInfo.cpp | 1 -
2 files changed, 1 insertion(+), 11 deletions(-)
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");
More information about the cfe-commits
mailing list