"One" line fix for -parse-noop failure, "id" and several other things
were being treated as type names for non-Objective-C files. - Other lines are just because MinimalAction didn't have access to the LangOptions. llvm-svn: 58498
This commit is contained in:
parent
0c248e7ed8
commit
f8362f9e5d
|
|
@ -22,7 +22,7 @@ namespace {
|
||||||
class ParserPrintActions : public MinimalAction {
|
class ParserPrintActions : public MinimalAction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ParserPrintActions(IdentifierTable &IT) : MinimalAction(IT) {}
|
ParserPrintActions(Preprocessor &PP) : MinimalAction(PP) {}
|
||||||
|
|
||||||
// Printing Functions which also must call MinimalAction
|
// Printing Functions which also must call MinimalAction
|
||||||
|
|
||||||
|
|
@ -568,6 +568,6 @@ namespace {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
MinimalAction *clang::CreatePrintParserActionsAction(IdentifierTable &IT) {
|
MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP) {
|
||||||
return new ParserPrintActions(IT);
|
return new ParserPrintActions(PP);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1304,12 +1304,12 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ParseNoop: // -parse-noop
|
case ParseNoop: // -parse-noop
|
||||||
ParseFile(PP, new MinimalAction(PP.getIdentifierTable()));
|
ParseFile(PP, new MinimalAction(PP));
|
||||||
ClearSourceMgr = true;
|
ClearSourceMgr = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ParsePrintCallbacks:
|
case ParsePrintCallbacks:
|
||||||
ParseFile(PP, CreatePrintParserActionsAction(PP.getIdentifierTable()));
|
ParseFile(PP, CreatePrintParserActionsAction(PP));
|
||||||
ClearSourceMgr = true;
|
ClearSourceMgr = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ void DoRewriteTest(Preprocessor &PP, const std::string &InFileName,
|
||||||
|
|
||||||
/// 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(IdentifierTable &);
|
MinimalAction *CreatePrintParserActionsAction(Preprocessor &PP);
|
||||||
|
|
||||||
/// EmitLLVMFromASTs - Implement -emit-llvm, which generates llvm IR from C.
|
/// EmitLLVMFromASTs - Implement -emit-llvm, which generates llvm IR from C.
|
||||||
void EmitLLVMFromASTs(Preprocessor &PP, bool PrintStats);
|
void EmitLLVMFromASTs(Preprocessor &PP, bool PrintStats);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ namespace clang {
|
||||||
class Selector;
|
class Selector;
|
||||||
class InitListDesignations;
|
class InitListDesignations;
|
||||||
// Lex.
|
// Lex.
|
||||||
|
class Preprocessor;
|
||||||
class Token;
|
class Token;
|
||||||
|
|
||||||
/// Action - As the parser reads the input file and recognizes the productions
|
/// Action - As the parser reads the input file and recognizes the productions
|
||||||
|
|
@ -923,8 +924,9 @@ class MinimalAction : public Action {
|
||||||
/// 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;
|
IdentifierTable &Idents;
|
||||||
|
Preprocessor &PP;
|
||||||
public:
|
public:
|
||||||
MinimalAction(IdentifierTable &IT) : Idents(IT) {}
|
MinimalAction(Preprocessor &pp);
|
||||||
|
|
||||||
/// 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.
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,16 @@ struct TypeNameInfo {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
TUScope = S;
|
||||||
IdentifierInfo *II;
|
if (!PP.getLangOptions().ObjC1) return;
|
||||||
TypeNameInfo *TI;
|
|
||||||
|
|
||||||
// recognize the ObjC built-in type identifiers.
|
// recognize the ObjC built-in type identifiers.
|
||||||
|
IdentifierInfo *II;
|
||||||
|
TypeNameInfo *TI;
|
||||||
II = &Idents.get("id");
|
II = &Idents.get("id");
|
||||||
TI = new TypeNameInfo(1, II->getFETokenInfo<TypeNameInfo>());
|
TI = new TypeNameInfo(1, II->getFETokenInfo<TypeNameInfo>());
|
||||||
II->setFETokenInfo(TI);
|
II->setFETokenInfo(TI);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
// RUN: clang -verify -parse-noop %t
|
||||||
|
|
||||||
|
void add_attribute(id) int id; {}
|
||||||
|
|
||||||
Loading…
Reference in New Issue