[cfe-commits] r38590 - /cfe/cfe/trunk/Basic/SourceManager.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:23:00 PDT 2007
Author: sabre
Date: Wed Jul 11 11:23:00 2007
New Revision: 38590
URL: http://llvm.org/viewvc/llvm-project?rev=38590&view=rev
Log:
Due to generated tokens expanded by macros, there can be multiple MacroExpansion fileid's, loop over them until we get to something real.
Modified:
cfe/cfe/trunk/Basic/SourceManager.cpp
Modified: cfe/cfe/trunk/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Basic/SourceManager.cpp?rev=38590&r1=38589&r2=38590&view=diff
==============================================================================
--- cfe/cfe/trunk/Basic/SourceManager.cpp (original)
+++ cfe/cfe/trunk/Basic/SourceManager.cpp Wed Jul 11 11:23:00 2007
@@ -135,7 +135,7 @@
const SrcMgr::FileIDInfo *FIDInfo = getFIDInfo(FileID);
// For Macros, the physical loc is specified by the MacroTokenFileID.
- if (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion)
+ while (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion)
FIDInfo = &FileIDs[FIDInfo->u.MacroTokenFileID-1];
return FIDInfo->IncludeLoc;
@@ -151,9 +151,10 @@
// If this is a macro, we need to get the instantiation location.
const SrcMgr::FileIDInfo *FIDInfo = getFIDInfo(FileID);
- if (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion) {
+ while (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion) {
Loc = FIDInfo->IncludeLoc;
FileID = Loc.getFileID();
+ FIDInfo = getFIDInfo(FileID);
}
unsigned FilePos = getFilePos(Loc);
@@ -175,7 +176,7 @@
// If this is a macro, we need to get the instantiation location.
const SrcMgr::FileIDInfo *FIDInfo = getFIDInfo(FileID);
- if (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion) {
+ while (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion) {
Loc = FIDInfo->IncludeLoc;
FIDInfo = getFIDInfo(Loc.getFileID());
}
@@ -192,7 +193,7 @@
unsigned FileID = Loc.getFileID();
// If this is a macro, we need to get the instantiation location.
const SrcMgr::FileIDInfo *FIDInfo = getFIDInfo(FileID);
- if (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion) {
+ while (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion) {
Loc = FIDInfo->IncludeLoc;
FileID = Loc.getFileID();
FIDInfo = getFIDInfo(FileID);
@@ -270,8 +271,10 @@
// If this is a macro, we need to get the instantiation location.
const SrcMgr::FileIDInfo *FIDInfo = getFIDInfo(Loc.getFileID());
- if (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion)
- return getFilePos(FIDInfo->IncludeLoc);
+ while (FIDInfo->IDType == SrcMgr::FileIDInfo::MacroExpansion) {
+ Loc = FIDInfo->IncludeLoc;
+ FIDInfo = getFIDInfo(Loc.getFileID());
+ }
return getFilePos(Loc);
}
More information about the cfe-commits
mailing list