Implement ObjC built-in types in MinimalAction.

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
This commit is contained in:
Steve Naroff 2007-10-31 20:55:39 +00:00
Родитель 9b181b3eec
Коммит b4292f221f
5 изменённых файлов: 26 добавлений и 6 удалений

Просмотреть файл

@ -21,6 +21,9 @@ using namespace clang;
namespace { namespace {
class ParserPrintActions : public MinimalAction { class ParserPrintActions : public MinimalAction {
public:
ParserPrintActions(IdentifierTable &IT) : MinimalAction(IT) {}
/// ActOnDeclarator - This callback is invoked when a declarator is parsed /// ActOnDeclarator - This callback is invoked when a declarator is parsed
/// and 'Init' specifies the initializer if any. This is for things like: /// and 'Init' specifies the initializer if any. This is for things like:
/// "int X = 4" or "typedef int foo". /// "int X = 4" or "typedef int foo".
@ -49,6 +52,6 @@ namespace {
}; };
} }
MinimalAction *clang::CreatePrintParserActionsAction() { MinimalAction *clang::CreatePrintParserActionsAction(IdentifierTable &IT) {
return new ParserPrintActions(); return new ParserPrintActions(IT);
} }

Просмотреть файл

@ -763,12 +763,13 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
break; break;
case ParseNoop: // -parse-noop case ParseNoop: // -parse-noop
ParseFile(PP, new MinimalAction(), MainFileID); ParseFile(PP, new MinimalAction(PP.getIdentifierTable()), MainFileID);
ClearSourceMgr = true; ClearSourceMgr = true;
break; break;
case ParsePrintCallbacks: case ParsePrintCallbacks:
ParseFile(PP, CreatePrintParserActionsAction(), MainFileID); ParseFile(PP, CreatePrintParserActionsAction(PP.getIdentifierTable()),
MainFileID);
ClearSourceMgr = true; ClearSourceMgr = true;
break; break;

Просмотреть файл

@ -21,6 +21,7 @@ class MinimalAction;
class TargetInfo; class TargetInfo;
class Diagnostic; class Diagnostic;
class ASTConsumer; class ASTConsumer;
class IdentifierTable;
/// DoPrintPreprocessedInput - Implement -E mode. /// DoPrintPreprocessedInput - Implement -E mode.
void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP, void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP,
@ -28,7 +29,7 @@ void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP,
/// CreatePrintParserActionsAction - Return the actions implementation that /// CreatePrintParserActionsAction - Return the actions implementation that
/// implements the -parse-print-callbacks option. /// implements the -parse-print-callbacks option.
MinimalAction *CreatePrintParserActionsAction(); MinimalAction *CreatePrintParserActionsAction(IdentifierTable &);
/// CreateTargetInfo - Return the set of target info objects as specified by /// CreateTargetInfo - Return the set of target info objects as specified by
/// the -arch command line option. /// the -arch command line option.

Просмотреть файл

@ -30,7 +30,19 @@ struct TypeNameInfo {
void MinimalAction:: ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { void MinimalAction:: ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
TUScope = 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 /// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to

Просмотреть файл

@ -632,7 +632,10 @@ class MinimalAction : public Action {
/// to lookup file scope declarations in the "ordinary" C decl namespace. /// to lookup file scope declarations in the "ordinary" C decl namespace.
/// For example, user-defined classes, built-in "id" type, etc. /// For example, user-defined classes, built-in "id" type, etc.
Scope *TUScope; Scope *TUScope;
IdentifierTable &Idents;
public: public:
MinimalAction(IdentifierTable &IT) : Idents(IT) {}
/// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to /// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to
/// determine whether the name is a typedef or not in this scope. /// determine whether the name is a typedef or not in this scope.
virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const; virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const;