[cfe-commits] r94242 - in /cfe/trunk: include/clang-c/Index.h include/clang/Basic/Version.h lib/Basic/Version.cpp tools/CIndex/CIndex.cpp tools/CIndex/CIndex.exports

Daniel Dunbar daniel at zuster.org
Fri Jan 22 16:21:11 PST 2010


Hi Ted,

On Fri, Jan 22, 2010 at 2:44 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Fri Jan 22 16:44:15 2010
> New Revision: 94242
>
> URL: http://llvm.org/viewvc/llvm-project?rev=94242&view=rev
> Log:
> Add 'clang_getClangVersion()' function to CIndex.  This exposes the full Clang version string through the CIndex API.

I think it would be better to name this "clang_getFullVersionString"
or something, we might want getVersion or so in the future to get the
actually numeric version number.

 - Daniel

> Modified:
>    cfe/trunk/include/clang-c/Index.h
>    cfe/trunk/include/clang/Basic/Version.h
>    cfe/trunk/lib/Basic/Version.cpp
>    cfe/trunk/tools/CIndex/CIndex.cpp
>    cfe/trunk/tools/CIndex/CIndex.exports
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=94242&r1=94241&r2=94242&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Fri Jan 22 16:44:15 2010
> @@ -1238,6 +1238,19 @@
>  * @}
>  */
>
> +
> +/**
> + * \defgroup CINDEX_MISC Miscellaneous utility functions
> + *
> + * @{
> + */
> +
> +CINDEX_LINKAGE const char *clang_getClangVersion();
> +
> +/**
> + * @}
> + */
> +
>  /**
>  * @}
>  */
>
> Modified: cfe/trunk/include/clang/Basic/Version.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Version.h?rev=94242&r1=94241&r2=94242&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Version.h (original)
> +++ cfe/trunk/include/clang/Basic/Version.h Fri Jan 22 16:44:15 2010
> @@ -65,7 +65,7 @@
>   /// \brief Retrieves a string representing the complete clang version,
>   ///   which includes the clang version number, the repository version,
>   ///   and the vendor tag.
> -  llvm::StringRef getClangFullVendorVersion();
> +  const char *getClangFullVendorVersion();
>  }
>
>  #endif // LLVM_CLANG_BASIC_VERSION_H
>
> Modified: cfe/trunk/lib/Basic/Version.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Version.cpp?rev=94242&r1=94241&r2=94242&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Basic/Version.cpp (original)
> +++ cfe/trunk/lib/Basic/Version.cpp Fri Jan 22 16:44:15 2010
> @@ -71,7 +71,7 @@
>   return buf;
>  }
>
> -llvm::StringRef getClangFullVendorVersion() {
> +const char *getClangFullVendorVersion() {
>   static std::string buf;
>   if (buf.empty()) {
>     llvm::raw_string_ostream OS(buf);
> @@ -81,7 +81,7 @@
>     OS << "clang version " CLANG_VERSION_STRING " ("
>        << getClangFullRepositoryVersion() << ')';
>   }
> -  return buf;
> +  return buf.c_str();
>  }
>
>  } // end namespace clang
>
> Modified: cfe/trunk/tools/CIndex/CIndex.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=94242&r1=94241&r2=94242&view=diff
>
> ==============================================================================
> --- cfe/trunk/tools/CIndex/CIndex.cpp (original)
> +++ cfe/trunk/tools/CIndex/CIndex.cpp Fri Jan 22 16:44:15 2010
> @@ -15,6 +15,7 @@
>  #include "CIndexer.h"
>  #include "CXCursor.h"
>
> +#include "clang/Basic/Version.h"
>  #include "clang/AST/DeclVisitor.h"
>  #include "clang/AST/StmtVisitor.h"
>  #include "clang/AST/TypeLocVisitor.h"
> @@ -1791,4 +1792,18 @@
>   if (string.MustFreeString && string.Spelling)
>     free((void*)string.Spelling);
>  }
> +
>  } // end: extern "C"
> +
> +//===----------------------------------------------------------------------===//
> +// Misc. utility functions.
> +//===----------------------------------------------------------------------===//
> +
> +extern "C" {
> +
> +const char *clang_getClangVersion() {
> +  return getClangFullVendorVersion();
> +}
> +
> +} // end: extern "C"
> +
>
> Modified: cfe/trunk/tools/CIndex/CIndex.exports
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.exports?rev=94242&r1=94241&r2=94242&view=diff
>
> ==============================================================================
> --- cfe/trunk/tools/CIndex/CIndex.exports (original)
> +++ cfe/trunk/tools/CIndex/CIndex.exports Fri Jan 22 16:44:15 2010
> @@ -8,6 +8,7 @@
>  _clang_disposeTranslationUnit
>  _clang_equalCursors
>  _clang_equalLocations
> +_clang_getClangVersion
>  _clang_getCString
>  _clang_getCompletionChunkCompletionString
>  _clang_getCompletionChunkKind
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list