To not treat macro invocation locations as part of the include stack
when reporting a diagnostic.
llvm-svn: 38577
diff --git a/clang/Basic/SourceManager.cpp b/clang/Basic/SourceManager.cpp
index 7a6542e..e1357f3 100644
--- a/clang/Basic/SourceManager.cpp
+++ b/clang/Basic/SourceManager.cpp
@@ -129,6 +129,18 @@
return 0;
}
+/// getIncludeLoc - Return the location of the #include for the specified
+/// FileID.
+SourceLocation SourceManager::getIncludeLoc(unsigned FileID) const {
+ const SrcMgr::FileIDInfo *FIDInfo = getFIDInfo(FileID);
+
+ // For Macros, the physical loc is specified by the MacroTokenFileID.
+ if (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion)
+ FIDInfo = &FileIDs[FIDInfo->u.MacroTokenFileID-1];
+
+ return FIDInfo->IncludeLoc;
+}
+
/// getColumnNumber - Return the column # for the specified include position.
/// this is significantly cheaper to compute than the line number. This returns