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

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 13 13:26:10 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 {
----------------
arichardson wrote:

Was used in a follow up change and I folded it into the wrong commit. Sorry

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


More information about the llvm-commits mailing list