]> granicus.if.org Git - clang/commitdiff
Implement ObjC built-in types in MinimalAction.
authorSteve Naroff <snaroff@apple.com>
Wed, 31 Oct 2007 20:55:39 +0000 (20:55 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 31 Oct 2007 20:55:39 +0000 (20:55 +0000)
This fixes the recent regression with selector-1.m and -parse-noop.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43575 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/PrintParserCallbacks.cpp
Driver/clang.cpp
Driver/clang.h
Parse/MinimalAction.cpp
include/clang/Parse/Action.h

index d7deb43f87ace8c49593cddfcc84a99e751dd488..9568b872114ec57d0cffabff2cc5840a52699c36 100644 (file)
@@ -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);
 }
index 6e0ed914e2b98f9720407c46ab326d047a2ba586..77779f7e80e78c02a757d04be56d6274e4c47b1b 100644 (file)
@@ -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;
       
index bf212866ec8dd438040bed3e5bb1810ff73df17f..fd11590854e6c7fad52ac87d7564960f943e898a 100644 (file)
@@ -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.
index bc7c41bec398e734a85c59f2cdeb2b3a2b6dd9ea..92d997f59cf518f71da20c98afa0b5982ca70174 100644 (file)
@@ -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<TypeNameInfo>());
+  II->setFETokenInfo(TI);
+  II = &Idents.get("SEL");
+  TI = new TypeNameInfo(1, II->getFETokenInfo<TypeNameInfo>());
+  II->setFETokenInfo(TI);
+  II = &Idents.get("Class");
+  TI = new TypeNameInfo(1, II->getFETokenInfo<TypeNameInfo>());
+  II->setFETokenInfo(TI);
 }
 
 /// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to
index 43290f2add981f3473664f50130e77c598afbd83..32025eaa01ee92e2d7af669b3de255bbd6cdaf20 100644 (file)
@@ -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;