aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-19 20:40:48 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-19 20:40:48 +0000
commit92ddef1bf843e1e18c040d69f48a6bf0bc7c776a (patch)
tree13be5d9d6b1809b8d7636181fce03dd5c20086ab /lib
parentb6441ef9b7285bd1aa77b05b10f473f7a3f413e7 (diff)
In libclang, when visiting preprocessed entities in a source range, use
PreprocessingRecord's getPreprocessedEntitiesInRange. Also remove all the stuff that were added in ASTUnit that are unnecessary now that we do a binary search for preprocessed entities and deserialize only what is necessary. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Frontend/ASTUnit.cpp62
-rw-r--r--lib/Serialization/ASTReader.cpp10
-rw-r--r--lib/Serialization/ASTWriter.cpp17
-rw-r--r--lib/Serialization/GeneratePCH.cpp7
4 files changed, 2 insertions, 94 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 60e1c3bab6..19b8ccb4c3 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -29,7 +29,6 @@
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Frontend/Utils.h"
#include "clang/Serialization/ASTReader.h"
-#include "clang/Serialization/ASTSerializationListener.h"
#include "clang/Serialization/ASTWriter.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
@@ -775,8 +774,7 @@ public:
}
};
-class PrecompilePreambleConsumer : public PCHGenerator,
- public ASTSerializationListener {
+class PrecompilePreambleConsumer : public PCHGenerator {
ASTUnit &Unit;
unsigned &Hash;
std::vector<Decl *> TopLevelDecls;
@@ -815,15 +813,6 @@ public:
getWriter().getDeclID(TopLevelDecls[I]));
}
}
-
- virtual void SerializedPreprocessedEntity(PreprocessedEntity *Entity,
- uint64_t Offset) {
- Unit.addPreprocessedEntityFromPreamble(Offset);
- }
-
- virtual ASTSerializationListener *GetASTSerializationListener() {
- return this;
- }
};
class PrecompilePreambleAction : public ASTFrontendAction {
@@ -922,16 +911,13 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
// Clear out old caches and data.
TopLevelDecls.clear();
- PreprocessedEntities.clear();
CleanTemporaryFiles();
- PreprocessedEntitiesByFile.clear();
if (!OverrideMainBuffer) {
StoredDiagnostics.erase(
StoredDiagnostics.begin() + NumStoredDiagnosticsFromDriver,
StoredDiagnostics.end());
TopLevelDeclsInPreamble.clear();
- PreprocessedEntitiesInPreamble.clear();
}
// Create a file manager object to provide access to and cache the filesystem.
@@ -1407,8 +1393,6 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
StoredDiagnostics.end());
TopLevelDecls.clear();
TopLevelDeclsInPreamble.clear();
- PreprocessedEntities.clear();
- PreprocessedEntitiesInPreamble.clear();
// Create a file manager object to provide access to and cache the filesystem.
Clang->setFileManager(new FileManager(Clang->getFileSystemOpts()));
@@ -1439,8 +1423,6 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
llvm::sys::Path(FrontendOpts.OutputFile).eraseFromDisk();
Preamble.clear();
TopLevelDeclsInPreamble.clear();
- PreprocessedEntities.clear();
- PreprocessedEntitiesInPreamble.clear();
PreambleRebuildCounter = DefaultPreambleRebuildInterval;
PreprocessorOpts.eraseRemappedFile(
PreprocessorOpts.remapped_file_buffer_end() - 1);
@@ -1511,48 +1493,6 @@ void ASTUnit::RealizeTopLevelDeclsFromPreamble() {
TopLevelDecls.insert(TopLevelDecls.begin(), Resolved.begin(), Resolved.end());
}
-void ASTUnit::RealizePreprocessedEntitiesFromPreamble() {
- if (!PP)
- return;
-
- PreprocessingRecord *PPRec = PP->getPreprocessingRecord();
- if (!PPRec)
- return;
-
- ExternalPreprocessingRecordSource *External = PPRec->getExternalSource();
- if (!External)
- return;
-
- for (unsigned I = 0, N = PreprocessedEntitiesInPreamble.size(); I != N; ++I) {
- if (PreprocessedEntity *PE
- = External->ReadPreprocessedEntityAtOffset(
- PreprocessedEntitiesInPreamble[I]))
- PreprocessedEntities.push_back(PE);
- }
-
- if (PreprocessedEntities.empty())
- return;
-
- PreprocessedEntities.insert(PreprocessedEntities.end(),
- PPRec->local_begin(), PPRec->local_end());
-}
-
-ASTUnit::pp_entity_iterator ASTUnit::pp_entity_begin() {
- if (!PreprocessedEntitiesInPreamble.empty() &&
- PreprocessedEntities.empty())
- RealizePreprocessedEntitiesFromPreamble();
-
- return PreprocessedEntities.begin();
-}
-
-ASTUnit::pp_entity_iterator ASTUnit::pp_entity_end() {
- if (!PreprocessedEntitiesInPreamble.empty() &&
- PreprocessedEntities.empty())
- RealizePreprocessedEntitiesFromPreamble();
-
- return PreprocessedEntities.end();
-}
-
StringRef ASTUnit::getMainFileName() const {
return Invocation->getFrontendOpts().Inputs[0].second;
}
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 02d7eeaa8d..25b86876b3 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -2999,16 +2999,6 @@ std::pair<unsigned, unsigned>
return std::make_pair(BeginID, EndID);
}
-PreprocessedEntity *ASTReader::ReadPreprocessedEntityAtOffset(uint64_t Offset) {
- RecordLocation Loc = getLocalBitOffset(Offset);
-
- // Keep track of where we are in the stream, then jump back there
- // after reading this entity.
- SavedStreamPosition SavedPosition(Loc.F->PreprocessorDetailCursor);
- Loc.F->PreprocessorDetailCursor.JumpToBit(Loc.Offset);
- return LoadPreprocessedEntity(*Loc.F);
-}
-
namespace {
/// \brief Visitor used to search for information about a header file.
class HeaderFileInfoVisitor {
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index ac961c78f9..2aa1e6c4e3 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "clang/Serialization/ASTWriter.h"
-#include "clang/Serialization/ASTSerializationListener.h"
#include "ASTCommon.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/IdentifierResolver.h"
@@ -1743,7 +1742,6 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
+ NUM_PREDEF_PP_ENTITY_IDS;
unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
RecordData Record;
- uint64_t BitsInChain = Chain? Chain->TotalModulesSizeInBits : 0;
for (PreprocessingRecord::iterator E = PPRec.local_begin(),
EEnd = PPRec.local_end();
E != EEnd;
@@ -1757,11 +1755,6 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
// Record this macro definition's ID.
MacroDefinitions[MD] = NextPreprocessorEntityID;
- // Notify the serialization listener that we're serializing this entity.
- if (SerializationListener)
- SerializationListener->SerializedPreprocessedEntity(*E,
- BitsInChain + Stream.GetCurrentBitNo());
-
Record.push_back(NextPreprocessorEntityID);
AddSourceLocation(MD->getSourceRange().getBegin(), Record);
AddSourceLocation(MD->getSourceRange().getEnd(), Record);
@@ -1771,11 +1764,6 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
continue;
}
- // Notify the serialization listener that we're serializing this entity.
- if (SerializationListener)
- SerializationListener->SerializedPreprocessedEntity(*E,
- BitsInChain + Stream.GetCurrentBitNo());
-
if (MacroExpansion *ME = dyn_cast<MacroExpansion>(*E)) {
Record.push_back(NextPreprocessorEntityID);
AddSourceLocation(ME->getSourceRange().getBegin(), Record);
@@ -2719,8 +2707,7 @@ void ASTWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) {
}
ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream)
- : Stream(Stream), Context(0), Chain(0), SerializationListener(0),
- WritingAST(false),
+ : Stream(Stream), Context(0), Chain(0), WritingAST(false),
FirstDeclID(NUM_PREDEF_DECL_IDS), NextDeclID(FirstDeclID),
FirstTypeID(NUM_PREDEF_TYPE_IDS), NextTypeID(FirstTypeID),
FirstIdentID(NUM_PREDEF_IDENT_IDS), NextIdentID(FirstIdentID),
@@ -4045,5 +4032,3 @@ void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
ChainedObjCCategoriesData Data = { IFD, CatD, 0, 0 };
LocalChainedObjCCategories.push_back(Data);
}
-
-ASTSerializationListener::~ASTSerializationListener() { }
diff --git a/lib/Serialization/GeneratePCH.cpp b/lib/Serialization/GeneratePCH.cpp
index 25fac8b7a8..a2534db82c 100644
--- a/lib/Serialization/GeneratePCH.cpp
+++ b/lib/Serialization/GeneratePCH.cpp
@@ -46,9 +46,6 @@ PCHGenerator::~PCHGenerator() {
void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
if (PP.getDiagnostics().hasErrorOccurred())
return;
-
- // Set up the serialization listener.
- Writer.SetSerializationListener(GetASTSerializationListener());
// Emit the PCH file
assert(SemaPtr && "No Sema?");
@@ -68,10 +65,6 @@ ASTMutationListener *PCHGenerator::GetASTMutationListener() {
return &Writer;
}
-ASTSerializationListener *PCHGenerator::GetASTSerializationListener() {
- return 0;
-}
-
ASTDeserializationListener *PCHGenerator::GetASTDeserializationListener() {
return &Writer;
}