aboutsummaryrefslogtreecommitdiff
path: root/lld/lib/Config/Version.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-03-03 00:51:23 +0000
committerRui Ueyama <ruiu@google.com>2016-03-03 00:51:23 +0000
commit6b500dc5f9c37ded310ebf626f655a33030b7914 (patch)
tree699cf872d021fe3d94590e7d6414124647e90038 /lld/lib/Config/Version.cpp
parent05a6333842df60049dfb16c3f212499ff00323cc (diff)
downloadllvm-6b500dc5f9c37ded310ebf626f655a33030b7914.zip
llvm-6b500dc5f9c37ded310ebf626f655a33030b7914.tar.gz
llvm-6b500dc5f9c37ded310ebf626f655a33030b7914.tar.bz2
Simplify string operations. NFC.
llvm-svn: 262569
Diffstat (limited to 'lld/lib/Config/Version.cpp')
-rw-r--r--lld/lib/Config/Version.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/lld/lib/Config/Version.cpp b/lld/lib/Config/Version.cpp
index 2f06d20..60687b9 100644
--- a/lld/lib/Config/Version.cpp
+++ b/lld/lib/Config/Version.cpp
@@ -35,22 +35,15 @@ StringRef getLLDRevision() {
}
std::string getLLDRepositoryVersion() {
- std::string buf;
- llvm::raw_string_ostream OS(buf);
- std::string Path = getLLDRepositoryPath();
- std::string Revision = getLLDRevision();
- if (!Path.empty() || !Revision.empty()) {
- OS << '(';
- if (!Path.empty())
- OS << Path;
- if (!Revision.empty()) {
- if (!Path.empty())
- OS << ' ';
- OS << Revision;
- }
- OS << ')';
- }
- return OS.str();
+ std::string S = getLLDRepositoryPath();
+ std::string T = getLLDRevision();
+ if (S.empty() && T.empty())
+ return "";
+ if (!S.empty() && !T.empty())
+ return "(" + S + " " + T + ")";
+ if (!S.empty())
+ return "(" + S + ")";
+ return "(" + T + ")";
}
StringRef getLLDVersion() {