Index: lib/Basic/SourceManager.cpp =================================================================== --- lib/Basic/SourceManager.cpp +++ lib/Basic/SourceManager.cpp @@ -1003,7 +1003,9 @@ if (!Loc.isMacroID()) return false; FileID FID = getFileID(Loc); - const SrcMgr::ExpansionInfo &Expansion = getSLocEntry(FID).getExpansion(); + const SrcMgr::SLocEntry &Entry = getSLocEntry(FID); + if (!Entry.isExpansion()) return false; + const SrcMgr::ExpansionInfo &Expansion = Entry.getExpansion(); if (!Expansion.isMacroArgExpansion()) return false; if (StartLoc) @@ -1015,7 +1017,9 @@ if (!Loc.isMacroID()) return false; FileID FID = getFileID(Loc); - const SrcMgr::ExpansionInfo &Expansion = getSLocEntry(FID).getExpansion(); + const SrcMgr::SLocEntry &Entry = getSLocEntry(FID); + if (!Entry.isExpansion()) return false; + const SrcMgr::ExpansionInfo &Expansion = Entry.getExpansion(); return Expansion.isMacroBodyExpansion(); } @@ -1028,10 +1032,10 @@ return false; // Does not point at the start of expansion range. bool Invalid = false; - const SrcMgr::ExpansionInfo &ExpInfo = - getSLocEntry(DecompLoc.first, &Invalid).getExpansion(); - if (Invalid) + const SrcMgr::SLocEntry &Entry = getSLocEntry(DecompLoc.first, &Invalid); + if (Invalid || !Entry.isExpansion()) return false; + const SrcMgr::ExpansionInfo &ExpInfo = Entry.getExpansion(); SourceLocation ExpLoc = ExpInfo.getExpansionLocStart(); if (ExpInfo.isMacroArgExpansion()) { @@ -1064,10 +1068,10 @@ return false; // Does not point at the end of expansion range. bool Invalid = false; - const SrcMgr::ExpansionInfo &ExpInfo = - getSLocEntry(FID, &Invalid).getExpansion(); - if (Invalid) + const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid); + if (Invalid || !Entry.isExpansion()) return false; + const SrcMgr::ExpansionInfo &ExpInfo = Entry.getExpansion(); if (ExpInfo.isMacroArgExpansion()) { // For macro argument expansions, check if the next FileID is part of the