parent
b5f8171a1b
commit
4bb15ab853
|
@ -280,7 +280,10 @@ SourceLocation
|
|||
getLocForEndOfDecl(const clang::Decl *D,
|
||||
const LangOptions &LangOpts = clang::LangOptions()) {
|
||||
const auto &SM = D->getASTContext().getSourceManager();
|
||||
auto EndExpansionLoc = SM.getExpansionRange(D->getLocEnd()).second;
|
||||
// If the expansion range is a character range, this is the location of
|
||||
// the first character past the end. Otherwise it's the location of the
|
||||
// first character in the final token in the range.
|
||||
auto EndExpansionLoc = SM.getExpansionRange(D->getLocEnd()).getEnd();
|
||||
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(EndExpansionLoc);
|
||||
// Try to load the file buffer.
|
||||
bool InvalidTemp = false;
|
||||
|
|
|
@ -374,7 +374,7 @@ static bool LineIsMarkedWithNOLINTinMacro(SourceManager &SM, SourceLocation Loc,
|
|||
return true;
|
||||
if (!Loc.isMacroID())
|
||||
return false;
|
||||
Loc = SM.getImmediateExpansionRange(Loc).first;
|
||||
Loc = SM.getImmediateExpansionRange(Loc).getBegin();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ void LambdaFunctionNameCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
if (E->getLocation().isMacroID()) {
|
||||
auto ER =
|
||||
Result.SourceManager->getImmediateExpansionRange(E->getLocation());
|
||||
if (SuppressMacroExpansions.find(SourceRange(ER.first, ER.second)) !=
|
||||
if (SuppressMacroExpansions.find(ER.getAsRange()) !=
|
||||
SuppressMacroExpansions.end()) {
|
||||
// This is a macro expansion for which we should not warn.
|
||||
return;
|
||||
|
|
|
@ -38,7 +38,7 @@ const Stmt *nextStmt(const MatchFinder::MatchResult &Result, const Stmt *S) {
|
|||
return nextStmt(Result, Parent);
|
||||
}
|
||||
|
||||
using ExpansionRanges = std::vector<std::pair<SourceLocation, SourceLocation>>;
|
||||
using ExpansionRanges = std::vector<SourceRange>;
|
||||
|
||||
/// \bried Get all the macro expansion ranges related to `Loc`.
|
||||
///
|
||||
|
@ -47,8 +47,9 @@ ExpansionRanges getExpansionRanges(SourceLocation Loc,
|
|||
const MatchFinder::MatchResult &Result) {
|
||||
ExpansionRanges Locs;
|
||||
while (Loc.isMacroID()) {
|
||||
Locs.push_back(Result.SourceManager->getImmediateExpansionRange(Loc));
|
||||
Loc = Locs.back().first;
|
||||
Locs.push_back(
|
||||
Result.SourceManager->getImmediateExpansionRange(Loc).getAsRange());
|
||||
Loc = Locs.back().getBegin();
|
||||
}
|
||||
return Locs;
|
||||
}
|
||||
|
@ -96,9 +97,9 @@ void MultipleStatementMacroCheck::check(
|
|||
InnerRanges.back() != NextRanges.back())
|
||||
return;
|
||||
|
||||
diag(InnerRanges.back().first, "multiple statement macro used without "
|
||||
"braces; some statements will be "
|
||||
"unconditionally executed");
|
||||
diag(InnerRanges.back().getBegin(), "multiple statement macro used without "
|
||||
"braces; some statements will be "
|
||||
"unconditionally executed");
|
||||
}
|
||||
|
||||
} // namespace bugprone
|
||||
|
|
|
@ -332,7 +332,7 @@ private:
|
|||
NullMacros.end();
|
||||
}
|
||||
|
||||
MacroLoc = SM.getExpansionRange(ArgLoc).first;
|
||||
MacroLoc = SM.getExpansionRange(ArgLoc).getBegin();
|
||||
|
||||
ArgLoc = Expansion.getSpellingLoc().getLocWithOffset(LocInfo.second);
|
||||
if (ArgLoc.isFileID())
|
||||
|
@ -387,7 +387,7 @@ private:
|
|||
continue;
|
||||
}
|
||||
|
||||
MacroLoc = SM.getImmediateExpansionRange(Loc).first;
|
||||
MacroLoc = SM.getImmediateExpansionRange(Loc).getBegin();
|
||||
if (MacroLoc.isFileID() && MacroLoc == TestMacroLoc) {
|
||||
// Match made.
|
||||
return true;
|
||||
|
|
|
@ -32,7 +32,7 @@ SourceLocation findNameLoc(const clang::Decl* D) {
|
|||
// be "<scratch space>"
|
||||
// * symbols controlled and defined by a compile command-line option
|
||||
// `-DName=foo`, the spelling location will be "<command line>".
|
||||
SpellingLoc = SM.getExpansionRange(D->getLocation()).first;
|
||||
SpellingLoc = SM.getExpansionRange(D->getLocation()).getBegin();
|
||||
}
|
||||
}
|
||||
return SpellingLoc;
|
||||
|
|
Loading…
Reference in New Issue