diff options
| author | Reid Kleckner <reid@kleckner.net> | 2014-12-13 00:53:10 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2014-12-13 00:53:10 +0000 |
| commit | a7fe33e0f6e2ad24bb45e292c51f6cb6e27b377e (patch) | |
| tree | 58c25564d45c66408ab3ee9aec39e93176b0dfbf | |
| parent | 17f429f46255230b5b54f4ed947cc88c9f424a62 (diff) | |
| download | bcm5719-llvm-a7fe33e0f6e2ad24bb45e292c51f6cb6e27b377e.tar.gz bcm5719-llvm-a7fe33e0f6e2ad24bb45e292c51f6cb6e27b377e.zip | |
Typo correction: Ignore temporary binding exprs after overload resolution
Transformation of a CallExpr doesn't always result in a new CallExpr.
Fixes PR21899.
llvm-svn: 224172
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 9 | ||||
| -rw-r--r-- | clang/test/SemaCXX/typo-correction-delayed.cpp | 20 |
2 files changed, 27 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e8be716ea09..554e8c9b8fd 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -6105,8 +6105,13 @@ public: auto Result = BaseTransform::RebuildCallExpr(Callee, LParenLoc, Args, RParenLoc, ExecConfig); if (auto *OE = dyn_cast<OverloadExpr>(Callee)) { - if (!Result.isInvalid() && Result.get()) - OverloadResolution[OE] = cast<CallExpr>(Result.get())->getCallee(); + if (!Result.isInvalid() && Result.get()) { + Expr *ResultCall = Result.get(); + if (auto *BE = dyn_cast<CXXBindTemporaryExpr>(ResultCall)) + ResultCall = BE->getSubExpr(); + if (auto *CE = dyn_cast<CallExpr>(ResultCall)) + OverloadResolution[OE] = CE->getCallee(); + } } return Result; } diff --git a/clang/test/SemaCXX/typo-correction-delayed.cpp b/clang/test/SemaCXX/typo-correction-delayed.cpp index d303b58554d..d42888f1e6a 100644 --- a/clang/test/SemaCXX/typo-correction-delayed.cpp +++ b/clang/test/SemaCXX/typo-correction-delayed.cpp @@ -119,3 +119,23 @@ class SomeClass { public: explicit SomeClass() : Kind(kSum) {} // expected-error {{use of undeclared identifier 'kSum'; did you mean 'kNum'?}} }; + +extern "C" int printf(const char *, ...); + +// There used to be an issue with typo resolution inside overloads. +struct AssertionResult { + ~AssertionResult(); + operator bool(); + int val; +}; +AssertionResult Compare(const char *a, const char *b); +AssertionResult Compare(int a, int b); +int main() { + // expected-note@+1 {{'result' declared here}} + const char *result; + // expected-error@+1 {{use of undeclared identifier 'resulta'; did you mean 'result'?}} + if (AssertionResult ar = (Compare("value1", resulta))) + ; + else + printf("ar: %d\n", ar.val); +} |

