Skip to content

Commit

Permalink
Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230454 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
adrian-prantl committed Feb 25, 2015
1 parent d68bbb9 commit 9f65c56
Show file tree
Hide file tree
Showing 83 changed files with 91 additions and 456 deletions.
3 changes: 0 additions & 3 deletions docs/PCHInternals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ be included at the beginning of the translation unit. The extensions to the
AST file format required for modules are discussed in the section on
:ref:`modules <pchinternals-modules>`.

Clang's AST files are Mach-O, ELF, or COFF containers that contain a
``__clangast`` section which holds the AST bitstream.

Clang's AST files are designed with a compact on-disk representation, which
minimizes both creation time and the time required to initially load the AST
file. The AST file itself contains a serialized representation of Clang's
Expand Down
34 changes: 0 additions & 34 deletions include/clang/CodeGen/CodeGenModuleContainer.h

This file was deleted.

8 changes: 0 additions & 8 deletions include/clang/Frontend/FrontendActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ class DeclContextPrintAction : public ASTFrontendAction {
StringRef InFile) override;
};

/// \brief Emits the output of a GeneratePCHAction or GenerateModuleAction into
/// a Mach-O/ELF/COFF container.
class GeneratePCMContainerAction : public FrontendAction {
protected:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override;
};

class GeneratePCHAction : public ASTFrontendAction {
protected:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
Expand Down
4 changes: 0 additions & 4 deletions include/clang/Serialization/ASTReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -1127,10 +1127,6 @@ class ASTReader
public:
void ResolveImportedPath(ModuleFile &M, std::string &Filename);
static void ResolveImportedPath(std::string &Filename, StringRef Prefix);
/// \brief Initialize a BitstreamReader with the `__clangast` section from an
/// object file container found in Buffer.
static void InitStreamFileWithModule(llvm::MemoryBufferRef Buffer,
llvm::BitstreamReader &StreamFile);

private:
struct ImportedModule {
Expand Down
18 changes: 5 additions & 13 deletions include/clang/Serialization/ASTWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,10 @@ class PCHGenerator : public SemaConsumer {
std::string OutputFile;
clang::Module *Module;
std::string isysroot;
raw_ostream *Out;
Sema *SemaPtr;
// This buffer is always large, but BitstreamWriter really wants a
// SmallVectorImpl<char>.
SmallVector<char, 0> Buffer;
SmallVector<char, 128> Buffer;
llvm::BitstreamWriter Stream;
std::function<void(SmallVectorImpl<char>*)>
SerializationFinishedCallback;
ASTWriter Writer;
bool AllowASTWithErrors;
bool HasEmittedPCH;
Expand All @@ -839,21 +836,16 @@ class PCHGenerator : public SemaConsumer {
const ASTWriter &getWriter() const { return Writer; }

public:
PCHGenerator(const Preprocessor &PP,
StringRef OutputFile,
PCHGenerator(const Preprocessor &PP, StringRef OutputFile,
clang::Module *Module,
StringRef isysroot,
StringRef isysroot, raw_ostream *Out,
bool AllowASTWithErrors = false);
~PCHGenerator();
void InitializeSema(Sema &S) override { SemaPtr = &S; }
void HandleTranslationUnit(ASTContext &Ctx) override;
ASTMutationListener *GetASTMutationListener() override;
ASTDeserializationListener *GetASTDeserializationListener() override;
/// \brief Register a callback to be invoked when the serialization is done.
void RegisterSerializationFinishedCallback(
const std::function<void(SmallVectorImpl<char>*)> Fn) {
SerializationFinishedCallback = Fn;
}

bool hasEmittedPCH() const { return HasEmittedPCH; }
};

Expand Down
2 changes: 0 additions & 2 deletions lib/CodeGen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Analysis
BitReader
BitWriter
Expand Down Expand Up @@ -64,7 +63,6 @@ add_clang_library(clangCodeGen
CodeGenAction.cpp
CodeGenFunction.cpp
CodeGenModule.cpp
CodeGenModuleContainer.cpp
CodeGenPGO.cpp
CodeGenTBAA.cpp
CodeGenTypes.cpp
Expand Down
150 changes: 0 additions & 150 deletions lib/CodeGen/CodeGenModuleContainer.cpp

This file was deleted.

18 changes: 2 additions & 16 deletions lib/Frontend/ASTUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,20 +914,13 @@ class PrecompilePreambleConsumer : public PCHGenerator {
unsigned &Hash;
std::vector<Decl *> TopLevelDecls;
PrecompilePreambleAction *Action;
raw_ostream *Out;
SmallVectorImpl<char> *SerializedASTBuffer;

public:
PrecompilePreambleConsumer(ASTUnit &Unit, PrecompilePreambleAction *Action,
const Preprocessor &PP, StringRef isysroot,
raw_ostream *Out)
: PCHGenerator(PP, "", nullptr, isysroot, /*AllowASTWithErrors=*/true),
Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()), Action(Action),
Out(Out) {
RegisterSerializationFinishedCallback(
[&](SmallVectorImpl<char> *Buf){
SerializedASTBuffer = Buf;
});
: PCHGenerator(PP, "", nullptr, isysroot, Out, /*AllowASTWithErrors=*/true),
Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()), Action(Action) {
Hash = 0;
}

Expand All @@ -948,13 +941,6 @@ class PrecompilePreambleConsumer : public PCHGenerator {
void HandleTranslationUnit(ASTContext &Ctx) override {
PCHGenerator::HandleTranslationUnit(Ctx);
if (hasEmittedPCH()) {
// Write the generated bitstream to "Out".
Out->write((char *)&SerializedASTBuffer->front(),
SerializedASTBuffer->size());
// Make sure it hits disk now.
Out->flush();
SerializedASTBuffer->clear();

// Translate the top-level declarations we captured during
// parsing into declaration IDs in the precompiled
// preamble. This will allow us to deserialize those top-level
Expand Down
1 change: 0 additions & 1 deletion lib/Frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ add_clang_library(clangFrontend
LINK_LIBS
clangAST
clangBasic
clangCodeGen
clangDriver
clangEdit
clangLex
Expand Down
16 changes: 6 additions & 10 deletions lib/Frontend/ChainedIncludesSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
&Clang->getPreprocessor());
Clang->createASTContext();

auto consumer = llvm::make_unique<PCHGenerator>(Clang->getPreprocessor(),
"-", nullptr, /*isysroot=*/"");
SmallVectorImpl<char> *serialAST;
consumer->RegisterSerializationFinishedCallback(
[&](SmallVectorImpl<char> *Buf){
serialAST = Buf;
});
SmallVector<char, 256> serialAST;
llvm::raw_svector_ostream OS(serialAST);
auto consumer =
llvm::make_unique<PCHGenerator>(Clang->getPreprocessor(), "-", nullptr,
/*isysroot=*/"", &OS);
Clang->getASTContext().setASTMutationListener(
consumer->GetASTMutationListener());
Clang->setASTConsumer(std::move(consumer));
Expand Down Expand Up @@ -199,9 +197,7 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(

ParseAST(Clang->getSema());
Clang->getDiagnosticClient().EndSourceFile();
SerialBufs.push_back(llvm::MemoryBuffer::
getMemBufferCopy(StringRef(serialAST->data(), serialAST->size())));
serialAST->clear();
SerialBufs.push_back(llvm::MemoryBuffer::getMemBufferCopy(OS.str()));
source->CIs.push_back(Clang.release());
}

Expand Down
Loading

0 comments on commit 9f65c56

Please sign in to comment.