r224172 - Typo correction: Ignore temporary binding exprs after overload resolution
Reid Kleckner
reid at kleckner.net
Fri Dec 12 16:53:10 PST 2014
Author: rnk
Date: Fri Dec 12 18:53:10 2014
New Revision: 224172
URL: http://llvm.org/viewvc/llvm-project?rev=224172&view=rev
Log:
Typo correction: Ignore temporary binding exprs after overload resolution
Transformation of a CallExpr doesn't always result in a new CallExpr.
Fixes PR21899.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=224172&r1=224171&r2=224172&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Dec 12 18:53:10 2014
@@ -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;
}
Modified: cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=224172&r1=224171&r2=224172&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Fri Dec 12 18:53:10 2014
@@ -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 at +1 {{'result' declared here}}
+ const char *result;
+ // expected-error at +1 {{use of undeclared identifier 'resulta'; did you mean 'result'?}}
+ if (AssertionResult ar = (Compare("value1", resulta)))
+ ;
+ else
+ printf("ar: %d\n", ar.val);
+}
More information about the cfe-commits
mailing list