[cfe-commits] r151112 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseExpr.cpp lib/Parse/ParseTemplate.cpp test/SemaCXX/typo-correction.cpp

Kaelyn Uhrain rikka at google.com
Tue Feb 21 17:03:07 PST 2012


Author: rikka
Date: Tue Feb 21 19:03:07 2012
New Revision: 151112

URL: http://llvm.org/viewvc/llvm-project?rev=151112&view=rev
Log:
Fix typo correction of template arguments to once again allow type names.

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/test/SemaCXX/typo-correction.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=151112&r1=151111&r2=151112&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Feb 21 19:03:07 2012
@@ -1288,7 +1288,7 @@
   };
 
   ExprResult ParseExpression(TypeCastState isTypeCast = NotTypeCast);
-  ExprResult ParseConstantExpression();
+  ExprResult ParseConstantExpression(TypeCastState isTypeCast = NotTypeCast);
   // Expr that doesn't include commas.
   ExprResult ParseAssignmentExpression(TypeCastState isTypeCast = NotTypeCast);
 

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=151112&r1=151111&r2=151112&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Feb 21 19:03:07 2012
@@ -249,7 +249,7 @@
 }
 
 
-ExprResult Parser::ParseConstantExpression() {
+ExprResult Parser::ParseConstantExpression(TypeCastState isTypeCast) {
   // C++03 [basic.def.odr]p2:
   //   An expression is potentially evaluated unless it appears where an
   //   integral constant expression is required (see 5.19) [...].
@@ -257,7 +257,7 @@
   EnterExpressionEvaluationContext Unevaluated(Actions,
                                                Sema::ConstantEvaluated);
 
-  ExprResult LHS(ParseCastExpression(false));
+  ExprResult LHS(ParseCastExpression(false, false, isTypeCast));
   return ParseRHSOfBinaryExpression(LHS, prec::Conditional);
 }
 

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=151112&r1=151111&r2=151112&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Tue Feb 21 19:03:07 2012
@@ -1037,7 +1037,7 @@
   
   // Parse a non-type template argument. 
   SourceLocation Loc = Tok.getLocation();
-  ExprResult ExprArg = ParseConstantExpression();
+  ExprResult ExprArg = ParseConstantExpression(MaybeTypeCast);
   if (ExprArg.isInvalid() || !ExprArg.get())
     return ParsedTemplateArgument();
 

Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=151112&r1=151111&r2=151112&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp Tue Feb 21 19:03:07 2012
@@ -167,3 +167,19 @@
 };
 class Child: public Parent {};
 void Child::add_types(int value) {} // expected-error{{out-of-line definition of 'add_types' does not match any declaration in 'Child'}}
+
+// Fix the callback based filtering of typo corrections within
+// Sema::ActOnIdExpression by Parser::ParseCastExpression to allow type names as
+// potential corrections for template arguments.
+namespace clash {
+class ConstructExpr {}; // expected-note{{'clash::ConstructExpr' declared here}}
+}
+class ClashTool {
+  bool HaveConstructExpr();
+  template <class T> T* getExprAs();
+
+  void test() {
+    ConstructExpr *expr = // expected-error{{unknown type name 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
+        getExprAs<ConstructExpr>(); // expected-error{{use of undeclared identifier 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
+  }
+};





More information about the cfe-commits mailing list