[cfe-commits] r60119 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseExpr.cpp lib/Parse/Parser.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Wed Nov 26 13:51:08 PST 2008
Author: akirtzidis
Date: Wed Nov 26 15:51:07 2008
New Revision: 60119
URL: http://llvm.org/viewvc/llvm-project?rev=60119&view=rev
Log:
Add some comments.
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/Parser.cpp
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=60119&r1=60118&r2=60119&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Nov 26 15:51:07 2008
@@ -226,6 +226,10 @@
/// 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
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=60119&r1=60118&r2=60119&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Nov 26 15:51:07 2008
@@ -424,7 +424,11 @@
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();
}
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=60119&r1=60118&r2=60119&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Wed Nov 26 15:51:07 2008
@@ -700,6 +700,15 @@
/// 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;
More information about the cfe-commits
mailing list