r223705 - Handle possible TypoExprs in member initializers.
Kaelyn Takata
rikka at google.com
Mon Dec 8 14:41:42 PST 2014
Author: rikka
Date: Mon Dec 8 16:41:42 2014
New Revision: 223705
URL: http://llvm.org/viewvc/llvm-project?rev=223705&view=rev
Log:
Handle possible TypoExprs in member initializers.
Includes a new test case since none of the existing tests were hitting
this code path.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=223705&r1=223704&r2=223705&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Dec 8 16:41:42 2014
@@ -2813,6 +2813,11 @@ Sema::BuildMemInitializer(Decl *Construc
SourceLocation IdLoc,
Expr *Init,
SourceLocation EllipsisLoc) {
+ ExprResult Res = CorrectDelayedTyposInExpr(Init);
+ if (!Res.isUsable())
+ return true;
+ Init = Res.get();
+
if (!ConstructorD)
return true;
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=223705&r1=223704&r2=223705&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Mon Dec 8 16:41:42 2014
@@ -112,3 +112,10 @@ void test_paren_suffix() {
foo::bar({5, 6}); // expected-error-re {{no member named 'bar' in namespace 'foo'{{$}}}} \
// expected-error {{expected expression}}
}
+
+const int kNum = 10; // expected-note {{'kNum' declared here}}
+class SomeClass {
+ int Kind;
+public:
+ explicit SomeClass() : Kind(kSum) {} // expected-error {{use of undeclared identifier 'kSum'; did you mean 'kNum'?}}
+};
More information about the cfe-commits
mailing list