[llvm] [MC][Support] Track macro definition locations for improved diagnostics (PR #198936)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 13 12:47:24 PDT 2026


================
@@ -158,6 +162,23 @@ class SourceMgr {
     return Buffers[i - 1].IncludeLoc;
   }
 
+  unsigned getMacroParentBuf(unsigned i) const {
+    if (SMLoc Loc = getMacroDefLoc(i); Loc.isValid())
+      return FindBufferContainingLoc(getParentIncludeLoc(i));
+    return 0;
+  }
+
+  SMLoc getMacroDefLoc(unsigned i) const {
+    assert(isValidBufferID(i));
+    return Buffers[i - 1].MacroDefLoc;
+  }
+
+  unsigned getMacroDefBuf(unsigned i) const {
----------------
MaskRay wrote:

Dead?

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


More information about the llvm-commits mailing list