were being treated as type names for non-Objective-C files.
- Other lines are just because MinimalAction didn't have access to
the LangOptions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58498
91177308-0d34-0410-b5e6-
96231b3b80d8
class ParserPrintActions : public MinimalAction {
public:
- ParserPrintActions(IdentifierTable &IT) : MinimalAction(IT) {}
+ ParserPrintActions(Preprocessor &PP) : MinimalAction(PP) {}
// Printing Functions which also must call MinimalAction
};
}
-MinimalAction *clang::CreatePrintParserActionsAction(IdentifierTable &IT) {
- return new ParserPrintActions(IT);
+MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP) {
+ return new ParserPrintActions(PP);
}
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;
/// 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);
class Selector;
class InitListDesignations;
// Lex.
+ class Preprocessor;
class Token;
/// Action - As the parser reads the input file and recognizes the productions
/// 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.
}
};
-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);
--- /dev/null
+// RUN: clang -verify -parse-noop %t
+
+void add_attribute(id) int id; {}
+