r183903 - Modernize some low-hanging PathV1 uses.
Rafael EspĂndola
rafael.espindola at gmail.com
Thu Jun 13 07:34:47 PDT 2013
Thanks!
On 13 June 2013 10:26, Benjamin Kramer <benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Thu Jun 13 09:26:04 2013
> New Revision: 183903
>
> URL: http://llvm.org/viewvc/llvm-project?rev=183903&view=rev
> Log:
> Modernize some low-hanging PathV1 uses.
>
> Modified:
> cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
> cfe/trunk/lib/Frontend/DependencyFile.cpp
> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
>
> Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=183903&r1=183902&r2=183903&view=diff
> ==============================================================================
> --- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original)
> +++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Thu Jun 13 09:26:04 2013
> @@ -14,7 +14,6 @@
> #include "llvm/Support/FileSystem.h"
> #include "llvm/Support/MemoryBuffer.h"
> #include "llvm/Support/Path.h"
> -#include "llvm/Support/PathV1.h"
> #include "llvm/Support/raw_ostream.h"
> #include <fstream>
>
> @@ -44,10 +43,9 @@ void FileRemapper::clear(StringRef outpu
>
> std::string FileRemapper::getRemapInfoFile(StringRef outputDir) {
> assert(!outputDir.empty());
> - llvm::sys::Path dir(outputDir);
> - llvm::sys::Path infoFile = dir;
> - infoFile.appendComponent("remap");
> - return infoFile.str();
> + SmallString<128> InfoFile = outputDir;
> + llvm::sys::path::append(InfoFile, "remap");
> + return InfoFile.str();
> }
>
> bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag,
>
> Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=183903&r1=183902&r2=183903&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
> +++ cfe/trunk/lib/Frontend/DependencyFile.cpp Thu Jun 13 09:26:04 2013
> @@ -21,8 +21,8 @@
> #include "clang/Lex/PPCallbacks.h"
> #include "clang/Lex/Preprocessor.h"
> #include "llvm/ADT/StringSet.h"
> +#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/Path.h"
> -#include "llvm/Support/PathV1.h"
> #include "llvm/Support/raw_ostream.h"
>
> using namespace clang;
> @@ -166,7 +166,8 @@ static void PrintFilename(raw_ostream &O
>
> void DependencyFileCallback::OutputDependencyFile() {
> if (SeenMissingHeader) {
> - llvm::sys::Path(OutputFile).eraseFromDisk();
> + bool existed;
> + llvm::sys::fs::remove(OutputFile, existed);
> return;
> }
>
>
> Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=183903&r1=183902&r2=183903&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Thu Jun 13 09:26:04 2013
> @@ -26,7 +26,6 @@
> #include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/FileSystem.h"
> #include "llvm/Support/Path.h"
> -#include "llvm/Support/PathV1.h"
> #include "llvm/Support/raw_ostream.h"
>
> using namespace clang;
> @@ -245,8 +244,8 @@ void InitHeaderSearch::AddDefaultCInclud
> if (HSOpts.UseBuiltinIncludes) {
> // Ignore the sys root, we *always* look for clang headers relative to
> // supplied path.
> - llvm::sys::Path P(HSOpts.ResourceDir);
> - P.appendComponent("include");
> + SmallString<128> P = StringRef(HSOpts.ResourceDir);
> + llvm::sys::path::append(P, "include");
> AddUnmappedPath(P.str(), ExternCSystem, false);
> }
>
> @@ -313,15 +312,20 @@ void InitHeaderSearch::AddDefaultCInclud
> break;
> case llvm::Triple::MinGW32: {
> // mingw-w64 crt include paths
> - llvm::sys::Path P(HSOpts.ResourceDir);
> - P.appendComponent("../../../i686-w64-mingw32/include"); // <sysroot>/i686-w64-mingw32/include
> + // <sysroot>/i686-w64-mingw32/include
> + SmallString<128> P = StringRef(HSOpts.ResourceDir);
> + llvm::sys::path::append(P, "../../../i686-w64-mingw32/include");
> AddPath(P.str(), System, false);
> - P = llvm::sys::Path(HSOpts.ResourceDir);
> - P.appendComponent("../../../x86_64-w64-mingw32/include"); // <sysroot>/x86_64-w64-mingw32/include
> +
> + // <sysroot>/x86_64-w64-mingw32/include
> + P.resize(HSOpts.ResourceDir.size());
> + llvm::sys::path::append(P, "../../../x86_64-w64-mingw32/include");
> AddPath(P.str(), System, false);
> +
> // mingw.org crt include paths
> - P = llvm::sys::Path(HSOpts.ResourceDir);
> - P.appendComponent("../../../include"); // <sysroot>/include
> + // <sysroot>/include
> + P.resize(HSOpts.ResourceDir.size());
> + llvm::sys::path::append(P, "../../../include");
> AddPath(P.str(), System, false);
> AddPath("/mingw/include", System, false);
> #if defined(_WIN32)
> @@ -470,14 +474,14 @@ void InitHeaderSearch::AddDefaultInclude
> if (triple.isOSDarwin()) {
> // On Darwin, libc++ may be installed alongside the compiler in
> // lib/c++/v1.
> - llvm::sys::Path P(HSOpts.ResourceDir);
> - if (!P.isEmpty()) {
> - P.eraseComponent(); // Remove version from foo/lib/clang/version
> - P.eraseComponent(); // Remove clang from foo/lib/clang
> + if (!HSOpts.ResourceDir.empty()) {
> + // Remove version from foo/lib/clang/version
> + StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
> + // Remove clang from foo/lib/clang
> + SmallString<128> P = llvm::sys::path::parent_path(NoVer);
>
> // Get foo/lib/c++/v1
> - P.appendComponent("c++");
> - P.appendComponent("v1");
> + llvm::sys::path::append(P, "c++", "v1");
> AddUnmappedPath(P.str(), CXXSystem, false);
> }
> }
> @@ -687,8 +691,8 @@ void clang::ApplyHeaderSearchOptions(Hea
>
> if (HSOpts.UseBuiltinIncludes) {
> // Set up the builtin include directory in the module map.
> - llvm::sys::Path P(HSOpts.ResourceDir);
> - P.appendComponent("include");
> + SmallString<128> P = StringRef(HSOpts.ResourceDir);
> + llvm::sys::path::append(P, "include");
> if (const DirectoryEntry *Dir = HS.getFileMgr().getDirectory(P.str()))
> HS.getModuleMap().setBuiltinIncludeDir(Dir);
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list