From fd5e756ad033e792619ee57f9229b247084e2cae Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 30 Oct 2012 00:38:13 +0000 Subject: [PATCH] getOriginalSourceFileName and getOriginalSourceFile can return a StringRef. MaybeAddSystemRootToFilename doesn't need to return anything, it modifies its argument. llvm-svn: 166988 --- clang/include/clang/Frontend/ASTUnit.h | 2 +- clang/include/clang/Serialization/ASTReader.h | 4 ++-- clang/lib/Serialization/ASTReader.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index 065fc44..fc27bb9 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -467,7 +467,7 @@ public: const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; } - const std::string &getOriginalSourceFileName() { + const StringRef getOriginalSourceFileName() { return OriginalSourceFile; } diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 36eae76..c0d93c3 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -900,7 +900,7 @@ private: /// into account all the necessary relocations. const FileEntry *getFileEntry(StringRef filename); - StringRef MaybeAddSystemRootToFilename(ModuleFile &M, std::string &Filename); + void MaybeAddSystemRootToFilename(ModuleFile &M, std::string &Filename); ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type, ModuleFile *ImportedBy, @@ -1163,7 +1163,7 @@ public: /// \brief Retrieve the name of the original source file name for the primary /// module file. - const std::string &getOriginalSourceFile() { + StringRef getOriginalSourceFile() { return ModuleMgr.getPrimaryModule().OriginalSourceFileName; } diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 4857856..874d2c4 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1679,19 +1679,19 @@ const FileEntry *ASTReader::getFileEntry(StringRef filenameStrRef) { /// \brief If we are loading a relocatable PCH file, and the filename is /// not an absolute path, add the system root to the beginning of the file /// name. -StringRef ASTReader::MaybeAddSystemRootToFilename(ModuleFile &M, - std::string &Filename) { +void ASTReader::MaybeAddSystemRootToFilename(ModuleFile &M, + std::string &Filename) { // If this is not a relocatable PCH file, there's nothing to do. if (!M.RelocatablePCH) - return Filename; + return; if (Filename.empty() || llvm::sys::path::is_absolute(Filename)) - return Filename; + return; if (isysroot.empty()) { // If no system root was given, default to '/' Filename.insert(Filename.begin(), '/'); - return Filename; + return; } unsigned Length = isysroot.size(); @@ -1699,7 +1699,6 @@ StringRef ASTReader::MaybeAddSystemRootToFilename(ModuleFile &M, Filename.insert(Filename.begin(), '/'); Filename.insert(Filename.begin(), isysroot.begin(), isysroot.end()); - return Filename; } ASTReader::ASTReadResult -- 2.7.4