diff options
author | Daniel Dunbar <daniel@zuster.org> | 2011-03-31 00:53:51 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2011-03-31 00:53:51 +0000 |
commit | 3b17a865bb99b92e08f173e45928b42146ca9492 (patch) | |
tree | 5bcb16951e730a363e26365ec2be527700dad265 /clang/lib | |
parent | 1a93b3b080474ab9b62ba63b07a890f559ca27a3 (diff) | |
download | bcm5719-llvm-3b17a865bb99b92e08f173e45928b42146ca9492.tar.gz bcm5719-llvm-3b17a865bb99b92e08f173e45928b42146ca9492.zip |
Change Clang's __VERSION__ to include the same basic info as in clang -v.
- Please never ever ever ever write a tool that sniffs this.
llvm-svn: 128599
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/Version.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp index af2f848071b..65cc2581dab 100644 --- a/clang/lib/Basic/Version.cpp +++ b/clang/lib/Basic/Version.cpp @@ -91,4 +91,17 @@ std::string getClangFullVersion() { return OS.str(); } +std::string getClangFullCPPVersion() { + // The version string we report in __VERSION__ is just a compacted version of + // the one we report on the command line. + std::string buf; + llvm::raw_string_ostream OS(buf); +#ifdef CLANG_VENDOR + OS << CLANG_VENDOR; +#endif + OS << "Clang " CLANG_VERSION_STRING " (" + << getClangFullRepositoryVersion() << ')'; + return OS.str(); +} + } // end namespace clang diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 3c5be253c7f..928e84b1856 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -247,7 +247,12 @@ static void InitializePredefinedMacros(const TargetInfo &TI, Builder.defineMacro("__GNUC_PATCHLEVEL__", "1"); Builder.defineMacro("__GNUC__", "4"); Builder.defineMacro("__GXX_ABI_VERSION", "1002"); - Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible Clang Compiler\""); + + // As sad as it is, enough software depends on the __VERSION__ for version + // checks that it is necessary to report 4.2.1 (the base GCC version we claim + // compatibility with) first. + Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible " + + llvm::Twine(getClangFullCPPVersion()) + "\""); // Initialize language-specific preprocessor defines. |