[Frontend] Add compiler version information to -print-target-info output.

Clients that use -print-target-info can avoid an extra frontend
invocation by using this information.
This commit is contained in:
Doug Gregor
2020-07-07 22:11:19 -07:00
parent cea9d5cd67
commit 7bf676d335
2 changed files with 10 additions and 0 deletions

View File

@@ -1985,6 +1985,12 @@ static void printTargetInfo(const CompilerInvocation &invocation,
llvm::raw_ostream &out) {
out << "{\n";
// Compiler version, as produced by --version.
out << " \"compilerVersion\": \"";
out.write_escaped(version::getSwiftFullVersion(
version::Version::getCurrentLanguageVersion()));
out << "\",\n";
// Target triple and target variant triple.
auto &langOpts = invocation.getLangOptions();
out << " \"target\": ";