[lld] r284641 - Move getVersionString to Core and simplify Version.cpp.
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 21 08:05:29 PDT 2016
do we want to include the llvm version too? Clang --version says:
clang version 3.8.0 (trunk 255273) (llvm/trunk 255300)
Cheers,
Rafael
On 19 October 2016 at 16:53, Rui Ueyama via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: ruiu
> Date: Wed Oct 19 15:53:07 2016
> New Revision: 284641
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284641&view=rev
> Log:
> Move getVersionString to Core and simplify Version.cpp.
>
> Modified:
> lld/trunk/ELF/Driver.cpp
> lld/trunk/ELF/Driver.h
> lld/trunk/ELF/DriverUtils.cpp
> lld/trunk/include/lld/Config/Version.h
> lld/trunk/lib/Config/Version.cpp
>
> Modified: lld/trunk/ELF/Driver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=284641&r1=284640&r2=284641&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Driver.cpp (original)
> +++ lld/trunk/ELF/Driver.cpp Wed Oct 19 15:53:07 2016
> @@ -19,6 +19,7 @@
> #include "SymbolTable.h"
> #include "Target.h"
> #include "Writer.h"
> +#include "lld/Config/Version.h"
> #include "lld/Driver/Driver.h"
> #include "llvm/ADT/StringExtras.h"
> #include "llvm/ADT/StringSwitch.h"
> @@ -287,7 +288,7 @@ void LinkerDriver::main(ArrayRef<const c
> return;
> }
> if (Args.hasArg(OPT_version))
> - outs() << getVersionString();
> + outs() << getLLDVersion() << "\n";
>
> if (const char *Path = getReproduceOption(Args)) {
> // Note that --reproduce is a debug option so you can ignore it
> @@ -296,7 +297,7 @@ void LinkerDriver::main(ArrayRef<const c
> if (F) {
> Cpio.reset(*F);
> Cpio->append("response.txt", createResponseFile(Args));
> - Cpio->append("version.txt", getVersionString());
> + Cpio->append("version.txt", (getLLDVersion() + "\n").str());
> } else
> error(F.getError(),
> Twine("--reproduce: failed to open ") + Path + ".cpio");
>
> Modified: lld/trunk/ELF/Driver.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=284641&r1=284640&r2=284641&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Driver.h (original)
> +++ lld/trunk/ELF/Driver.h Wed Oct 19 15:53:07 2016
> @@ -70,7 +70,6 @@ enum {
> };
>
> void printHelp(const char *Argv0);
> -std::string getVersionString();
> std::vector<uint8_t> parseHexstring(StringRef S);
>
> std::string createResponseFile(const llvm::opt::InputArgList &Args);
>
> Modified: lld/trunk/ELF/DriverUtils.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=284641&r1=284640&r2=284641&view=diff
> ==============================================================================
> --- lld/trunk/ELF/DriverUtils.cpp (original)
> +++ lld/trunk/ELF/DriverUtils.cpp Wed Oct 19 15:53:07 2016
> @@ -98,14 +98,6 @@ void elf::printHelp(const char *Argv0) {
> Table.PrintHelp(outs(), Argv0, "lld", false);
> }
>
> -std::string elf::getVersionString() {
> - std::string Version = getLLDVersion();
> - std::string Repo = getLLDRepositoryVersion();
> - if (Repo.empty())
> - return "LLD " + Version + "\n";
> - return "LLD " + Version + " " + Repo + "\n";
> -}
> -
> // Reconstructs command line arguments so that so that you can re-run
> // the same command with the same inputs. This is for --reproduce.
> std::string elf::createResponseFile(const opt::InputArgList &Args) {
>
> Modified: lld/trunk/include/lld/Config/Version.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Config/Version.h?rev=284641&r1=284640&r2=284641&view=diff
> ==============================================================================
> --- lld/trunk/include/lld/Config/Version.h (original)
> +++ lld/trunk/include/lld/Config/Version.h Wed Oct 19 15:53:07 2016
> @@ -6,11 +6,9 @@
> // License. See LICENSE.TXT for details.
> //
> //===----------------------------------------------------------------------===//
> -///
> -/// \file
> -/// \brief Defines version macros and version-related utility functions
> -/// for lld.
> -///
> +//
> +// Defines a version-related utility function.
> +//
> //===----------------------------------------------------------------------===//
>
> #ifndef LLD_VERSION_H
> @@ -18,32 +16,8 @@
>
> #include "lld/Config/Version.inc"
> #include "llvm/ADT/StringRef.h"
> -#include <string>
> -
> -/// \brief Helper macro for LLD_VERSION_STRING.
> -#define LLD_MAKE_VERSION_STRING2(X) #X
> -
> -/// \brief Helper macro for LLD_VERSION_STRING.
> -#define LLD_MAKE_VERSION_STRING(X, Y) LLD_MAKE_VERSION_STRING2(X.Y)
> -
> -/// \brief A string that describes the lld version number, e.g., "1.0".
> -#define LLD_VERSION_STRING \
> - LLD_MAKE_VERSION_STRING(LLD_VERSION_MAJOR, LLD_VERSION_MINOR)
>
> namespace lld {
> -/// \brief Retrieves the repository path (e.g., Subversion path) that
> -/// identifies the particular lld branch, tag, or trunk from which this
> -/// lld was built.
> -llvm::StringRef getLLDRepositoryPath();
> -
> -/// \brief Retrieves the repository revision number (or identifer) from which
> -/// this lld was built.
> -llvm::StringRef getLLDRevision();
> -
> -/// \brief Retrieves the full repository version that is an amalgamation of
> -/// the information in getLLDRepositoryPath() and getLLDRevision().
> -std::string getLLDRepositoryVersion();
> -
> /// \brief Retrieves a string representing the complete lld version.
> llvm::StringRef getLLDVersion();
> }
>
> Modified: lld/trunk/lib/Config/Version.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Config/Version.cpp?rev=284641&r1=284640&r2=284641&view=diff
> ==============================================================================
> --- lld/trunk/lib/Config/Version.cpp (original)
> +++ lld/trunk/lib/Config/Version.cpp Wed Oct 19 15:53:07 2016
> @@ -12,46 +12,27 @@
> //===----------------------------------------------------------------------===//
>
> #include "lld/Config/Version.h"
> -#include "llvm/Support/raw_ostream.h"
>
> using namespace llvm;
>
> -namespace lld {
> +#define JOIN2(X) #X
> +#define JOIN(X, Y) JOIN2(X.Y)
>
> -StringRef getLLDRepositoryPath() {
> -#ifdef LLD_REPOSITORY_STRING
> - return LLD_REPOSITORY_STRING;
> -#else
> - return "";
> -#endif
> -}
> -
> -StringRef getLLDRevision() {
> -#ifdef LLD_REVISION_STRING
> - return LLD_REVISION_STRING;
> -#else
> - return "";
> -#endif
> -}
> +// A string that describes the lld version number, e.g., "1.0".
> +#define VERSION JOIN(LLD_VERSION_MAJOR, LLD_VERSION_MINOR)
>
> -std::string getLLDRepositoryVersion() {
> - std::string S = getLLDRepositoryPath();
> - std::string T = getLLDRevision();
> - if (S.empty() && T.empty())
> - return "";
> - if (!S.empty() && !T.empty())
> - return "(" + S + " " + T + ")";
> - if (!S.empty())
> - return "(" + S + ")";
> - return "(" + T + ")";
> -}
> -
> -StringRef getLLDVersion() {
> -#ifdef LLD_VERSION_STRING
> - return LLD_VERSION_STRING;
> +// A string that describes SVN repository, e.g.,
> +// " (https://llvm.org/svn/llvm-project/lld/trunk 284614)".
> +#if defined(LLD_REPOSITORY_STRING) && defined(LLD_REVISION_STRING)
> +#define REPO " (" LLD_REPOSITORY_STRING " " LLD_REVISION_STRING ")"
> +#elif defined(LLD_REPOSITORY_STRING)
> +#define REPO " (" LLD_REPOSITORY_STRING ")"
> +#elif defined(LLD_REVISION_STRING)
> +#define REPO " (" LLD_REVISION_STRING ")"
> #else
> - return "";
> +#define REPO ""
> #endif
> -}
>
> -} // end namespace lld
> +// Returns a version string, e.g.,
> +// "LLD 4.0 (https://llvm.org/svn/llvm-project/lld/trunk 284614)".
> +StringRef lld::getLLDVersion() { return "LLD " VERSION REPO; }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list