diff options
author | Sergio Martins <iamsergio@gmail.com> | 2018-05-05 21:17:32 +0100 |
---|---|---|
committer | Sergio Martins <iamsergio@gmail.com> | 2018-09-19 16:18:38 +0100 |
commit | c1074481b58a4ec9b9d54599a152e079384042ac (patch) | |
tree | 4eb0686acdddd76f945202d3760d38df10ce1cbb /src | |
parent | 8404219d174ffb4aaf7a713704db0abf93ffa47a (diff) |
Fix build with clang 7.0
(cherry-picked from 06edd15fdda9155b54366d3887a4fbf25cf1d911)
Diffstat (limited to 'src')
-rw-r--r-- | src/checks/level2/oldstyleconnect.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/checks/level2/oldstyleconnect.cpp b/src/checks/level2/oldstyleconnect.cpp index 02440913..c22c6266 100644 --- a/src/checks/level2/oldstyleconnect.cpp +++ b/src/checks/level2/oldstyleconnect.cpp @@ -72,6 +72,16 @@ static bool classIsOk(const string &className) return clazy_std::contains(okClasses, className); } +static CharSourceRange getImmediateExpansionRange(SourceLocation macroLoc, const SourceManager &sm) +{ +#if LLVM_VERSION_MAJOR >= 7 + return sm.getImmediateExpansionRange(macroLoc); +#else + auto pair = sm.getImmediateExpansionRange(macroLoc); + return CharSourceRange(SourceRange(pair.first, pair.second), false); +#endif +} + OldStyleConnect::OldStyleConnect(const std::string &name, ClazyContext *context) : CheckBase(name, context) { @@ -237,8 +247,8 @@ string OldStyleConnect::signalOrSlotNameFromMacro(SourceLocation macroLoc) if (!macroLoc.isMacroID()) return "error"; - auto expansionRange = sm().getImmediateExpansionRange(macroLoc); - SourceRange range = SourceRange(expansionRange.first, expansionRange.second); + CharSourceRange expansionRange = getImmediateExpansionRange(macroLoc, sm()); + SourceRange range = SourceRange(expansionRange.getBegin(), expansionRange.getEnd()); auto charRange = Lexer::getAsCharRange(range, sm(), lo()); const string text = Lexer::getSourceText(charRange, sm(), lo()); @@ -402,8 +412,8 @@ vector<FixItHint> OldStyleConnect::fixits(int classification, CallExpr *call) qualifiedName = ContextUtils::getMostNeededQualifiedName(sm(), methodDecl, context, call->getLocStart(), !isInInclude); // (In includes ignore using directives) } - auto expansionRange = sm().getImmediateExpansionRange(s); - SourceRange range = SourceRange(expansionRange.first, expansionRange.second); + CharSourceRange expansionRange = getImmediateExpansionRange(s, sm()); + SourceRange range = SourceRange(expansionRange.getBegin(), expansionRange.getEnd()); const string functionPointer = '&' + qualifiedName; string replacement = functionPointer; |