diff --git a/clang/lib/DPCT/RuleInfra/ExprAnalysis.h b/clang/lib/DPCT/RuleInfra/ExprAnalysis.h index 22fb3f038b25..9c463614074d 100644 --- a/clang/lib/DPCT/RuleInfra/ExprAnalysis.h +++ b/clang/lib/DPCT/RuleInfra/ExprAnalysis.h @@ -785,8 +785,6 @@ class ArgumentAnalysis : public ExprAnalysis { // constructor and no migration for it. Start analyzing its argument. // Replace total string when it is default argument expression. void initArgumentExpr(const Expr *Expression) { - if (!Expression) - initExpression(Expression); if (auto Ctor = dyn_cast(Expression)) { if (Ctor->getParenOrBraceRange().isInvalid() && Ctor->getNumArgs() == 1) Expression = Ctor->getArg(0); diff --git a/clang/lib/DPCT/Utility.cpp b/clang/lib/DPCT/Utility.cpp index eaa99452e75c..46f704206fc3 100644 --- a/clang/lib/DPCT/Utility.cpp +++ b/clang/lib/DPCT/Utility.cpp @@ -193,8 +193,8 @@ SourceRange getStmtExpansionSourceRange(const Stmt *S) { isInRange(SM.getExpansionRange(Range.getBegin()).getBegin(), SM.getExpansionRange(Range.getBegin()).getEnd(), SM.getSpellingLoc(Range.getBegin())) && - isInRange(SM.getExpansionRange(Range.getBegin()).getBegin(), - SM.getExpansionRange(Range.getBegin()).getEnd(), + isInRange(SM.getExpansionRange(Range.getEnd()).getBegin(), + SM.getExpansionRange(Range.getEnd()).getEnd(), SM.getSpellingLoc(Range.getEnd()))) { // MACRO(callExpr()) BeginLoc = SM.getSpellingLoc(Range.getBegin()); @@ -2176,7 +2176,7 @@ getTheOneBeforeLastImmediateExapansion(const clang::SourceLocation Begin, // Line 3: #define CALL_KERNEL(C, D) KERNEL(C, D); int a = 0; // Line 4: void templatefoo2() { CALL_KERNEL(8, 9) } // There are 3 candidates of the kernel range, -// 1. Line 4 "CALL_KERNEL2(8, AAA)" +// 1. Line 4 "CALL_KERNEL(8, 9)" // 2. Line 3 "KERNEL(C, D)" // 3. Line 2 "templatefooCCC" // The 3rd candidate is the best choice. @@ -2280,7 +2280,7 @@ void traversePossibleLocations(const SourceLocation &SL, if (!SL.isValid()) return; if (Cache.find(SL.getHashValue()) != Cache.end()) - return; + return; // If visited, return; Cache.insert(SL.getHashValue()); if (!SL.isMacroID()) { if (isInRange(RangeBegin, RangeEnd, SL)) {