From aaba027717a81d49c73739665d0305f04475e2ce Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Wed, 31 Oct 2007 20:55:39 +0000 Subject: [PATCH] Implement ObjC built-in types in MinimalAction. This fixes the recent regression with selector-1.m and -parse-noop. llvm-svn: 43575 --- clang/Driver/PrintParserCallbacks.cpp | 7 +++++-- clang/Driver/clang.cpp | 5 +++-- clang/Driver/clang.h | 3 ++- clang/Parse/MinimalAction.cpp | 14 +++++++++++++- clang/include/clang/Parse/Action.h | 3 +++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/clang/Driver/PrintParserCallbacks.cpp b/clang/Driver/PrintParserCallbacks.cpp index d7deb43f87ac..9568b872114e 100644 --- a/clang/Driver/PrintParserCallbacks.cpp +++ b/clang/Driver/PrintParserCallbacks.cpp @@ -21,6 +21,9 @@ using namespace clang; namespace { class ParserPrintActions : public MinimalAction { + public: + ParserPrintActions(IdentifierTable &IT) : MinimalAction(IT) {} + /// ActOnDeclarator - This callback is invoked when a declarator is parsed /// and 'Init' specifies the initializer if any. This is for things like: /// "int X = 4" or "typedef int foo". @@ -49,6 +52,6 @@ namespace { }; } -MinimalAction *clang::CreatePrintParserActionsAction() { - return new ParserPrintActions(); +MinimalAction *clang::CreatePrintParserActionsAction(IdentifierTable &IT) { + return new ParserPrintActions(IT); } diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index 6e0ed914e2b9..77779f7e80e7 100644 --- a/clang/Driver/clang.cpp +++ b/clang/Driver/clang.cpp @@ -763,12 +763,13 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID, break; case ParseNoop: // -parse-noop - ParseFile(PP, new MinimalAction(), MainFileID); + ParseFile(PP, new MinimalAction(PP.getIdentifierTable()), MainFileID); ClearSourceMgr = true; break; case ParsePrintCallbacks: - ParseFile(PP, CreatePrintParserActionsAction(), MainFileID); + ParseFile(PP, CreatePrintParserActionsAction(PP.getIdentifierTable()), + MainFileID); ClearSourceMgr = true; break; diff --git a/clang/Driver/clang.h b/clang/Driver/clang.h index bf212866ec8d..fd11590854e6 100644 --- a/clang/Driver/clang.h +++ b/clang/Driver/clang.h @@ -21,6 +21,7 @@ class MinimalAction; class TargetInfo; class Diagnostic; class ASTConsumer; +class IdentifierTable; /// DoPrintPreprocessedInput - Implement -E mode. void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP, @@ -28,7 +29,7 @@ void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP, /// CreatePrintParserActionsAction - Return the actions implementation that /// implements the -parse-print-callbacks option. -MinimalAction *CreatePrintParserActionsAction(); +MinimalAction *CreatePrintParserActionsAction(IdentifierTable &); /// CreateTargetInfo - Return the set of target info objects as specified by /// the -arch command line option. diff --git a/clang/Parse/MinimalAction.cpp b/clang/Parse/MinimalAction.cpp index bc7c41bec398..92d997f59cf5 100644 --- a/clang/Parse/MinimalAction.cpp +++ b/clang/Parse/MinimalAction.cpp @@ -30,7 +30,19 @@ struct TypeNameInfo { void MinimalAction:: ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { TUScope = S; - // FIXME: add id/SEL/Class. We need to get our paws on the identifier table. + IdentifierInfo *II; + TypeNameInfo *TI; + + // recognize the ObjC built-in type identifiers. + II = &Idents.get("id"); + TI = new TypeNameInfo(1, II->getFETokenInfo()); + II->setFETokenInfo(TI); + II = &Idents.get("SEL"); + TI = new TypeNameInfo(1, II->getFETokenInfo()); + II->setFETokenInfo(TI); + II = &Idents.get("Class"); + TI = new TypeNameInfo(1, II->getFETokenInfo()); + II->setFETokenInfo(TI); } /// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to diff --git a/clang/include/clang/Parse/Action.h b/clang/include/clang/Parse/Action.h index 43290f2add98..32025eaa01ee 100644 --- a/clang/include/clang/Parse/Action.h +++ b/clang/include/clang/Parse/Action.h @@ -632,7 +632,10 @@ class MinimalAction : public Action { /// to lookup file scope declarations in the "ordinary" C decl namespace. /// For example, user-defined classes, built-in "id" type, etc. Scope *TUScope; + IdentifierTable &Idents; public: + MinimalAction(IdentifierTable &IT) : Idents(IT) {} + /// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to /// determine whether the name is a typedef or not in this scope. virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const;