<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 14, 2015 at 7:36 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=richard@metafoo.co.uk&cc=&bcc=&su=&body=','_blank');return false;" class="cremed">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Wed, Jan 7, 2015 at 1:16 PM, Kaelyn Takata <span dir="ltr"><<a href="mailto:rikka@google.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=rikka@google.com&cc=&bcc=&su=&body=','_blank');return false;" class="cremed">rikka@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: rikka<br>
Date: Wed Jan  7 15:16:39 2015<br>
New Revision: 225389<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=225389&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=225389&view=rev</a><br>
Log:<br>
Handle OpaqueValueExprs more intelligently in the TransformTypos tree<br>
transform.<br>
<br>
Also diagnose typos in the initializer of an invalid C++ declaration.<br>
Both issues were hit using the same line of test code, depending on<br>
whether the code was treated as C or C++.<br>
<br>
Fixes PR22092.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaDecl.cpp<br>
    cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
    cfe/trunk/test/Sema/typo-correction.c<br>
    cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=225389&r1=225388&r2=225389&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=225389&r1=225388&r2=225389&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jan  7 15:16:39 2015<br>
@@ -8574,8 +8574,10 @@ void Sema::AddInitializerToDecl(Decl *Re<br>
                                 bool DirectInit, bool TypeMayContainAuto) {<br>
   // If there is no declaration, there was an error parsing it.  Just ignore<br>
   // the initializer.<br>
-  if (!RealDecl || RealDecl->isInvalidDecl())<br>
+  if (!RealDecl || RealDecl->isInvalidDecl()) {<br>
+    CorrectDelayedTyposInExpr(Init);<br>
     return;<br>
+  }<br>
<br>
   if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {<br>
     // With declarators parsed the way they are, the parser cannot<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=225389&r1=225388&r2=225389&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=225389&r1=225388&r2=225389&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jan  7 15:16:39 2015<br>
@@ -6141,6 +6141,12 @@ public:<br>
<br>
   ExprResult TransformLambdaExpr(LambdaExpr *E) { return Owned(E); }<br>
<br>
+  ExprResult TransformOpaqueValueExpr(OpaqueValueExpr *E) {<br>
+    if (Expr *SE = E->getSourceExpr())<br>
+      return TransformExpr(SE);<br>
+    return BaseTransform::TransformOpaqueValueExpr(E);<br>
+  }<br></blockquote><div><br></div></div></div><div>Hmm, can you instead handle this by overriding TreeTransform's AlreadyTransformed:</div><div><br></div><div>bool AlreadyTransformed(QualType T) {</div><div>  return T.isNull() || T->isInstantiationDependentType();</div><div>}</div><div><br></div><div>(Since we treat a TypoExpr as being dependent, it must lead to an instantiation-dependent type.)</div></div></div></div></blockquote><div><br></div><div>That fixes the TreeTransform assertion reported in PR22092, but it isn't sufficient for the TypoExpr nested inside of the OpaqueValueExpr to be seen as the default TransformOpaqueValueExpr just returns the original OpaqueValueExpr if the assertion doesn't fail. So instead the test case added to typo-correction.c fails in a different way:</div><div><br></div><div><div>error: 'error' diagnostics expected but not seen: </div><div>  File ~/llvm/tools/clang/test/Sema/typo-correction.c Line 13: use of undeclared identifier 'b'</div><div>error: 'error' diagnostics seen but not expected: </div><div>  (frontend): used type '<dependent type>' where arithmetic, pointer, or vector type is required</div><div>clang: ../tools/clang/lib/Sema/Sema.cpp:249: clang::Sema::~Sema(): Assertion `DelayedTypos.empty() && "Uncorrected typos!"' failed.</div></div><div>[followed by the stack trace for the failed assertion]</div><div><br></div><div>Overriding the definition of AlreadyTransformed just for to get an assertion in one Tranform*Expr method to pass also feels a bit... heavy-handed to me.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+<br>
   ExprResult Transform(Expr *E) {<br>
     ExprResult Res;<br>
     while (true) {<br>
<br>
Modified: cfe/trunk/test/Sema/typo-correction.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=225389&r1=225388&r2=225389&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=225389&r1=225388&r2=225389&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Sema/typo-correction.c (original)<br>
+++ cfe/trunk/test/Sema/typo-correction.c Wed Jan  7 15:16:39 2015<br>
@@ -9,3 +9,6 @@ void PR21656() {<br>
   float x;<br>
   x = (float)arst;  // expected-error-re {{use of undeclared identifier 'arst'{{$}}}}<br>
 }<br>
+<br>
+a = b ? : 0;  // expected-warning {{type specifier missing, defaults to 'int'}} \<br>
+              // expected-error {{use of undeclared identifier 'b'}}<br>
<br>
Modified: cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=225389&r1=225388&r2=225389&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=225389&r1=225388&r2=225389&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Wed Jan  7 15:16:39 2015<br>
@@ -152,3 +152,8 @@ namespace PR21947 {<br>
 int blue;  // expected-note {{'blue' declared here}}<br>
 __typeof blur y;  // expected-error {{use of undeclared identifier 'blur'; did you mean 'blue'?}}<br>
 }<br>
+<br>
+namespace PR22092 {<br>
+a = b ? : 0;  // expected-error {{C++ requires a type specifier for all declarations}} \<br>
+              // expected-error-re {{use of undeclared identifier 'b'{{$}}}}<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=cfe-commits@cs.uiuc.edu&cc=&bcc=&su=&body=','_blank');return false;" class="cremed">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>