Skip to content

Commit

Permalink
Rename ModuleContainerGenerator to PCHContainergenerator for consistency
Browse files Browse the repository at this point in the history
and re-clang-format (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241841 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
adrian-prantl committed Jul 9, 2015
1 parent 9b5c02e commit fe95d3d
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions lib/CodeGen/ObjectFilePCHContainerOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using namespace clang;
#define DEBUG_TYPE "pchcontainer"

namespace {
class ModuleContainerGenerator : public ASTConsumer {
class PCHContainerGenerator : public ASTConsumer {
DiagnosticsEngine &Diags;
const std::string MainFileName;
ASTContext *Ctx;
Expand All @@ -51,15 +51,15 @@ class ModuleContainerGenerator : public ASTConsumer {
std::shared_ptr<PCHBuffer> Buffer;

public:
ModuleContainerGenerator(
DiagnosticsEngine &diags,
const HeaderSearchOptions &HSO, const PreprocessorOptions &PPO,
const TargetOptions &TO, const LangOptions &LO,
const std::string &MainFileName, const std::string &OutputFileName,
raw_pwrite_stream *OS, std::shared_ptr<PCHBuffer> Buffer)
: Diags(diags), HeaderSearchOpts(HSO), PreprocessorOpts(PPO),
TargetOpts(TO), LangOpts(LO), OS(OS),
Buffer(Buffer) {
PCHContainerGenerator(DiagnosticsEngine &diags,
const HeaderSearchOptions &HSO,
const PreprocessorOptions &PPO, const TargetOptions &TO,
const LangOptions &LO, const std::string &MainFileName,
const std::string &OutputFileName,
raw_pwrite_stream *OS,
std::shared_ptr<PCHBuffer> Buffer)
: Diags(diags), HeaderSearchOpts(HSO), PreprocessorOpts(PPO),
TargetOpts(TO), LangOpts(LO), OS(OS), Buffer(Buffer) {
// The debug info output isn't affected by CodeModel and
// ThreadModel, but the backend expects them to be nonempty.
CodeGenOpts.CodeModel = "default";
Expand All @@ -68,16 +68,16 @@ class ModuleContainerGenerator : public ASTConsumer {
CodeGenOpts.SplitDwarfFile = OutputFileName;
}

virtual ~ModuleContainerGenerator() {}
virtual ~PCHContainerGenerator() {}

void Initialize(ASTContext &Context) override {
Ctx = &Context;
VMContext.reset(new llvm::LLVMContext());
M.reset(new llvm::Module(MainFileName, *VMContext));
M->setDataLayout(Ctx->getTargetInfo().getTargetDescription());
Builder.reset(new CodeGen::CodeGenModule(*Ctx, HeaderSearchOpts,
PreprocessorOpts, CodeGenOpts,
*M, M->getDataLayout(), Diags));
PreprocessorOpts, CodeGenOpts, *M,
M->getDataLayout(), Diags));
}

/// Emit a container holding the serialized AST.
Expand Down Expand Up @@ -110,9 +110,9 @@ class ModuleContainerGenerator : public ASTConsumer {
auto Size = SerializedAST.size();
auto Int8Ty = llvm::Type::getInt8Ty(*VMContext);
auto *Ty = llvm::ArrayType::get(Int8Ty, Size);
auto *Data = llvm::ConstantDataArray::
getString(*VMContext, StringRef(SerializedAST.data(), Size),
/*AddNull=*/false);
auto *Data = llvm::ConstantDataArray::getString(
*VMContext, StringRef(SerializedAST.data(), Size),
/*AddNull=*/false);
auto *ASTSym = new llvm::GlobalVariable(
*M, Ty, /*constant*/ true, llvm::GlobalVariable::InternalLinkage, Data,
"__clang_ast");
Expand All @@ -129,15 +129,15 @@ class ModuleContainerGenerator : public ASTConsumer {
ASTSym->setSection("__clangast");

DEBUG({
// Print the IR for the PCH container to the debug output.
llvm::SmallString<0> Buffer;
llvm::raw_svector_ostream OS(Buffer);
clang::EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
Ctx.getTargetInfo().getTargetDescription(),
M.get(), BackendAction::Backend_EmitLL, &OS);
OS.flush();
llvm::dbgs()<<Buffer;
});
// Print the IR for the PCH container to the debug output.
llvm::SmallString<0> Buffer;
llvm::raw_svector_ostream OS(Buffer);
clang::EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
Ctx.getTargetInfo().getTargetDescription(),
M.get(), BackendAction::Backend_EmitLL, &OS);
OS.flush();
llvm::dbgs() << Buffer;
});

// Use the LLVM backend to emit the pch container.
clang::EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
Expand All @@ -152,7 +152,8 @@ class ModuleContainerGenerator : public ASTConsumer {
SerializedAST = std::move(Empty);
}
};
}

} // namespace

std::unique_ptr<ASTConsumer>
ObjectFilePCHContainerOperations::CreatePCHContainerGenerator(
Expand All @@ -161,8 +162,8 @@ ObjectFilePCHContainerOperations::CreatePCHContainerGenerator(
const LangOptions &LO, const std::string &MainFileName,
const std::string &OutputFileName, llvm::raw_pwrite_stream *OS,
std::shared_ptr<PCHBuffer> Buffer) const {
return llvm::make_unique<ModuleContainerGenerator>
(Diags, HSO, PPO, TO, LO, MainFileName, OutputFileName, OS, Buffer);
return llvm::make_unique<PCHContainerGenerator>(
Diags, HSO, PPO, TO, LO, MainFileName, OutputFileName, OS, Buffer);
}

void ObjectFilePCHContainerOperations::ExtractPCH(
Expand Down

0 comments on commit fe95d3d

Please sign in to comment.