aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/Version.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Basic/Version.cpp')
-rw-r--r--lib/Basic/Version.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/lib/Basic/Version.cpp b/lib/Basic/Version.cpp
index fdb96e5732..f9d62f9dc7 100644
--- a/lib/Basic/Version.cpp
+++ b/lib/Basic/Version.cpp
@@ -21,27 +21,22 @@ using namespace std;
namespace clang {
llvm::StringRef getClangRepositoryPath() {
- static const char *Path = 0;
- if (Path)
- return Path;
-
- static char URL[] = "$URL$";
- char *End = strstr(URL, "/lib/Basic");
+ static const char URL[] = "$URL$";
+ const char *URLEnd = URL + strlen(URL);
+
+ const char *End = strstr(URL, "/lib/Basic");
if (End)
- *End = 0;
-
+ URLEnd = End;
+
End = strstr(URL, "/clang/tools/clang");
if (End)
- *End = 0;
-
- char *Begin = strstr(URL, "cfe/");
- if (Begin) {
- Path = Begin + 4;
- return Path;
- }
-
- Path = URL;
- return Path;
+ URLEnd = End;
+
+ const char *Begin = strstr(URL, "cfe/");
+ if (Begin)
+ return llvm::StringRef(Begin + 4, URLEnd - Begin - 4);
+
+ return llvm::StringRef(URL, URLEnd - URL);
}