[cfe-commits] r58498 - in /cfe/trunk: Driver/PrintParserCallbacks.cpp Driver/clang.cpp Driver/clang.h include/clang/Parse/Action.h lib/Parse/MinimalAction.cpp test/Parser/2008-10-31-parse-noop-failure.c
Daniel Dunbar
daniel at zuster.org
Fri Oct 31 01:56:51 PDT 2008
Author: ddunbar
Date: Fri Oct 31 03:56:51 2008
New Revision: 58498
URL: http://llvm.org/viewvc/llvm-project?rev=58498&view=rev
Log:
"One" line fix for -parse-noop failure, "id" and several other things
were being treated as type names for non-Objective-C files.
- Other lines are just because MinimalAction didn't have access to
the LangOptions.
Added:
cfe/trunk/test/Parser/2008-10-31-parse-noop-failure.c (with props)
Modified:
cfe/trunk/Driver/PrintParserCallbacks.cpp
cfe/trunk/Driver/clang.cpp
cfe/trunk/Driver/clang.h
cfe/trunk/include/clang/Parse/Action.h
cfe/trunk/lib/Parse/MinimalAction.cpp
Modified: cfe/trunk/Driver/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintParserCallbacks.cpp?rev=58498&r1=58497&r2=58498&view=diff
==============================================================================
--- cfe/trunk/Driver/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/Driver/PrintParserCallbacks.cpp Fri Oct 31 03:56:51 2008
@@ -22,7 +22,7 @@
class ParserPrintActions : public MinimalAction {
public:
- ParserPrintActions(IdentifierTable &IT) : MinimalAction(IT) {}
+ ParserPrintActions(Preprocessor &PP) : MinimalAction(PP) {}
// Printing Functions which also must call MinimalAction
@@ -568,6 +568,6 @@
};
}
-MinimalAction *clang::CreatePrintParserActionsAction(IdentifierTable &IT) {
- return new ParserPrintActions(IT);
+MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP) {
+ return new ParserPrintActions(PP);
}
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=58498&r1=58497&r2=58498&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Fri Oct 31 03:56:51 2008
@@ -1304,12 +1304,12 @@
break;
case ParseNoop: // -parse-noop
- ParseFile(PP, new MinimalAction(PP.getIdentifierTable()));
+ ParseFile(PP, new MinimalAction(PP));
ClearSourceMgr = true;
break;
case ParsePrintCallbacks:
- ParseFile(PP, CreatePrintParserActionsAction(PP.getIdentifierTable()));
+ ParseFile(PP, CreatePrintParserActionsAction(PP));
ClearSourceMgr = true;
break;
Modified: cfe/trunk/Driver/clang.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.h?rev=58498&r1=58497&r2=58498&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.h (original)
+++ cfe/trunk/Driver/clang.h Fri Oct 31 03:56:51 2008
@@ -39,7 +39,7 @@
/// CreatePrintParserActionsAction - Return the actions implementation that
/// implements the -parse-print-callbacks option.
-MinimalAction *CreatePrintParserActionsAction(IdentifierTable &);
+MinimalAction *CreatePrintParserActionsAction(Preprocessor &PP);
/// EmitLLVMFromASTs - Implement -emit-llvm, which generates llvm IR from C.
void EmitLLVMFromASTs(Preprocessor &PP, bool PrintStats);
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=58498&r1=58497&r2=58498&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Fri Oct 31 03:56:51 2008
@@ -31,6 +31,7 @@
class Selector;
class InitListDesignations;
// Lex.
+ class Preprocessor;
class Token;
/// Action - As the parser reads the input file and recognizes the productions
@@ -923,8 +924,9 @@
/// For example, user-defined classes, built-in "id" type, etc.
Scope *TUScope;
IdentifierTable &Idents;
+ Preprocessor &PP;
public:
- MinimalAction(IdentifierTable &IT) : Idents(IT) {}
+ MinimalAction(Preprocessor &pp);
/// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to
/// determine whether the name is a typedef or not in this scope.
Modified: cfe/trunk/lib/Parse/MinimalAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/MinimalAction.cpp?rev=58498&r1=58497&r2=58498&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/MinimalAction.cpp (original)
+++ cfe/trunk/lib/Parse/MinimalAction.cpp Fri Oct 31 03:56:51 2008
@@ -28,12 +28,16 @@
}
};
-void MinimalAction:: ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
+MinimalAction::MinimalAction(Preprocessor &pp)
+ : Idents(pp.getIdentifierTable()), PP(pp) {}
+
+void MinimalAction::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
TUScope = S;
+ if (!PP.getLangOptions().ObjC1) return;
+
+ // recognize the ObjC built-in type identifiers.
IdentifierInfo *II;
TypeNameInfo *TI;
-
- // recognize the ObjC built-in type identifiers.
II = &Idents.get("id");
TI = new TypeNameInfo(1, II->getFETokenInfo<TypeNameInfo>());
II->setFETokenInfo(TI);
Added: cfe/trunk/test/Parser/2008-10-31-parse-noop-failure.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/2008-10-31-parse-noop-failure.c?rev=58498&view=auto
==============================================================================
--- cfe/trunk/test/Parser/2008-10-31-parse-noop-failure.c (added)
+++ cfe/trunk/test/Parser/2008-10-31-parse-noop-failure.c Fri Oct 31 03:56:51 2008
@@ -0,0 +1,4 @@
+// RUN: clang -verify -parse-noop %t
+
+void add_attribute(id) int id; {}
+
Propchange: cfe/trunk/test/Parser/2008-10-31-parse-noop-failure.c
------------------------------------------------------------------------------
svn:executable = *
More information about the cfe-commits
mailing list