From 06edd15fdda9155b54366d3887a4fbf25cf1d911 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Sat, 5 May 2018 21:17:32 +0100 Subject: Fix build with clang 8.0 BUG: 393745 --- src/checks/level2/old-style-connect.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/checks/level2/old-style-connect.cpp b/src/checks/level2/old-style-connect.cpp index 9633fdc4..3df545ae 100644 --- a/src/checks/level2/old-style-connect.cpp +++ b/src/checks/level2/old-style-connect.cpp @@ -64,6 +64,16 @@ static bool classIsOk(StringRef className) return className != "QDBusInterface"; } +static CharSourceRange getImmediateExpansionRange(SourceLocation macroLoc, const SourceManager &sm) +{ +#if LLVM_VERSION_MAJOR >= 8 + 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, Option_CanIgnoreIncludes) { @@ -228,8 +238,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()); @@ -393,8 +403,8 @@ vector OldStyleConnect::fixits(int classification, CallExpr *call) qualifiedName = clazy::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; -- cgit v1.2.3