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