summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorDouglas Katzman <dougk@google.com>2015-06-24 15:10:30 +0000
committerDouglas Katzman <dougk@google.com>2015-06-24 15:10:30 +0000
commit26eabf6d0f8aca2a59777dba5d929270a346aa17 (patch)
tree07205c881e6739473bf790e248199eb482ed168d /clang/lib/Driver/Driver.cpp
parentd68fb74c2b7b46f3c01a6239c10790395b6308ff (diff)
downloadbcm5719-llvm-26eabf6d0f8aca2a59777dba5d929270a346aa17.tar.gz
bcm5719-llvm-26eabf6d0f8aca2a59777dba5d929270a346aa17.zip
Express Driver::GetFilePath more concisely.
llvm-svn: 240545
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 50449611184..5db5a13f377 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -756,7 +756,7 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
llvm::outs() << ':';
// Interpretation of leading '=' is needed only for NetBSD.
if (Path[0] == '=')
- llvm::outs() << sysroot << (Path.c_str() + 1);
+ llvm::outs() << sysroot << Path.substr(1);
else
llvm::outs() << Path;
}
@@ -1835,14 +1835,10 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const {
// Respect a limited subset of the '-Bprefix' functionality in GCC by
// attempting to use this prefix when looking for file paths.
- for (Driver::prefix_list::const_iterator it = PrefixDirs.begin(),
- ie = PrefixDirs.end(); it != ie; ++it) {
- std::string Dir(*it);
+ for (const std::string &Dir : PrefixDirs) {
if (Dir.empty())
continue;
- if (Dir[0] == '=')
- Dir = SysRoot + Dir.substr(1);
- SmallString<128> P(Dir);
+ SmallString<128> P(Dir[0] == '=' ? SysRoot + Dir.substr(1) : Dir);
llvm::sys::path::append(P, Name);
if (llvm::sys::fs::exists(Twine(P)))
return P.str();
@@ -1853,15 +1849,10 @@ std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const {
if (llvm::sys::fs::exists(Twine(P)))
return P.str();
- const ToolChain::path_list &List = TC.getFilePaths();
- for (ToolChain::path_list::const_iterator
- it = List.begin(), ie = List.end(); it != ie; ++it) {
- std::string Dir(*it);
+ for (const std::string &Dir : TC.getFilePaths()) {
if (Dir.empty())
continue;
- if (Dir[0] == '=')
- Dir = SysRoot + Dir.substr(1);
- SmallString<128> P(Dir);
+ SmallString<128> P(Dir[0] == '=' ? SysRoot + Dir.substr(1) : Dir);
llvm::sys::path::append(P, Name);
if (llvm::sys::fs::exists(Twine(P)))
return P.str();
OpenPOWER on IntegriCloud