diff options
Diffstat (limited to 'lib/Serialization')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 10 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 24 | ||||
-rw-r--r-- | lib/Serialization/ChainedIncludesSource.cpp | 4 | ||||
-rw-r--r-- | lib/Serialization/GeneratePCH.cpp | 12 |
4 files changed, 22 insertions, 28 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 929db516ea..ecb24e730a 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1858,17 +1858,17 @@ void ASTReader::MaybeAddSystemRootToFilename(std::string &Filename) { if (Filename.empty() || llvm::sys::path::is_absolute(Filename)) return; - if (isysroot == 0) { + if (isysroot.empty()) { // If no system root was given, default to '/' Filename.insert(Filename.begin(), '/'); return; } - unsigned Length = strlen(isysroot); + unsigned Length = isysroot.size(); if (isysroot[Length - 1] != '/') Filename.insert(Filename.begin(), '/'); - Filename.insert(Filename.begin(), isysroot, isysroot + Length); + Filename.insert(Filename.begin(), isysroot.begin(), isysroot.end()); } ASTReader::ASTReadResult @@ -5265,7 +5265,7 @@ void ASTReader::FinishedDeserializing() { } ASTReader::ASTReader(Preprocessor &PP, ASTContext *Context, - const char *isysroot, bool DisableValidation, + StringRef isysroot, bool DisableValidation, bool DisableStatCache) : Listener(new PCHValidator(PP, *this)), DeserializationListener(0), SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()), @@ -5286,7 +5286,7 @@ ASTReader::ASTReader(Preprocessor &PP, ASTContext *Context, } ASTReader::ASTReader(SourceManager &SourceMgr, FileManager &FileMgr, - Diagnostic &Diags, const char *isysroot, + Diagnostic &Diags, StringRef isysroot, bool DisableValidation, bool DisableStatCache) : DeserializationListener(0), SourceMgr(SourceMgr), FileMgr(FileMgr), Diags(Diags), SemaObj(0), PP(0), Context(0), Consumer(0), FirstInSource(0), diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 65e0380f82..e291b7fd57 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -917,15 +917,15 @@ void ASTWriter::WriteBlockInfoBlock() { /// \returns either the original filename (if it needs no adjustment) or the /// adjusted filename (which points into the @p Filename parameter). static const char * -adjustFilenameForRelocatablePCH(const char *Filename, const char *isysroot) { +adjustFilenameForRelocatablePCH(const char *Filename, StringRef isysroot) { assert(Filename && "No file name to adjust?"); - if (!isysroot) + if (isysroot.empty()) return Filename; // Verify that the filename and the system root have the same prefix. unsigned Pos = 0; - for (; Filename[Pos] && isysroot[Pos]; ++Pos) + for (; Filename[Pos] && Pos < isysroot.size(); ++Pos) if (Filename[Pos] != isysroot[Pos]) return Filename; // Prefixes don't match. @@ -943,7 +943,7 @@ adjustFilenameForRelocatablePCH(const char *Filename, const char *isysroot) { } /// \brief Write the AST metadata (e.g., i686-apple-darwin9). -void ASTWriter::WriteMetadata(ASTContext &Context, const char *isysroot, +void ASTWriter::WriteMetadata(ASTContext &Context, StringRef isysroot, const std::string &OutputFile) { using namespace llvm; @@ -967,7 +967,7 @@ void ASTWriter::WriteMetadata(ASTContext &Context, const char *isysroot, Record.push_back(VERSION_MINOR); Record.push_back(CLANG_VERSION_MAJOR); Record.push_back(CLANG_VERSION_MINOR); - Record.push_back(isysroot != 0); + Record.push_back(!isysroot.empty()); // FIXME: This writes the absolute path for chained headers. const std::string &BlobStr = Chain ? Chain->getFileName() : Target.getTriple().getTriple(); Stream.EmitRecordWithBlob(MetaAbbrevCode, Record, BlobStr); @@ -1329,7 +1329,7 @@ namespace { /// \param HS The header search structure to save. /// /// \param Chain Whether we're creating a chained AST file. -void ASTWriter::WriteHeaderSearch(HeaderSearch &HS, const char* isysroot) { +void ASTWriter::WriteHeaderSearch(HeaderSearch &HS, StringRef isysroot) { llvm::SmallVector<const FileEntry *, 16> FilesByUID; HS.getFileMgr().GetUniqueIDMapping(FilesByUID); @@ -1405,7 +1405,7 @@ void ASTWriter::WriteHeaderSearch(HeaderSearch &HS, const char* isysroot) { /// the files in the AST. void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr, const Preprocessor &PP, - const char *isysroot) { + StringRef isysroot) { RecordData Record; // Enter the source manager block. @@ -2767,7 +2767,7 @@ ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream) void ASTWriter::WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls, const std::string &OutputFile, - const char *isysroot) { + StringRef isysroot) { // Emit the file header. Stream.Emit((unsigned)'C', 8); Stream.Emit((unsigned)'P', 8); @@ -2783,7 +2783,7 @@ void ASTWriter::WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls, } void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, - const char *isysroot, + StringRef isysroot, const std::string &OutputFile) { using namespace llvm; @@ -2908,7 +2908,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, Stream.EnterSubblock(AST_BLOCK_ID, 5); WriteMetadata(Context, isysroot, OutputFile); WriteLanguageOptions(Context.getLangOptions()); - if (StatCalls && !isysroot) + if (StatCalls && isysroot.empty()) WriteStatCache(*StatCalls); WriteSourceManagerBlock(Context.getSourceManager(), PP, isysroot); // Write the record of special types. @@ -3027,7 +3027,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, } void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, - const char *isysroot) { + StringRef isysroot) { using namespace llvm; ASTContext &Context = SemaRef.Context; @@ -3036,7 +3036,7 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, RecordData Record; Stream.EnterSubblock(AST_BLOCK_ID, 5); WriteMetadata(Context, isysroot, ""); - if (StatCalls && !isysroot) + if (StatCalls && isysroot.empty()) WriteStatCache(*StatCalls); // FIXME: Source manager block should only write new stuff, which could be // done by tracking the largest ID in the chain diff --git a/lib/Serialization/ChainedIncludesSource.cpp b/lib/Serialization/ChainedIncludesSource.cpp index 8337c7058e..a356dd6085 100644 --- a/lib/Serialization/ChainedIncludesSource.cpp +++ b/lib/Serialization/ChainedIncludesSource.cpp @@ -32,7 +32,7 @@ static ASTReader *createASTReader(CompilerInstance &CI, ASTDeserializationListener *deserialListener = 0) { Preprocessor &PP = CI.getPreprocessor(); llvm::OwningPtr<ASTReader> Reader; - Reader.reset(new ASTReader(PP, &CI.getASTContext(), /*isysroot=*/0, + Reader.reset(new ASTReader(PP, &CI.getASTContext(), /*isysroot=*/"", /*DisableValidation=*/true)); Reader->setASTMemoryBuffers(memBufs, numBufs); Reader->setDeserializationListener(deserialListener); @@ -103,7 +103,7 @@ ChainedIncludesSource *ChainedIncludesSource::create(CompilerInstance &CI) { llvm::OwningPtr<ASTConsumer> consumer; consumer.reset(new PCHGenerator(Clang->getPreprocessor(), "-", /*Chaining=*/!firstInclude, - /*isysroot=*/0, &OS)); + /*isysroot=*/"", &OS)); Clang->getASTContext().setASTMutationListener( consumer->GetASTMutationListener()); Clang->setASTConsumer(consumer.take()); diff --git a/lib/Serialization/GeneratePCH.cpp b/lib/Serialization/GeneratePCH.cpp index 9cd694e05c..16352c8e13 100644 --- a/lib/Serialization/GeneratePCH.cpp +++ b/lib/Serialization/GeneratePCH.cpp @@ -23,18 +23,16 @@ #include "llvm/Bitcode/BitstreamWriter.h" #include "llvm/Support/raw_ostream.h" #include <string> -#include <string.h> -#include <stdlib.h> using namespace clang; PCHGenerator::PCHGenerator(const Preprocessor &PP, const std::string &OutputFile, bool Chaining, - const char *isysroot, + StringRef isysroot, llvm::raw_ostream *OS) - : PP(PP), OutputFile(OutputFile), isysroot(0), Out(OS), SemaPtr(0), - StatCalls(0), Stream(Buffer), Writer(Stream), Chaining(Chaining) { + : PP(PP), OutputFile(OutputFile), isysroot(isysroot.str()), Out(OS), + SemaPtr(0), StatCalls(0), Stream(Buffer), Writer(Stream), Chaining(Chaining) { // Install a stat() listener to keep track of all of the stat() // calls. StatCalls = new MemorizeStatCalls(); @@ -42,13 +40,9 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP, // *after* the already installed ASTReader's stat cache. PP.getFileManager().addStatCache(StatCalls, /*AtBeginning=*/!Chaining); - - if (isysroot) - this->isysroot = strdup(isysroot); } PCHGenerator::~PCHGenerator() { - free((void*)isysroot); } void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) { |