Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ namespace clang {
/// number, the repository version, and the vendor tag.
std::string getClangFullCPPVersion();

/// Retrieves a string representing the complete DPC++ version suitable
/// for use in the CPP __VERSION__ macro, including repository information.
std::string getDPCPPFullCPPVersion();

/// Retrieves a string representing the SYCL standard version for use in
/// the CL_SYCL_LANGUAGE_VERSION and SYCL_LANGUAGE_VERSION macros.
llvm::SmallVector<std::pair<llvm::StringRef, llvm::StringRef>, 2>
Expand Down
13 changes: 13 additions & 0 deletions clang/lib/Basic/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ std::string getClangFullCPPVersion() {

return buf;
}
std::string getDPCPPFullCPPVersion() {
Comment on lines 148 to +149
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
std::string getDPCPPFullCPPVersion() {
}
std::string getDPCPPFullCPPVersion() {

// Format: "DPC++ 6.3.0 git (https://github.com/intel/llvm.git ...)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string looks like an example of the format rather than a format itself.

Suggested change
// Format: "DPC++ 6.3.0 git (https://github.com/intel/llvm.git ...)"
// Format example: "DPC++ 6.3.0 git (https://github.com/intel/llvm.git ...)"

std::string buf;
llvm::raw_string_ostream OS(buf);
OS << "DPC++ " DPCPP_VERSION;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this was already merged, but perhaps we should follow up with an additional change to add the pre-release indicator here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a follow-up PR. Just to confirm the output format for pre-release, does the following look good? "DPC++ 7.0.0 (pre-release) git (https://github.com/intel/llvm.git ...)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that looks great!


std::string repo = getClangFullRepositoryVersion();
if (!repo.empty()) {
OS << " " << repo;
}
Comment on lines +156 to +158
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!repo.empty()) {
OS << " " << repo;
}
if (!repo.empty())
OS << " " << repo;


return buf;
}

llvm::SmallVector<std::pair<llvm::StringRef, llvm::StringRef>, 2>
getSYCLVersionMacros(const LangOptions &LangOpts) {
Expand Down
16 changes: 11 additions & 5 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,12 +875,18 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("__clang_major__", TOSTR(CLANG_VERSION_MAJOR));
Builder.defineMacro("__clang_minor__", TOSTR(CLANG_VERSION_MINOR));
Builder.defineMacro("__clang_patchlevel__", TOSTR(CLANG_VERSION_PATCHLEVEL));
#undef TOSTR
#undef TOSTR2
Builder.defineMacro("__clang_version__",
"\"" CLANG_VERSION_STRING " "
+ getClangFullRepositoryVersion() + "\"");

// DPC++ version macros - Intel's SYCL compiler
Builder.defineMacro("__DPCPP__", "1");
Comment thread
ykhatav marked this conversation as resolved.
Builder.defineMacro("__dpcpp_major__", TOSTR(DPCPP_VERSION_MAJOR));
Builder.defineMacro("__dpcpp_minor__", TOSTR(DPCPP_VERSION_MINOR));
Builder.defineMacro("__dpcpp_patchlevel__", TOSTR(DPCPP_VERSION_PATCH));
#undef TOSTR
#undef TOSTR2

if (LangOpts.GNUCVersion != 0) {
// Major, minor, patch, are given two decimal places each, so 4.2.1 becomes
// 40201.
Expand Down Expand Up @@ -944,9 +950,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");

// Previously this macro was set to a string aiming to achieve compatibility
// with GCC 4.2.1. Now, just return the full Clang version
Builder.defineMacro("__VERSION__", "\"" +
Twine(getClangFullCPPVersion()) + "\"");
// with GCC 4.2.1. Now, just return the full DPC++ version
Builder.defineMacro("__VERSION__",
Comment thread
ykhatav marked this conversation as resolved.
"\"" + Twine(getDPCPPFullCPPVersion()) + "\"");

// Initialize language-specific preprocessor defines.

Expand Down
1 change: 1 addition & 0 deletions clang/test/Preprocessor/init-aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
// AARCH64-NEXT: #define __DBL_MIN__ 2.2250738585072014e-308
// AARCH64-NEXT: #define __DBL_NORM_MAX__ 1.7976931348623157e+308
// AARCH64-NEXT: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
// AARCH64-NEXT: #define __DPCPP__ 1
// AARCH64-NEXT: #define __ELF__ 1
// AARCH64-NEXT: #define __FINITE_MATH_ONLY__ 0
// AARCH64-NEXT: #define __FLT16_DECIMAL_DIG__ 5
Expand Down
6 changes: 5 additions & 1 deletion clang/test/Preprocessor/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@
// SPARC:#define __UINT_LEAST8_MAX__ 255
// SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
// SPARC:#define __USER_LABEL_PREFIX__
// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
// SPARC:#define __VERSION__ "{{.*}}DPC++{{.*}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// SPARC:#define __VERSION__ "{{.*}}DPC++{{.*}}
// SPARC:#define __VERSION__ "{{.*}}DPC++{{.*}}"

// SPARC:#define __WCHAR_MAX__ 2147483647
// SPARC:#define __WCHAR_TYPE__ int
// SPARC:#define __WCHAR_WIDTH__ 32
Expand Down Expand Up @@ -1727,6 +1727,7 @@
// WEBASSEMBLY-NEXT:#define __DBL_MIN__ 2.2250738585072014e-308
// WEBASSEMBLY-NEXT:#define __DBL_NORM_MAX__ 1.7976931348623157e+308
// WEBASSEMBLY-NEXT:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
// WEBASSEMBLY-NEXT:#define __DPCPP__ 1
// WEBASSEMBLY-NOT:#define __ELF__
// EMSCRIPTEN-THREADS-NEXT:#define __EMSCRIPTEN_PTHREADS__ 1
// EMSCRIPTEN-NEXT:#define __EMSCRIPTEN__ 1
Expand Down Expand Up @@ -2090,6 +2091,9 @@
// WEBASSEMBLY-NEXT:#define __clang_patchlevel__ {{.*}}
// WEBASSEMBLY-NEXT:#define __clang_version__ "{{.*}}"
// WEBASSEMBLY-NEXT:#define __clang_wide_literal_encoding__ {{.*}}
// WEBASSEMBLY-NEXT:#define __dpcpp_major__ 7
// WEBASSEMBLY-NEXT:#define __dpcpp_minor__ 0
// WEBASSEMBLY-NEXT:#define __dpcpp_patchlevel__ 0
// WEBASSEMBLY-NEXT:#define __llvm__ 1
// WASI-NOT:#define __unix
// WASI-NOT:#define __unix__
Expand Down
Loading