forked from OSchip/llvm-project
(1) Rename getClangSubversionRevision() to getClangRevision(), and
have it return a StringRef instead of an integer (to be more VCS agnostic). (2) Add getClangFullRepositoryVersion(), which contains an amalgamation of the repository name and the revision. (3) Change PCH to only emit the string returned by getClangFullRepositoryVersion() instead of also emitting the value of getClangSubversionRevision() (which has been removed). This is functionally equivalent. More cleanup to version string generation pending... llvm-svn: 94231
This commit is contained in:
parent
f5c834fce1
commit
18e066f6a9
|
@ -54,9 +54,13 @@ namespace clang {
|
|||
/// Clang was built.
|
||||
llvm::StringRef getClangRepositoryPath();
|
||||
|
||||
/// \brief Retrieves the Subversion revision number from which this Clang
|
||||
/// was built.
|
||||
unsigned getClangSubversionRevision();
|
||||
/// \brief Retrieves the repository revision number (or identifer) from which
|
||||
/// this Clang was built.
|
||||
llvm::StringRef getClangRevision();
|
||||
|
||||
/// \brief Retrieves the full repository version that is an amalgamation of
|
||||
/// the information in getClangRepositoryPath() and getClangRevision().
|
||||
llvm::StringRef getClangFullRepositoryVersion();
|
||||
}
|
||||
|
||||
#endif // LLVM_CLANG_BASIC_VERSION_H
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
|
@ -44,13 +45,30 @@ llvm::StringRef getClangRepositoryPath() {
|
|||
}
|
||||
|
||||
|
||||
unsigned getClangSubversionRevision() {
|
||||
llvm::StringRef getClangRevision() {
|
||||
#ifndef SVN_REVISION
|
||||
// Subversion was not available at build time?
|
||||
return 0;
|
||||
return llvm::StringRef();
|
||||
#else
|
||||
return strtol(SVN_REVISION, 0, 10);
|
||||
static std::string revision;
|
||||
if (revision.empty()) {
|
||||
llvm::raw_string_ostream Out(revision);
|
||||
Out << strtol(SVN_REVISION, 0, 10);
|
||||
}
|
||||
return revision;
|
||||
#endif
|
||||
}
|
||||
|
||||
llvm::StringRef getClangFullRepositoryVersion() {
|
||||
static std::string buf;
|
||||
if (buf.empty()) {
|
||||
llvm::raw_string_ostream Out(buf);
|
||||
Out << getClangRepositoryPath();
|
||||
llvm::StringRef Revision = getClangRevision();
|
||||
if (!Revision.empty())
|
||||
Out << ' ' << Revision;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
} // end namespace clang
|
||||
|
|
|
@ -286,9 +286,7 @@ void Driver::PrintVersion(const Compilation &C, llvm::raw_ostream &OS) const {
|
|||
OS << CLANG_VENDOR;
|
||||
#endif
|
||||
OS << "clang version " CLANG_VERSION_STRING " ("
|
||||
<< getClangRepositoryPath();
|
||||
if (unsigned Revision = getClangSubversionRevision())
|
||||
OS << " " << Revision;
|
||||
<< getClangFullRepositoryVersion();
|
||||
OS << ")" << '\n';
|
||||
|
||||
const ToolChain &TC = C.getDefaultToolChain();
|
||||
|
|
|
@ -1400,14 +1400,7 @@ PCHReader::ReadPCHBlock() {
|
|||
break;
|
||||
|
||||
case pch::VERSION_CONTROL_BRANCH_REVISION: {
|
||||
unsigned CurRevision = getClangSubversionRevision();
|
||||
if (Record[0] && CurRevision && Record[0] != CurRevision) {
|
||||
Diag(Record[0] < CurRevision? diag::warn_pch_version_too_old
|
||||
: diag::warn_pch_version_too_new);
|
||||
return IgnorePCH;
|
||||
}
|
||||
|
||||
llvm::StringRef CurBranch = getClangRepositoryPath();
|
||||
llvm::StringRef CurBranch = getClangFullRepositoryVersion();
|
||||
llvm::StringRef PCHBranch(BlobStart, BlobLen);
|
||||
if (CurBranch != PCHBranch) {
|
||||
Diag(diag::warn_pch_different_branch) << PCHBranch << CurBranch;
|
||||
|
|
|
@ -707,16 +707,15 @@ void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
|
|||
Stream.EmitRecordWithBlob(FileAbbrevCode, Record, MainFileNameStr);
|
||||
}
|
||||
|
||||
// Subversion branch/version information.
|
||||
BitCodeAbbrev *SvnAbbrev = new BitCodeAbbrev();
|
||||
SvnAbbrev->Add(BitCodeAbbrevOp(pch::VERSION_CONTROL_BRANCH_REVISION));
|
||||
SvnAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // SVN revision
|
||||
SvnAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // SVN branch/tag
|
||||
unsigned SvnAbbrevCode = Stream.EmitAbbrev(SvnAbbrev);
|
||||
// Repository branch/version information.
|
||||
BitCodeAbbrev *RepoAbbrev = new BitCodeAbbrev();
|
||||
RepoAbbrev->Add(BitCodeAbbrevOp(pch::VERSION_CONTROL_BRANCH_REVISION));
|
||||
RepoAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // SVN branch/tag
|
||||
unsigned RepoAbbrevCode = Stream.EmitAbbrev(RepoAbbrev);
|
||||
Record.clear();
|
||||
Record.push_back(pch::VERSION_CONTROL_BRANCH_REVISION);
|
||||
Record.push_back(getClangSubversionRevision());
|
||||
Stream.EmitRecordWithBlob(SvnAbbrevCode, Record, getClangRepositoryPath());
|
||||
Stream.EmitRecordWithBlob(RepoAbbrevCode, Record,
|
||||
getClangFullRepositoryVersion());
|
||||
}
|
||||
|
||||
/// \brief Write the LangOptions structure.
|
||||
|
|
Loading…
Reference in New Issue