aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-12 23:31:19 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-12 23:31:19 +0000
commitf18d0d8b39e891460d50f8a8b85029885b264986 (patch)
tree8a120245ca3d945c0ba5a7a87673d434f72ca849 /lib/Frontend/FrontendAction.cpp
parent505a5065af704c63c2c747458e7d997dd31ae35b (diff)
Teach CompilerInstance to create and hold on to the Sema object used
for parsing, so that it can persist beyond the lifetime of the parsing call. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110978 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/FrontendAction.cpp')
-rw-r--r--lib/Frontend/FrontendAction.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp
index 90b87864b8..40b4e7fa24 100644
--- a/lib/Frontend/FrontendAction.cpp
+++ b/lib/Frontend/FrontendAction.cpp
@@ -196,12 +196,16 @@ void FrontendAction::EndSourceFile() {
// FIXME: There is more per-file stuff we could just drop here?
if (CI.getFrontendOpts().DisableFree) {
CI.takeASTConsumer();
- if (!isCurrentFileAST())
+ if (!isCurrentFileAST()) {
+ CI.takeSema();
CI.takeASTContext();
+ }
} else {
- CI.setASTConsumer(0);
- if (!isCurrentFileAST())
+ if (!isCurrentFileAST()) {
+ CI.setSema(0);
CI.setASTContext(0);
+ }
+ CI.setASTConsumer(0);
}
// Inform the preprocessor we are done.
@@ -225,6 +229,7 @@ void FrontendAction::EndSourceFile() {
CI.getDiagnosticClient().EndSourceFile();
if (isCurrentFileAST()) {
+ CI.takeSema();
CI.takeASTContext();
CI.takePreprocessor();
CI.takeSourceManager();
@@ -253,9 +258,10 @@ void ASTFrontendAction::ExecuteAction() {
if (CI.hasCodeCompletionConsumer())
CompletionConsumer = &CI.getCodeCompletionConsumer();
- ParseAST(CI.getPreprocessor(), &CI.getASTConsumer(), CI.getASTContext(),
- CI.getFrontendOpts().ShowStats,
- usesCompleteTranslationUnit(), CompletionConsumer);
+ if (!CI.hasSema())
+ CI.createSema(usesCompleteTranslationUnit(), CompletionConsumer);
+
+ ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats);
}
ASTConsumer *