[cfe-commits] r43575 - in /cfe/trunk: Driver/PrintParserCallbacks.cpp Driver/clang.cpp Driver/clang.h Parse/MinimalAction.cpp include/clang/Parse/Action.h

Steve Naroff snaroff at apple.com
Wed Oct 31 13:55:39 PDT 2007


Author: snaroff
Date: Wed Oct 31 15:55:39 2007
New Revision: 43575

URL: http://llvm.org/viewvc/llvm-project?rev=43575&view=rev
Log:

Implement ObjC built-in types in MinimalAction.

This fixes the recent regression with selector-1.m and -parse-noop.


Modified:
    cfe/trunk/Driver/PrintParserCallbacks.cpp
    cfe/trunk/Driver/clang.cpp
    cfe/trunk/Driver/clang.h
    cfe/trunk/Parse/MinimalAction.cpp
    cfe/trunk/include/clang/Parse/Action.h

Modified: cfe/trunk/Driver/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintParserCallbacks.cpp?rev=43575&r1=43574&r2=43575&view=diff

==============================================================================
--- cfe/trunk/Driver/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/Driver/PrintParserCallbacks.cpp Wed Oct 31 15:55:39 2007
@@ -21,6 +21,9 @@
 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 @@
   };
 }
 
-MinimalAction *clang::CreatePrintParserActionsAction() {
-  return new ParserPrintActions();
+MinimalAction *clang::CreatePrintParserActionsAction(IdentifierTable &IT) {
+  return new ParserPrintActions(IT);
 }

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=43575&r1=43574&r2=43575&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Wed Oct 31 15:55:39 2007
@@ -763,12 +763,13 @@
     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;
       

Modified: cfe/trunk/Driver/clang.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.h?rev=43575&r1=43574&r2=43575&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.h (original)
+++ cfe/trunk/Driver/clang.h Wed Oct 31 15:55:39 2007
@@ -21,6 +21,7 @@
 class TargetInfo;
 class Diagnostic;
 class ASTConsumer;
+class IdentifierTable;
 
 /// DoPrintPreprocessedInput - Implement -E mode.
 void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP,
@@ -28,7 +29,7 @@
 
 /// 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.

Modified: cfe/trunk/Parse/MinimalAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/MinimalAction.cpp?rev=43575&r1=43574&r2=43575&view=diff

==============================================================================
--- cfe/trunk/Parse/MinimalAction.cpp (original)
+++ cfe/trunk/Parse/MinimalAction.cpp Wed Oct 31 15:55:39 2007
@@ -30,7 +30,19 @@
 
 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

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=43575&r1=43574&r2=43575&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Wed Oct 31 15:55:39 2007
@@ -632,7 +632,10 @@
   /// 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;





More information about the cfe-commits mailing list