diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -50,6 +50,9 @@ using namespace clang; using namespace llvm; +static llvm::cl::opt ClearASTBeforeBackend("clear-clang-ast", + llvm::cl::init(true)); + namespace clang { class BackendConsumer; class ClangDiagnosticHandler final : public DiagnosticHandler { @@ -120,6 +123,7 @@ bool IRGenFinished = false; bool TimerIsEnabled = false; + bool ASTCleared = false; std::unique_ptr Gen; @@ -329,6 +333,13 @@ if (LinkInModules()) return; + // FIXME: Fix cleanup issues with clearing the AST when we properly free + // things. + if (CodeGenOpts.DisableFree && ClearASTBeforeBackend) { + Context->getAllocator().Reset(); + ASTCleared = true; + } + EmbedBitcode(getModule(), CodeGenOpts, llvm::MemoryBufferRef()); EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts, @@ -568,6 +579,7 @@ // We do not know how to format other severities. return false; + // FIXME if (const Decl *ND = Gen->GetDeclForMangledName(D.getFunction().getName())) { // FIXME: Shouldn't need to truncate to uint32_t Diags.Report(ND->getASTContext().getFullLoc(ND->getLocation()), @@ -607,7 +619,7 @@ // function definition. We use the definition's right brace to differentiate // from diagnostics that genuinely relate to the function itself. FullSourceLoc Loc(DILoc, SourceMgr); - if (Loc.isInvalid()) + if (Loc.isInvalid() && !ASTCleared) if (const Decl *FD = Gen->GetDeclForMangledName(D.getFunction().getName())) Loc = FD->getASTContext().getFullLoc(FD->getLocation()); diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -182,6 +182,7 @@ llvm::Expected> Interpreter::create(std::unique_ptr CI) { llvm::Error Err = llvm::Error::success(); + CI->getCodeGenOpts().DisableFree = false; auto Interp = std::unique_ptr(new Interpreter(std::move(CI), Err)); if (Err) diff --git a/clang/test/Frontend/optimization-remark-analysis.c b/clang/test/Frontend/optimization-remark-analysis.c --- a/clang/test/Frontend/optimization-remark-analysis.c +++ b/clang/test/Frontend/optimization-remark-analysis.c @@ -1,8 +1,8 @@ -// RUN: %clang -O1 -fvectorize -target x86_64-unknown-unknown -emit-llvm -Rpass-analysis -S %s -o - 2>&1 | FileCheck %s --check-prefix=RPASS -// RUN: %clang -O1 -fvectorize -target x86_64-unknown-unknown -emit-llvm -S %s -o - 2>&1 | FileCheck %s +// RUN: %clang -O1 -g2 -fvectorize -target x86_64-unknown-unknown -emit-llvm -Rpass-analysis -S %s -o - 2>&1 | FileCheck %s --check-prefix=RPASS +// RUN: %clang -O1 -g2 -fvectorize -target x86_64-unknown-unknown -emit-llvm -S %s -o - 2>&1 | FileCheck %s -// RPASS: {{.*}}:7:8: remark: loop not vectorized: loop contains a switch statement -// CHECK-NOT: {{.*}}:7:8: remark: loop not vectorized: loop contains a switch statement +// RPASS: {{.*}}:12:5: remark: loop not vectorized: loop contains a switch statement +// CHECK-NOT: {{.*}}:12:5: remark: loop not vectorized: loop contains a switch statement double foo(int N, int *Array) { double v = 0.0; diff --git a/clang/test/Misc/backend-stack-frame-diagnostics.cpp b/clang/test/Misc/backend-stack-frame-diagnostics.cpp --- a/clang/test/Misc/backend-stack-frame-diagnostics.cpp +++ b/clang/test/Misc/backend-stack-frame-diagnostics.cpp @@ -1,3 +1,5 @@ +// FIXME + // REQUIRES: x86-registered-target // RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks -Wframe-larger-than=70 -Wno-stdlibcxx-not-found -Xclang -verify -o /dev/null -c %s // RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks -Wframe-larger-than=70 -Wno-stdlibcxx-not-found -Xclang -verify -o /dev/null -c %s -DIS_SYSHEADER