summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseAST.cpp
diff options
context:
space:
mode:
authorMeador Inge <meadori@codesourcery.com>2012-06-19 18:17:30 +0000
committerMeador Inge <meadori@codesourcery.com>2012-06-19 18:17:30 +0000
commitcdc0057e3ceb4c2d5b4477ddb9d30d0bf4ec6c1e (patch)
tree5c2cf3de3849954fd69465aa87c5aa904c5859b8 /clang/lib/Parse/ParseAST.cpp
parent6f832c57334e549cd277a09b4c2816bb3b895ec5 (diff)
downloadbcm5719-llvm-cdc0057e3ceb4c2d5b4477ddb9d30d0bf4ec6c1e.tar.gz
bcm5719-llvm-cdc0057e3ceb4c2d5b4477ddb9d30d0bf4ec6c1e.zip
Revert predefined decl tracking.
r158085 added some logic to track predefined declarations. The main reason we had predefined declarations in the input was because the __builtin_va_list declarations were injected into the preprocessor input. As of r158592 we explicitly build the __builtin_va_list declarations. Therefore the predefined decl tracking is no longer needed. llvm-svn: 158732
Diffstat (limited to 'clang/lib/Parse/ParseAST.cpp')
-rw-r--r--clang/lib/Parse/ParseAST.cpp44
1 files changed, 11 insertions, 33 deletions
diff --git a/clang/lib/Parse/ParseAST.cpp b/clang/lib/Parse/ParseAST.cpp
index 3f86c4d2c89..c50c1c980e5 100644
--- a/clang/lib/Parse/ParseAST.cpp
+++ b/clang/lib/Parse/ParseAST.cpp
@@ -83,46 +83,24 @@ void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) {
// declaration. C++ doesn't have this restriction. We also don't want to
// complain if we have a precompiled header, although technically if the PCH
// is empty we should still emit the (pedantic) diagnostic.
- bool WarnForEmptyTU = !S.getLangOpts().CPlusPlus;
- if (ExternalASTSource *External = S.getASTContext().getExternalSource()) {
- External->StartTranslationUnit(Consumer);
- WarnForEmptyTU = false;
- }
-
- // Clang's predefines contain top-level declarations for things like va_list,
- // making it hard to tell if the /user's/ translation unit has at least one
- // top-level declaration. So we parse cautiously, looking for a declaration
- // that doesn't come from our predefines.
- // Note that ParseTopLevelDecl returns 'true' at EOF.
- SourceManager &SM = S.getSourceManager();
Parser::DeclGroupPtrTy ADecl;
- while (WarnForEmptyTU && !P.ParseTopLevelDecl(ADecl)) {
- if (ADecl) {
- if (!Consumer->HandleTopLevelDecl(ADecl.get()))
- return;
- if (DeclGroupRef::iterator FirstDecl = ADecl.get().begin()) {
- SourceLocation DeclLoc = (*FirstDecl)->getLocation();
- WarnForEmptyTU = SM.isFromPredefines(DeclLoc);
- }
- }
- }
+ ExternalASTSource *External = S.getASTContext().getExternalSource();
+ if (External)
+ External->StartTranslationUnit(Consumer);
- // If we ended up seeing EOF before any top-level declarations, emit our
- // diagnostic. Otherwise, parse the rest of the file normally.
- if (WarnForEmptyTU) {
- P.Diag(diag::ext_empty_translation_unit);
+ if (P.ParseTopLevelDecl(ADecl)) {
+ if (!External && !S.getLangOpts().CPlusPlus)
+ P.Diag(diag::ext_empty_translation_unit);
} else {
- while (!P.ParseTopLevelDecl(ADecl)) { // Not end of file.
+ do {
// If we got a null return and something *was* parsed, ignore it. This
// is due to a top-level semicolon, an action override, or a parse error
// skipping something.
- if (ADecl) {
- if (!Consumer->HandleTopLevelDecl(ADecl.get()))
- return;
- }
- };
+ if (ADecl && !Consumer->HandleTopLevelDecl(ADecl.get()))
+ return;
+ } while (!P.ParseTopLevelDecl(ADecl));
}
-
+
// Process any TopLevelDecls generated by #pragma weak.
for (SmallVector<Decl*,2>::iterator
I = S.WeakTopLevelDecls().begin(),
OpenPOWER on IntegriCloud