summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-02-24 04:25:59 +0000
committerAdrian Prantl <aprantl@apple.com>2015-02-24 04:25:59 +0000
commitfc360dc30be41b7ea941ae39fd8a847b6e0263c5 (patch)
treea1ff1d6476ea33713c9ed4d5e18575690322f9d5 /clang/lib/Frontend/FrontendActions.cpp
parentc109102ecb80c06375688d374fdc17c04cd7d562 (diff)
downloadbcm5719-llvm-fc360dc30be41b7ea941ae39fd8a847b6e0263c5.tar.gz
bcm5719-llvm-fc360dc30be41b7ea941ae39fd8a847b6e0263c5.zip
Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 3. llvm-svn: 230305
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index a55a3257851..3e0f525e653 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -10,10 +10,13 @@
#include "clang/Frontend/FrontendActions.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/CodeGen/CodeGenModuleContainer.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/MultiplexConsumer.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Pragma.h"
@@ -85,8 +88,23 @@ GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
if (!CI.getFrontendOpts().RelocatablePCH)
Sysroot.clear();
- return llvm::make_unique<PCHGenerator>(CI.getPreprocessor(), OutputFile,
- nullptr, Sysroot, OS);
+
+ std::vector<std::unique_ptr<ASTConsumer>> Consumers;
+ Consumers.push_back(llvm::make_unique<PCHGenerator>(CI.getPreprocessor(),
+ OutputFile, nullptr,
+ Sysroot));
+
+ auto CGOpts = CI.getCodeGenOpts();
+ // The debug info emitted by ModuleContainerGenerator is not affected by the
+ // optimization level.
+ CGOpts.OptimizationLevel = 0;
+ CGOpts.setDebugInfo(CodeGenOptions::LimitedDebugInfo);
+ Consumers.push_back(std::unique_ptr<ASTConsumer>(
+ CreateModuleContainerGenerator(CI.getDiagnostics(), "PCH", CGOpts,
+ CI.getTargetOpts(), CI.getLangOpts(), OS,
+ cast<PCHGenerator>(Consumers[0].get()))));
+
+ return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
}
bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI,
@@ -122,8 +140,22 @@ GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS))
return nullptr;
- return llvm::make_unique<PCHGenerator>(CI.getPreprocessor(), OutputFile,
- Module, Sysroot, OS);
+ std::vector<std::unique_ptr<ASTConsumer>> Consumers;
+ Consumers.push_back(llvm::make_unique<PCHGenerator>(CI.getPreprocessor(),
+ OutputFile, Module,
+ Sysroot));
+
+ auto CGOpts = CI.getCodeGenOpts();
+ // The debug info emitted by ModuleContainerGenerator is not affected by the
+ // optimization level.
+ CGOpts.OptimizationLevel = 0;
+ CGOpts.setDebugInfo(CodeGenOptions::LimitedDebugInfo);
+ Consumers.push_back(
+ std::unique_ptr<ASTConsumer>(CreateModuleContainerGenerator(
+ CI.getDiagnostics(), Module->getFullModuleName(), CGOpts,
+ CI.getTargetOpts(), CI.getLangOpts(), OS,
+ cast<PCHGenerator>(Consumers[0].get()))));
+ return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
}
static SmallVectorImpl<char> &
OpenPOWER on IntegriCloud