|
1 # The anonymous std::string temporary created by getClangFullRepositoryVersion |
|
2 # goes out-of-scope in C++11 because COW std::string is not allowed. |
|
3 # I.e. the std::string buffer of the anonymous temporary goes out of scope. |
|
4 # Because of this, the buffer referenced by the underlying StringRef in |
|
5 # llvm::Twine is invalid as soon as the std::string temporary expires. |
|
6 # The tagged clang version string must be created as a data segment global |
|
7 # constant via macro, just like all the other clang version macro identifiers. |
|
8 # https://llvm.org/bugs/show_bug.cgi?id=24684 |
|
9 --- tools/clang/include/clang/Basic/Version.inc.in 2010-06-25 13:33:46.000000000 -0400 |
|
10 +++ tools/clang/include/clang/Basic/Version.inc.in 2015-07-05 14:20:27.771128865 -0400 |
|
11 @@ -4,3 +4,4 @@ |
|
12 #if @CLANG_HAS_VERSION_PATCHLEVEL@ |
|
13 #define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@ |
|
14 #endif |
|
15 +#define CLANG_VERSION_TAGGED_STRING @CLANG_VERSION_TAGGED_STRING@ |
|
16 --- tools/clang/include/clang/Basic/Makefile 2014-03-31 09:14:44.000000000 -0400 |
|
17 +++ tools/clang/include/clang/Basic/Makefile 2015-07-05 14:19:58.972485543 -0400 |
|
18 @@ -16,8 +16,18 @@ |
|
19 |
|
20 INPUT_TDS = $(wildcard $(PROJ_SRC_DIR)/Diagnostic*.td) |
|
21 |
|
22 +SVN_OR_RC := |
|
23 + |
|
24 # Compute the Clang version from the LLVM version, unless specified explicitly. |
|
25 ifndef CLANG_VERSION |
|
26 +ifeq ($(LLVMVersion), $(findstring svn, $(LLVMVersion)), svn) |
|
27 + SVN_OR_RC := "svn" |
|
28 +endif |
|
29 + |
|
30 +ifeq ($(LLVMVersion), $(findstring rc, $(LLVMVersion)), rc) |
|
31 + SVN_OR_RC := "rc" |
|
32 +endif |
|
33 + |
|
34 CLANG_VERSION := $(subst svn,,$(LLVMVersion)) |
|
35 CLANG_VERSION := $(subst rc,,$(CLANG_VERSION)) |
|
36 endif |
|
37 @@ -26,6 +36,14 @@ |
|
38 CLANG_VERSION_MAJOR := $(word 1,$(CLANG_VERSION_COMPONENTS)) |
|
39 CLANG_VERSION_MINOR := $(word 2,$(CLANG_VERSION_COMPONENTS)) |
|
40 CLANG_VERSION_PATCHLEVEL := $(word 3,$(CLANG_VERSION_COMPONENTS)) |
|
41 +CLANG_VERSION_TAGGED_STRING := |
|
42 + |
|
43 +ifeq ($(SVN_OR_RC),) |
|
44 +CLANG_VERSION_TAGGED_STRING := "\"\(tags/RELEASE_$(CLANG_VERSION_MAJOR)$(CLANG_VERSION_MINOR)$(CLANG_VERSION_PATCHLEVEL)/final\)\"" |
|
45 +else |
|
46 +CLANG_VERSION_TAGGED_STRING := "\"\(tags/RELEASE_$(CLANG_VERSION_MAJOR)$(CLANG_VERSION_MINOR)$(CLANG_VERSION_PATCHLEVEL)/$(SVN_OR_RC)\)\"" |
|
47 +endif |
|
48 + |
|
49 ifeq ($(CLANG_VERSION_PATCHLEVEL),) |
|
50 CLANG_HAS_VERSION_PATCHLEVEL := 0 |
|
51 else |
|
52 @@ -67,4 +85,5 @@ |
|
53 -e "s#@CLANG_VERSION_MINOR@#$(CLANG_VERSION_MINOR)#g" \ |
|
54 -e "s#@CLANG_VERSION_PATCHLEVEL@#$(CLANG_VERSION_PATCHLEVEL)#g" \ |
|
55 -e "s#@CLANG_HAS_VERSION_PATCHLEVEL@#$(CLANG_HAS_VERSION_PATCHLEVEL)#g" \ |
|
56 + -e "s#@CLANG_VERSION_TAGGED_STRING@#$(CLANG_VERSION_TAGGED_STRING:' '='')#g" \ |
|
57 $< > $@ |
|
58 --- tools/clang/lib/Frontend/InitPreprocessor.cpp 2015-04-27 04:12:42.000000000 -0400 |
|
59 +++ tools/clang/lib/Frontend/InitPreprocessor.cpp 2015-07-05 14:24:20.804334574 -0400 |
|
60 @@ -470,8 +470,7 @@ |
|
61 Builder.defineMacro("__clang_patchlevel__", "0"); |
|
62 #endif |
|
63 Builder.defineMacro("__clang_version__", |
|
64 - "\"" CLANG_VERSION_STRING " " |
|
65 - + getClangFullRepositoryVersion() + "\""); |
|
66 + "\"" CLANG_VERSION_STRING " " CLANG_VERSION_TAGGED_STRING "\""); |
|
67 #undef TOSTR |
|
68 #undef TOSTR2 |
|
69 if (!LangOpts.MSVCCompat) { |