]> granicus.if.org Git - clang/commitdiff
Add some comments.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 26 Nov 2008 21:51:07 +0000 (21:51 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 26 Nov 2008 21:51:07 +0000 (21:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60119 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Parser.h
lib/Parse/ParseExpr.cpp
lib/Parse/Parser.cpp

index 94e3d713d5e379f9673d2a1b02062cc4dc3d72a2..f4695af279c5a0ecdf025b2e2901daeca52d9a96 100644 (file)
@@ -226,6 +226,10 @@ private:
   /// This simplifies handling of C++ scope specifiers and allows efficient
   /// backtracking without the need to re-parse and resolve nested-names and
   /// typenames.
+  /// It will mainly be called when we expect to treat identifiers as typenames
+  /// (if they are typenames). For example, in C we do not expect identifiers
+  /// inside expressions to be treated as typenames so it will not be called
+  /// for expressions in C.
   void TryAnnotateTypeOrScopeToken();
 
   /// TryAnnotateCXXScopeToken - Like TryAnnotateTypeOrScopeToken but only
index 17b14bd2a1b953e915527631381c3f038830b0be..66b1d180780b83648ac191aa5c724ffffc65d91a 100644 (file)
@@ -424,7 +424,11 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) {
 Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
   if (getLang().CPlusPlus) {
     // Annotate typenames and C++ scope specifiers.
-    // Used only in C++; in C let the typedef name be handled as an identifier.
+    // Used only in C++, where the typename can be considered as a functional
+    // style cast ("int(1)").
+    // In C we don't expect identifiers to be treated as typenames; if it's a
+    // typedef name, let it be handled as an identifier and
+    // Actions.ActOnIdentifierExpr will emit the proper diagnostic.
     TryAnnotateTypeOrScopeToken();
   }
 
index ec07b4231936aa279ada090d497c12fb9b5e9495..42d95e7f02e8d545420a33bd79ee5f33d21b924b 100644 (file)
@@ -700,6 +700,15 @@ Parser::ExprResult Parser::ParseSimpleAsm() {
 /// This simplifies handling of C++ scope specifiers and allows efficient
 /// backtracking without the need to re-parse and resolve nested-names and
 /// typenames.
+/// It will mainly be called when we expect to treat identifiers as typenames
+/// (if they are typenames). For example, in C we do not expect identifiers
+/// inside expressions to be treated as typenames so it will not be called
+/// for expressions in C.
+/// The benefit for C/ObjC is that a typename will be annotated and
+/// Actions.isTypeName will not be needed to be called again (e.g. isTypeName
+/// will not be called twice, once to check whether we have a declaration
+/// specifier, and another one to get the actual type inside
+/// ParseDeclarationSpecifiers).
 void Parser::TryAnnotateTypeOrScopeToken() {
   if (Tok.is(tok::annot_qualtypename) || Tok.is(tok::annot_cxxscope))
     return;