Skip to content
Commits on Source (5)
---
# This configuration requires clang-format 3.8 or higher.
# This configuration requires clang-format version 6.0 exactly.
BasedOnStyle: Mozilla
AlignOperands: false
AlwaysBreakAfterReturnType: None
AllowShortFunctionsOnASingleLine: InlineOnly
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterEnum: true
AfterFunction: true
AfterStruct: true
AfterUnion: true
BreakBeforeBraces: Custom
ColumnLimit: 79
Standard: Cpp11
IndentPPDirectives: AfterHash
SortUsingDeclarations: false
SpaceAfterTemplateKeyword: true
...
......@@ -33,11 +33,7 @@ if(NOT CastXML_INSTALL_DATA_DIR)
set(CastXML_INSTALL_DATA_DIR share/castxml)
endif()
if(NOT CastXML_INSTALL_DOC_DIR)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CastXML_INSTALL_DOC_DIR share/doc/castxml)
else()
set(CastXML_INSTALL_DOC_DIR doc/castxml)
endif()
endif()
if(NOT CastXML_INSTALL_MAN_DIR)
set(CastXML_INSTALL_MAN_DIR man)
......
......@@ -46,7 +46,10 @@ To build CastXML from source, first obtain the prerequisites:
* `LLVM/Clang`_ compiler SDK install tree built using the C++ compiler.
This version of CastXML has been tested with LLVM/Clang
- SVN revision ``319768`` (trunk)
- SVN revision ``356914`` (trunk)
- Release ``8.0``
- Release ``7.0``
- Release ``6.0``
- Release ``5.0``
- Release ``4.0``
- Release ``3.9``
......
castxml (0.2.0-1) UNRELEASED; urgency=medium
* s/watch Add watch file
* New upstream version 0.2.0 Closes: #927891
* d/p/* Update patches
-- Gert Wollny <gewo@debian.org> Sat, 27 Apr 2019 13:07:24 +0200
castxml (0.1+git20180702-3) unstable; urgency=medium
* d/rules: Add -latomic to libs on armel, clang requires it
......
Description: don't install license file
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -188,7 +188,6 @@
@@ -184,7 +184,6 @@
install(DIRECTORY share/castxml/ DESTINATION "${CastXML_INSTALL_DATA_DIR}")
install(FILES
......
Author: praetorian20@github
Description: Don't double link against certain llvm libraries
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -65,10 +65,18 @@
RunClang.cxx RunClang.h
Utils.cxx Utils.h
)
-target_link_libraries(castxml
- ${clang_libs}
- ${llvm_libs}
- )
+if (${LLVM_VERSION_MAJOR} LESS 6)
+ target_link_libraries(castxml
+ ${clang_libs}
+ ${llvm_libs}
+ )
+else()
+ target_link_libraries(castxml
+ ${clang_libs}
+ LLVM
+ )
+endif()
+
set_property(SOURCE Utils.cxx APPEND PROPERTY COMPILE_DEFINITIONS
"CASTXML_INSTALL_DATA_DIR=\"${CastXML_INSTALL_DATA_DIR}\"")
install(TARGETS castxml DESTINATION ${CastXML_INSTALL_RUNTIME_DIR})
diff --git a/README.rst b/README.rst
index dc25912..42990e8 100644
--- a/README.rst
+++ b/README.rst
@@ -46,7 +46,9 @@ To build CastXML from source, first obtain the prerequisites:
* `LLVM/Clang`_ compiler SDK install tree built using the C++ compiler.
This version of CastXML has been tested with LLVM/Clang
- - SVN revision ``319768`` (trunk)
+ - SVN revision ``346978`` (trunk)
+ - Release ``7.0``
+ - Release ``6.0``
- Release ``5.0``
- Release ``4.0``
- Release ``3.9``
diff --git a/share/castxml/detect_vs.c b/share/castxml/detect_vs.c
index eca94bc..baa0f79 100644
--- a/share/castxml/detect_vs.c
+++ b/share/castxml/detect_vs.c
@@ -20,6 +20,9 @@
#define TO_DEFINE(x) "#define " #x " " TO_STRING(x)
#pragma message("")
+#ifdef __ATOM__
+# pragma message(TO_DEFINE(__ATOM__))
+#endif
#ifdef __AVX__
# pragma message(TO_DEFINE(__AVX__))
#endif
@@ -32,6 +35,9 @@
#ifdef _CHAR_UNSIGNED
# pragma message(TO_DEFINE(_CHAR_UNSIGNED))
#endif
+#ifdef _CONTROL_FLOW_GUARD
+# pragma message(TO_DEFINE(_CONTROL_FLOW_GUARD))
+#endif
#ifdef _CPPRTTI
# pragma message(TO_DEFINE(_CPPRTTI))
#endif
@@ -47,6 +53,12 @@
#ifdef _INTEGRAL_MAX_BITS
# pragma message(TO_DEFINE(_INTEGRAL_MAX_BITS))
#endif
+#ifdef _ISO_VOLATILE
+# pragma message(TO_DEFINE(_ISO_VOLATILE))
+#endif
+#ifdef _KERNEL_MODE
+# pragma message(TO_DEFINE(_KERNEL_MODE))
+#endif
#ifdef _MANAGED
# pragma message(TO_DEFINE(_MANAGED))
#endif
@@ -77,6 +89,12 @@
#ifdef _M_ARM
# pragma message(TO_DEFINE(_M_ARM))
#endif
+#ifdef _M_ARM64
+# pragma message(TO_DEFINE(_M_ARM64))
+#endif
+#ifdef _M_ARM_ARMV7VE
+# pragma message(TO_DEFINE(_M_ARM_ARMV7VE))
+#endif
#ifdef _M_ARM_FP
# pragma message(TO_DEFINE(_M_ARM_FP))
#endif
@@ -89,6 +107,18 @@
#ifdef _M_CEE_SAFE
# pragma message(TO_DEFINE(_M_CEE_SAFE))
#endif
+#ifdef _M_FP_EXCEPT
+# pragma message(TO_DEFINE(_M_FP_EXCEPT))
+#endif
+#ifdef _M_FP_FAST
+# pragma message(TO_DEFINE(_M_FP_FAST))
+#endif
+#ifdef _M_FP_PRECISE
+# pragma message(TO_DEFINE(_M_FP_PRECISE))
+#endif
+#ifdef _M_FP_STRICT
+# pragma message(TO_DEFINE(_M_FP_STRICT))
+#endif
#ifdef _M_IA64
# pragma message(TO_DEFINE(_M_IA64))
#endif
@@ -116,6 +146,9 @@
#ifdef _OPENMP
# pragma message(TO_DEFINE(_OPENMP))
#endif
+#ifdef _PREFAST_
+# pragma message(TO_DEFINE(_PREFAST_))
+#endif
#ifdef _VC_NODEFAULTLIB
# pragma message(TO_DEFINE(_VC_NODEFAULTLIB))
#endif
@@ -128,6 +161,9 @@
#ifdef _WIN64
# pragma message(TO_DEFINE(_WIN64))
#endif
+#ifdef _WINRT_DLL
+# pragma message(TO_DEFINE(_WINRT_DLL))
+#endif
#ifdef _Wp64
# pragma message(TO_DEFINE(_Wp64))
#endif
@@ -137,3 +173,9 @@
#ifdef __MSVC_RUNTIME_CHECKS
# pragma message(TO_DEFINE(__MSVC_RUNTIME_CHECKS))
#endif
+#ifdef __STDC__
+# pragma message(TO_DEFINE(__STDC__))
+#endif
+#ifdef __STDC_HOSTED__
+# pragma message(TO_DEFINE(__STDC_HOSTED__))
+#endif
diff --git a/share/castxml/detect_vs.cpp b/share/castxml/detect_vs.cpp
index 2b24955..2c81137 100644
--- a/share/castxml/detect_vs.cpp
+++ b/share/castxml/detect_vs.cpp
@@ -20,6 +20,9 @@
#define TO_DEFINE(x) "#define " #x " " TO_STRING(x)
#pragma message("")
+#ifdef __ATOM__
+# pragma message(TO_DEFINE(__ATOM__))
+#endif
#ifdef __AVX__
# pragma message(TO_DEFINE(__AVX__))
#endif
@@ -32,6 +35,9 @@
#ifdef _CHAR_UNSIGNED
# pragma message(TO_DEFINE(_CHAR_UNSIGNED))
#endif
+#ifdef _CONTROL_FLOW_GUARD
+# pragma message(TO_DEFINE(_CONTROL_FLOW_GUARD))
+#endif
#ifdef _CPPRTTI
# pragma message(TO_DEFINE(_CPPRTTI))
#endif
@@ -47,6 +53,12 @@
#ifdef _INTEGRAL_MAX_BITS
# pragma message(TO_DEFINE(_INTEGRAL_MAX_BITS))
#endif
+#ifdef _ISO_VOLATILE
+# pragma message(TO_DEFINE(_ISO_VOLATILE))
+#endif
+#ifdef _KERNEL_MODE
+# pragma message(TO_DEFINE(_KERNEL_MODE))
+#endif
#ifdef _MANAGED
# pragma message(TO_DEFINE(_MANAGED))
#endif
@@ -80,6 +92,12 @@
#ifdef _M_ARM
# pragma message(TO_DEFINE(_M_ARM))
#endif
+#ifdef _M_ARM64
+# pragma message(TO_DEFINE(_M_ARM64))
+#endif
+#ifdef _M_ARM_ARMV7VE
+# pragma message(TO_DEFINE(_M_ARM_ARMV7VE))
+#endif
#ifdef _M_ARM_FP
# pragma message(TO_DEFINE(_M_ARM_FP))
#endif
@@ -92,6 +110,18 @@
#ifdef _M_CEE_SAFE
# pragma message(TO_DEFINE(_M_CEE_SAFE))
#endif
+#ifdef _M_FP_EXCEPT
+# pragma message(TO_DEFINE(_M_FP_EXCEPT))
+#endif
+#ifdef _M_FP_FAST
+# pragma message(TO_DEFINE(_M_FP_FAST))
+#endif
+#ifdef _M_FP_PRECISE
+# pragma message(TO_DEFINE(_M_FP_PRECISE))
+#endif
+#ifdef _M_FP_STRICT
+# pragma message(TO_DEFINE(_M_FP_STRICT))
+#endif
#ifdef _M_IA64
# pragma message(TO_DEFINE(_M_IA64))
#endif
@@ -119,6 +149,9 @@
#ifdef _OPENMP
# pragma message(TO_DEFINE(_OPENMP))
#endif
+#ifdef _PREFAST_
+# pragma message(TO_DEFINE(_PREFAST_))
+#endif
#ifdef _VC_NODEFAULTLIB
# pragma message(TO_DEFINE(_VC_NODEFAULTLIB))
#endif
@@ -131,6 +164,9 @@
#ifdef _WIN64
# pragma message(TO_DEFINE(_WIN64))
#endif
+#ifdef _WINRT_DLL
+# pragma message(TO_DEFINE(_WINRT_DLL))
+#endif
#ifdef _Wp64
# pragma message(TO_DEFINE(_Wp64))
#endif
@@ -140,6 +176,15 @@
#ifdef __MSVC_RUNTIME_CHECKS
# pragma message(TO_DEFINE(__MSVC_RUNTIME_CHECKS))
#endif
+#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
+# pragma message(TO_DEFINE(__STDCPP_DEFAULT_NEW_ALIGNMENT__))
+#endif
+#ifdef __STDCPP_STRICT_POINTER_SAFETY__
+# pragma message(TO_DEFINE(__STDCPP_STRICT_POINTER_SAFETY__))
+#endif
+#ifdef __STDCPP_THREADS__
+# pragma message(TO_DEFINE(__STDCPP_THREADS__))
+#endif
#ifdef __cplusplus
# pragma message(TO_DEFINE(__cplusplus))
#endif
diff --git a/src/RunClang.cxx b/src/RunClang.cxx
index 2bbcfcc..edf18a5 100644
--- a/src/RunClang.cxx
+++ b/src/RunClang.cxx
@@ -459,6 +459,15 @@ static clang::FrontendAction* CreateFrontendAction(clang::CompilerInstance* CI,
}
}
+static bool isObjC(clang::CompilerInstance* CI)
+{
+#if LLVM_VERSION_MAJOR >= 8
+ return CI->getLangOpts().ObjC;
+#else
+ return CI->getLangOpts().ObjC1 || CI->getLangOpts().ObjC2;
+#endif
+}
+
static bool runClangCI(clang::CompilerInstance* CI, Options const& opts)
{
// Create a diagnostics engine for this compiler instance.
@@ -472,7 +481,7 @@ static bool runClangCI(clang::CompilerInstance* CI, Options const& opts)
if (opts.GccXml) {
#define MSG(x) "error: '--castxml-gccxml' does not work with " x "\n"
- if (CI->getLangOpts().ObjC1 || CI->getLangOpts().ObjC2) {
+ if (isObjC(CI)) {
std::cerr << MSG("Objective C");
return false;
}
@@ -481,7 +490,7 @@ static bool runClangCI(clang::CompilerInstance* CI, Options const& opts)
if (opts.CastXml) {
#define MSG(x) "error: '--castxml-output=<v>' does not work with " x "\n"
- if (CI->getLangOpts().ObjC1 || CI->getLangOpts().ObjC2) {
+ if (isObjC(CI)) {
std::cerr << MSG("Objective C");
return false;
}
diff --git a/src/Utils.cxx b/src/Utils.cxx
index 1794671..a7b5245 100644
--- a/src/Utils.cxx
+++ b/src/Utils.cxx
@@ -147,12 +147,20 @@ bool runCommand(int argc, const char* const* argv, int& ret, std::string& out,
redirects[2] = &errFile;
#endif
+#if LLVM_VERSION_MAJOR >= 7
+ llvm::SmallVector<llvm::StringRef, 64> cmd(argv, argv + argc);
+ llvm::ArrayRef<llvm::StringRef> args = cmd;
+ llvm::Optional<llvm::ArrayRef<llvm::StringRef>> env = llvm::None;
+#else
std::vector<const char*> cmd(argv, argv + argc);
cmd.push_back(0);
+ const char** args = &*cmd.begin();
+ const char** env = nullptr;
+#endif
// Actually run the command.
- ret = llvm::sys::ExecuteAndWait(prog, &*cmd.begin(), nullptr, redirects, 0,
- 0, &msg, nullptr);
+ ret =
+ llvm::sys::ExecuteAndWait(prog, args, env, redirects, 0, 0, &msg, nullptr);
// Load the output from the temporary files.
{
diff --git a/src/castxml.cxx b/src/castxml.cxx
index 7c39e78..4989857 100644
--- a/src/castxml.cxx
+++ b/src/castxml.cxx
@@ -28,6 +28,10 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
+#if LLVM_VERSION_MAJOR >= 7
+#include "llvm/Support/InitLLVM.h"
+#endif
+
#include <iostream>
#include <set>
#include <sstream>
@@ -55,22 +59,29 @@ int main(int argc_in, const char** argv_in)
{
suppressInteractiveErrors();
- llvm::InitializeAllTargets();
- llvm::InitializeAllTargetMCs();
- llvm::InitializeAllAsmPrinters();
- llvm::InitializeAllAsmParsers();
-
+#if LLVM_VERSION_MAJOR >= 7
+ llvm::InitLLVM initLLVM(argc_in, argv_in);
+ llvm::SmallVector<const char*, 64> argv(argv_in, argv_in + argc_in);
+#else
llvm::SmallVector<const char*, 64> argv;
llvm::SpecificBumpPtrAllocator<char> argAlloc;
if (std::error_code e = llvm::sys::Process::GetArgumentVector(
argv, llvm::ArrayRef<const char*>(argv_in, argc_in), argAlloc)) {
llvm::errs() << "error: could not get arguments: " << e.message() << "\n";
return 1;
- } else if (argv.empty()) {
+ }
+#endif
+
+ if (argv.empty()) {
llvm::errs() << "error: no argv[0]?!\n";
return 1;
}
+ llvm::InitializeAllTargets();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllAsmPrinters();
+ llvm::InitializeAllAsmParsers();
+
#if LLVM_VERSION_MAJOR > 3 || \
LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8
llvm::BumpPtrAllocator argSaverAlloc;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1ad5ff1..cc72d78 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -394,6 +394,7 @@ castxml_test_cmd(cc-msvc-std-c++98 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc>
castxml_test_cmd(cc-msvc-std-c++11 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1600 ")" ${empty_cxx} "-###")
castxml_test_cmd(cc-msvc-std-c++14 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1900 ")" ${empty_cxx} "-###")
castxml_test_cmd(cc-msvc-std-c++17 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1900 -msvc_lang=201703L ")" ${empty_cxx} "-###")
+castxml_test_cmd(cc-msvc-std-c++17-E --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1900 -msvc_lang=201703L -stdcpp_default_new_alignment=16ll ")" ${empty_cxx} -E -dM)
castxml_test_cmd(cc-msvc-std-explicit --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1500 ")" -std=gnu++14 ${empty_cxx} "-###")
castxml_test_cmd(cc-msvc-builtin-1800-E --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1800 ")" ${empty_cxx} -E -dM)
castxml_test_cmd(cc-msvc-builtin-1900-E --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1900 ")" ${empty_cxx} -E -dM)
diff --git a/test/cc-msvc.c b/test/cc-msvc.c
index 45feff8..b20121e 100644
--- a/test/cc-msvc.c
+++ b/test/cc-msvc.c
@@ -6,14 +6,17 @@ int main(int argc, const char* argv[])
int cpp = 0;
const char* msc_ver = "1600";
const char* msvc_lang = 0;
+ const char* stdcpp_default_new_alignment = 0;
int i;
for (i = 1; i < argc; ++i) {
if (strncmp(argv[i], "--cc-define=", 12) == 0) {
fprintf(stdout, "\n#define %s 1", argv[i]+12);
} else if (strncmp(argv[i], "-msc=", 5) == 0) {
msc_ver = argv[i]+5;
- } else if (strncmp(argv[i], "-msvc_lang=", 8) == 0) {
+ } else if (strncmp(argv[i], "-msvc_lang=", 11) == 0) {
msvc_lang = argv[i]+11;
+ } else if (strncmp(argv[i], "-stdcpp_default_new_alignment=", 30) == 0) {
+ stdcpp_default_new_alignment = argv[i]+30;
} else if (strstr(argv[i], ".cpp")) {
cpp = 1;
}
@@ -34,6 +37,11 @@ int main(int argc, const char* argv[])
"#define _MSVC_LANG %s\n", msvc_lang
);
}
+ if(stdcpp_default_new_alignment) {
+ fprintf(stdout,
+ "#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ %s\n",
+ stdcpp_default_new_alignment);
+ }
fprintf(stdout,
"#define __has_include(x) x\n"
"#define __has_include_next(x) x\n"
diff --git a/test/expect/cmd.cc-msvc-std-c++17-E.stdout.txt b/test/expect/cmd.cc-msvc-std-c++17-E.stdout.txt
new file mode 100644
index 0000000..4015351
--- /dev/null
+++ b/test/expect/cmd.cc-msvc-std-c++17-E.stdout.txt
@@ -0,0 +1,11 @@
+^#define _MSC_VER 1900
+#define _MSVC_LANG 201703L
+#define _WIN32 1
+#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16ll
+#define __castxml__ [0-9]+
+#define __castxml_clang_major__ [0-9]+
+#define __castxml_clang_minor__ [0-9]+
+#define __castxml_clang_patchlevel__ [0-9]+
+#define __cplusplus 199711L
+#define __is_assignable\(_To,_Fr\) \(sizeof\(__castxml__is_assignable_check<_To,_Fr>\(0\)\) == sizeof\(char\(&\)\[1\]\)\)(
+#define __make_integer_seq __castxml__make_integer_seq)?$
0001-fix-version-test-to-allow-text-before-clang.patch
0002-dont-install-license-file.patch
0003-fix-dynamic-linking.patch
0004-llvm7.patch
version=3
# Uncomment to find new files on Github
# - when using releases:
opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/castxml-$1\.tar\.gz/ \
https://github.com/CastXML/CastXML/releases .*/archive/v(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz)
......@@ -52,11 +52,31 @@ for fpath in castxml_manuals:
name, desc, [], int(sec)))
else:
sys.stderr.write("ERROR: No castxml-manual-description in '%s'\n" % fpath)
except Exception, e:
except Exception as e:
sys.stderr.write("ERROR: %s\n" % str(e))
man_show_urls = False
html_show_sourcelink = True
html_theme = 'default'
html_theme_options = {
'footerbgcolor': '#00182d',
'footertextcolor': '#ffffff',
'sidebarbgcolor': '#e4ece8',
'sidebarbtncolor': '#00a94f',
'sidebartextcolor': '#333333',
'sidebarlinkcolor': '#00a94f',
'relbarbgcolor': '#00529b',
'relbartextcolor': '#ffffff',
'relbarlinkcolor': '#ffffff',
'bgcolor': '#ffffff',
'textcolor': '#444444',
'headbgcolor': '#f2f2f2',
'headtextcolor': '#003564',
'headlinkcolor': '#3d8ff2',
'linkcolor': '#2b63a8',
'visitedlinkcolor': '#2b63a8',
'codebgcolor': '#eeeeee',
'codetextcolor': '#333333',
}
html_title = 'CastXML %s Documentation' % release
html_short_title = '%s Documentation' % release
......@@ -79,6 +79,21 @@ Remaining options are given to the internal Clang compiler.
``--version``
Print ``castxml`` and internal Clang compiler version information.
Release versions of CastXML use the format::
<major>.<minor>.<patch>[-rc<n>][-<id>]
where the ``<patch>`` component is less than ``20000000``, ``<n>``
is an optional release candidate number, and ``<id>`` may contain
arbitrary text (in case of development between patch versions).
Development versions of CastXML use the format::
<major>.<minor>.<date>[-<id>]
where the ``<date>`` component is of format ``CCYYMMDD`` and ``<id>``
may contain arbitrary text. This represents development as of a
particular date following the ``<major>.<minor>`` feature release.
Output Format Versions
======================
......@@ -125,9 +140,23 @@ The ``--castxml-cc-<id>`` option switches the predefined macros
to match those detected from the given compiler command. In either
case, CastXML always adds the following predefined macros:
``__castxml_major__``
Defined to the CastXML major version number in decimal.
``__castxml_minor__``
Defined to the CastXML minor version number in decimal.
``__castxml_patch__``
Defined to the CastXML patch version number in decimal.
``__castxml_check(major,minor,patch)``
Defined to a constant expression encoding the three version components for
comparison with ``__castxml__``. The actual encoding is unspecified.
``__castxml__``
Defined to an integer encoding the CastXML version number as
``printf("%d%03d%03d",major,minor,patch)``.
Defined to a constant expression encoding the CastXML version components::
__castxml_check(__castxml_major__,__castxml_minor__,__castxml_patch__)
``__castxml_clang_major__``
Defined to the value of ``__clang_major__`` from the internal Clang.
......
......@@ -20,6 +20,9 @@
#define TO_DEFINE(x) "#define " #x " " TO_STRING(x)
#pragma message("")
#ifdef __ATOM__
# pragma message(TO_DEFINE(__ATOM__))
#endif
#ifdef __AVX__
# pragma message(TO_DEFINE(__AVX__))
#endif
......@@ -32,6 +35,9 @@
#ifdef _CHAR_UNSIGNED
# pragma message(TO_DEFINE(_CHAR_UNSIGNED))
#endif
#ifdef _CONTROL_FLOW_GUARD
# pragma message(TO_DEFINE(_CONTROL_FLOW_GUARD))
#endif
#ifdef _CPPRTTI
# pragma message(TO_DEFINE(_CPPRTTI))
#endif
......@@ -47,6 +53,12 @@
#ifdef _INTEGRAL_MAX_BITS
# pragma message(TO_DEFINE(_INTEGRAL_MAX_BITS))
#endif
#ifdef _ISO_VOLATILE
# pragma message(TO_DEFINE(_ISO_VOLATILE))
#endif
#ifdef _KERNEL_MODE
# pragma message(TO_DEFINE(_KERNEL_MODE))
#endif
#ifdef _MANAGED
# pragma message(TO_DEFINE(_MANAGED))
#endif
......@@ -77,6 +89,12 @@
#ifdef _M_ARM
# pragma message(TO_DEFINE(_M_ARM))
#endif
#ifdef _M_ARM64
# pragma message(TO_DEFINE(_M_ARM64))
#endif
#ifdef _M_ARM_ARMV7VE
# pragma message(TO_DEFINE(_M_ARM_ARMV7VE))
#endif
#ifdef _M_ARM_FP
# pragma message(TO_DEFINE(_M_ARM_FP))
#endif
......@@ -89,6 +107,18 @@
#ifdef _M_CEE_SAFE
# pragma message(TO_DEFINE(_M_CEE_SAFE))
#endif
#ifdef _M_FP_EXCEPT
# pragma message(TO_DEFINE(_M_FP_EXCEPT))
#endif
#ifdef _M_FP_FAST
# pragma message(TO_DEFINE(_M_FP_FAST))
#endif
#ifdef _M_FP_PRECISE
# pragma message(TO_DEFINE(_M_FP_PRECISE))
#endif
#ifdef _M_FP_STRICT
# pragma message(TO_DEFINE(_M_FP_STRICT))
#endif
#ifdef _M_IA64
# pragma message(TO_DEFINE(_M_IA64))
#endif
......@@ -116,6 +146,9 @@
#ifdef _OPENMP
# pragma message(TO_DEFINE(_OPENMP))
#endif
#ifdef _PREFAST_
# pragma message(TO_DEFINE(_PREFAST_))
#endif
#ifdef _VC_NODEFAULTLIB
# pragma message(TO_DEFINE(_VC_NODEFAULTLIB))
#endif
......@@ -128,6 +161,9 @@
#ifdef _WIN64
# pragma message(TO_DEFINE(_WIN64))
#endif
#ifdef _WINRT_DLL
# pragma message(TO_DEFINE(_WINRT_DLL))
#endif
#ifdef _Wp64
# pragma message(TO_DEFINE(_Wp64))
#endif
......@@ -137,3 +173,9 @@
#ifdef __MSVC_RUNTIME_CHECKS
# pragma message(TO_DEFINE(__MSVC_RUNTIME_CHECKS))
#endif
#ifdef __STDC__
# pragma message(TO_DEFINE(__STDC__))
#endif
#ifdef __STDC_HOSTED__
# pragma message(TO_DEFINE(__STDC_HOSTED__))
#endif
......@@ -20,6 +20,9 @@
#define TO_DEFINE(x) "#define " #x " " TO_STRING(x)
#pragma message("")
#ifdef __ATOM__
# pragma message(TO_DEFINE(__ATOM__))
#endif
#ifdef __AVX__
# pragma message(TO_DEFINE(__AVX__))
#endif
......@@ -32,6 +35,9 @@
#ifdef _CHAR_UNSIGNED
# pragma message(TO_DEFINE(_CHAR_UNSIGNED))
#endif
#ifdef _CONTROL_FLOW_GUARD
# pragma message(TO_DEFINE(_CONTROL_FLOW_GUARD))
#endif
#ifdef _CPPRTTI
# pragma message(TO_DEFINE(_CPPRTTI))
#endif
......@@ -47,6 +53,12 @@
#ifdef _INTEGRAL_MAX_BITS
# pragma message(TO_DEFINE(_INTEGRAL_MAX_BITS))
#endif
#ifdef _ISO_VOLATILE
# pragma message(TO_DEFINE(_ISO_VOLATILE))
#endif
#ifdef _KERNEL_MODE
# pragma message(TO_DEFINE(_KERNEL_MODE))
#endif
#ifdef _MANAGED
# pragma message(TO_DEFINE(_MANAGED))
#endif
......@@ -80,6 +92,12 @@
#ifdef _M_ARM
# pragma message(TO_DEFINE(_M_ARM))
#endif
#ifdef _M_ARM64
# pragma message(TO_DEFINE(_M_ARM64))
#endif
#ifdef _M_ARM_ARMV7VE
# pragma message(TO_DEFINE(_M_ARM_ARMV7VE))
#endif
#ifdef _M_ARM_FP
# pragma message(TO_DEFINE(_M_ARM_FP))
#endif
......@@ -92,6 +110,18 @@
#ifdef _M_CEE_SAFE
# pragma message(TO_DEFINE(_M_CEE_SAFE))
#endif
#ifdef _M_FP_EXCEPT
# pragma message(TO_DEFINE(_M_FP_EXCEPT))
#endif
#ifdef _M_FP_FAST
# pragma message(TO_DEFINE(_M_FP_FAST))
#endif
#ifdef _M_FP_PRECISE
# pragma message(TO_DEFINE(_M_FP_PRECISE))
#endif
#ifdef _M_FP_STRICT
# pragma message(TO_DEFINE(_M_FP_STRICT))
#endif
#ifdef _M_IA64
# pragma message(TO_DEFINE(_M_IA64))
#endif
......@@ -119,6 +149,9 @@
#ifdef _OPENMP
# pragma message(TO_DEFINE(_OPENMP))
#endif
#ifdef _PREFAST_
# pragma message(TO_DEFINE(_PREFAST_))
#endif
#ifdef _VC_NODEFAULTLIB
# pragma message(TO_DEFINE(_VC_NODEFAULTLIB))
#endif
......@@ -131,6 +164,9 @@
#ifdef _WIN64
# pragma message(TO_DEFINE(_WIN64))
#endif
#ifdef _WINRT_DLL
# pragma message(TO_DEFINE(_WINRT_DLL))
#endif
#ifdef _Wp64
# pragma message(TO_DEFINE(_Wp64))
#endif
......@@ -140,6 +176,15 @@
#ifdef __MSVC_RUNTIME_CHECKS
# pragma message(TO_DEFINE(__MSVC_RUNTIME_CHECKS))
#endif
#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
# pragma message(TO_DEFINE(__STDCPP_DEFAULT_NEW_ALIGNMENT__))
#endif
#ifdef __STDCPP_STRICT_POINTER_SAFETY__
# pragma message(TO_DEFINE(__STDCPP_STRICT_POINTER_SAFETY__))
#endif
#ifdef __STDCPP_THREADS__
# pragma message(TO_DEFINE(__STDCPP_THREADS__))
#endif
#ifdef __cplusplus
# pragma message(TO_DEFINE(__cplusplus))
#endif
......
......@@ -45,16 +45,13 @@ set(clang_libs
clangBasic
)
llvm_map_components_to_libnames(llvm_libs
set(llvm_libs
native
option
bitreader
support
${LLVM_TARGETS_TO_BUILD}
)
if(WIN32)
list(APPEND llvm_libs version.lib)
endif()
add_executable(castxml
castxml.cxx
......@@ -65,10 +62,12 @@ add_executable(castxml
RunClang.cxx RunClang.h
Utils.cxx Utils.h
)
target_link_libraries(castxml
${clang_libs}
${llvm_libs}
)
if(LLVM_LINK_LLVM_DYLIB)
set(USE_SHARED USE_SHARED)
endif()
llvm_config(castxml ${USE_SHARED} ${llvm_libs})
target_link_libraries(castxml PRIVATE ${clang_libs})
set_property(SOURCE Utils.cxx APPEND PROPERTY COMPILE_DEFINITIONS
"CASTXML_INSTALL_DATA_DIR=\"${CastXML_INSTALL_DATA_DIR}\"")
install(TARGETS castxml DESTINATION ${CastXML_INSTALL_RUNTIME_DIR})
......@@ -65,6 +65,7 @@ protected:
private:
typedef void (DumpQual::*bool_type)() const;
void bool_true() const {}
public:
bool IsConst;
bool IsVolatile;
......@@ -113,6 +114,7 @@ protected:
private:
typedef void (DumpId::*bool_type)() const;
void bool_true() const {}
public:
unsigned int Id;
DumpQual Qual;
......@@ -741,6 +743,17 @@ ASTVisitor::DumpId ASTVisitor::AddTypeDumpNode(DumpType dt, bool complete,
return this->AddTypeDumpNode(
DumpType(t->getAs<clang::DecayedType>()->getDecayedType(), c),
complete, dq);
case clang::Type::Decltype:
if (this->Opts.CastXml && t->isNullPtrType()) {
clang::DecltypeType const* dtt = t->getAs<clang::DecltypeType>();
if (dtt->getUnderlyingExpr()->getStmtClass() ==
clang::Stmt::CXXNullPtrLiteralExprClass) {
// Treat literal 'decltype(nullptr)' as a FundamentalType.
return this->AddTypeDumpNode(DumpType(dtt->getUnderlyingType(), c),
complete, dq);
}
}
break;
case clang::Type::Elaborated:
if (this->Opts.GccXml || !t->isElaboratedTypeSpecifier()) {
return this->AddTypeDumpNode(
......@@ -2092,6 +2105,9 @@ void ASTVisitor::OutputBuiltinType(clang::BuiltinType const* t,
case clang::BuiltinType::ULongLong:
name = "long long unsigned int";
break;
case clang::BuiltinType::NullPtr:
name = "decltype(nullptr)";
break;
default:
name = t->getName(this->PrintingPolicy).str();
break;
......
......@@ -211,10 +211,28 @@ protected:
std::string builtins;
// Add a builtin to identify CastXML itself.
// Add builtins to identify CastXML itself.
{
char castxml_version[64];
sprintf(castxml_version, "#define __castxml__ %u\n", getVersionValue());
sprintf(castxml_version, "#define __castxml_major__ %u\n",
getVersionMajor());
builtins += castxml_version;
sprintf(castxml_version, "#define __castxml_minor__ %u\n",
getVersionMinor());
builtins += castxml_version;
sprintf(castxml_version, "#define __castxml_patch__ %u\n",
getVersionPatch());
builtins += castxml_version;
}
// Encode the version number components to allow a date as the patch
// level and up to 1000 minor releases for each major release.
// These values can exceed a 32-bit unsigned integer, but we know
// that they will only be evaluated by our builtin clang.
builtins += "#define __castxml_check(major,minor,patch) "
"(10000000000*major + 100000000*minor + patch)\n";
builtins += "#define __castxml__ "
"__castxml_check(__castxml_major__,__castxml_minor__,"
"__castxml_patch__)\n";
// Add builtins to identify the internal Clang compiler.
builtins +=
......@@ -459,6 +477,15 @@ static clang::FrontendAction* CreateFrontendAction(clang::CompilerInstance* CI,
}
}
static bool isObjC(clang::CompilerInstance* CI)
{
#if LLVM_VERSION_MAJOR >= 8
return CI->getLangOpts().ObjC;
#else
return CI->getLangOpts().ObjC1 || CI->getLangOpts().ObjC2;
#endif
}
static bool runClangCI(clang::CompilerInstance* CI, Options const& opts)
{
// Create a diagnostics engine for this compiler instance.
......@@ -472,7 +499,7 @@ static bool runClangCI(clang::CompilerInstance* CI, Options const& opts)
if (opts.GccXml) {
#define MSG(x) "error: '--castxml-gccxml' does not work with " x "\n"
if (CI->getLangOpts().ObjC1 || CI->getLangOpts().ObjC2) {
if (isObjC(CI)) {
std::cerr << MSG("Objective C");
return false;
}
......@@ -481,7 +508,7 @@ static bool runClangCI(clang::CompilerInstance* CI, Options const& opts)
if (opts.CastXml) {
#define MSG(x) "error: '--castxml-output=<v>' does not work with " x "\n"
if (CI->getLangOpts().ObjC1 || CI->getLangOpts().ObjC2) {
if (isObjC(CI)) {
std::cerr << MSG("Objective C");
return false;
}
......
......@@ -102,10 +102,19 @@ std::string getVersionString()
return CASTXML_VERSION_STRING;
}
unsigned int getVersionValue()
unsigned int getVersionMajor()
{
return (CASTXML_VERSION_MAJOR * 1000000 + CASTXML_VERSION_MINOR * 1000 +
CASTXML_VERSION_PATCH * 1);
return CASTXML_VERSION_MAJOR;
}
unsigned int getVersionMinor()
{
return CASTXML_VERSION_MINOR;
}
unsigned int getVersionPatch()
{
return CASTXML_VERSION_PATCH;
}
bool runCommand(int argc, const char* const* argv, int& ret, std::string& out,
......@@ -147,12 +156,20 @@ bool runCommand(int argc, const char* const* argv, int& ret, std::string& out,
redirects[2] = &errFile;
#endif
#if LLVM_VERSION_MAJOR >= 7
llvm::SmallVector<llvm::StringRef, 64> cmd(argv, argv + argc);
llvm::ArrayRef<llvm::StringRef> args = cmd;
llvm::Optional<llvm::ArrayRef<llvm::StringRef>> env = llvm::None;
#else
std::vector<const char*> cmd(argv, argv + argc);
cmd.push_back(0);
const char** args = &*cmd.begin();
const char** env = nullptr;
#endif
// Actually run the command.
ret = llvm::sys::ExecuteAndWait(prog, &*cmd.begin(), nullptr, redirects, 0,
0, &msg, nullptr);
ret =
llvm::sys::ExecuteAndWait(prog, args, env, redirects, 0, 0, &msg, nullptr);
// Load the output from the temporary files.
{
......
......@@ -32,8 +32,14 @@ std::string getClangResourceDir();
/// getVersionString - Get the CastXML version string
std::string getVersionString();
/// getVersionValue - Get CastXML version encoded as %d%03d%03d
unsigned int getVersionValue();
/// getVersionMajor - Get CastXML major version.
unsigned int getVersionMajor();
/// getVersionMinor - Get CastXML minor version.
unsigned int getVersionMinor();
/// getVersionPatch - Get CastXML patch version.
unsigned int getVersionPatch();
/// runCommand - Run a given command line and capture the output.
bool runCommand(int argc, const char* const* argv, int& ret, std::string& out,
......
set(CastXML_VERSION "0.1")
# CastXML version number components.
set(CastXML_VERSION_MAJOR 0)
set(CastXML_VERSION_MINOR 2)
set(CastXML_VERSION_PATCH 0)
set(CastXML_VERSION_RC 0)
set(CastXML_VERSION_IS_DIRTY 0)
# Start with the full version number used in tags. It has no dev info.
set(CastXML_VERSION
"${CastXML_VERSION_MAJOR}.${CastXML_VERSION_MINOR}.${CastXML_VERSION_PATCH}")
if(CastXML_VERSION_RC)
set(CastXML_VERSION "${CastXML_VERSION}-rc${CastXML_VERSION_RC}")
endif()
if(EXISTS ${CastXML_SOURCE_DIR}/.git)
find_package(Git)
find_package(Git QUIET)
if(GIT_FOUND)
macro(_git)
execute_process(
......@@ -15,46 +27,43 @@ if(EXISTS ${CastXML_SOURCE_DIR}/.git)
endif()
endif()
if(EXISTS ${CastXML_SOURCE_DIR}/VERSION)
# Read version provided in file with source tarball.
file(STRINGS ${CastXML_SOURCE_DIR}/VERSION CastXML_VERSION
LIMIT_COUNT 1 LIMIT_INPUT 1024)
elseif(COMMAND _git)
# Compute version relative to annotated version tags, if any.
_git(describe --match "v[0-9]*" --dirty)
if(_git_out MATCHES "^v([0-9].*)$")
# Use version computed by 'git describe'.
set(CastXML_VERSION "${CMAKE_MATCH_1}")
# Try to identify the current development source version.
if(COMMAND _git)
# Get the commit checked out in this work tree.
_git(log -n 1 HEAD "--pretty=format:%h %s" --)
set(git_info "${_git_out}")
else()
# Compute version currently checked out, possibly dirty.
_git(rev-parse --verify -q --short=7 HEAD)
if(_git_out MATCHES "^([0-9a-f]+)$")
set(CastXML_VERSION "${CastXML_VERSION}-g${CMAKE_MATCH_1}")
# Get the commit exported by 'git archive'.
set(git_info "5ba47e3 CastXML 0.2.0")
endif()
# Extract commit information if available.
if(git_info MATCHES "^([0-9a-f]+) (.*)$")
set(git_hash "${CMAKE_MATCH_1}")
set(git_subject "${CMAKE_MATCH_2}")
# If this is not the exact commit of a release, add dev info.
if(NOT "${git_subject}" MATCHES "^[Cc]ast[Xx][Mm][Ll] ${CastXML_VERSION}$")
set(git_suffix "-g${git_hash}")
if(COMMAND _git)
# Use version suffix computed by 'git describe' if this version has been tagged.
_git(describe --tags --match "v${CastXML_VERSION}" HEAD)
if(_git_out MATCHES "^v${CastXML_VERSION}(-[0-9]+-g[0-9a-f]+)?$")
set(git_suffix "${CMAKE_MATCH_1}")
endif()
endif()
set(CastXML_VERSION "${CastXML_VERSION}${git_suffix}")
endif()
# If this is a work tree, check whether it is dirty.
if(COMMAND _git)
_git(update-index -q --refresh)
_git(diff-index --name-only HEAD --)
if(_git_out)
set(CastXML_VERSION "${CastXML_VERSION}-dirty")
endif()
else()
set(CastXML_VERSION "${CastXML_VERSION}-git")
endif()
endif()
elseif("db257aa" MATCHES "^([0-9a-f]+)$")
# Use version exported by 'git archive'.
set(CastXML_VERSION "${CastXML_VERSION}-g${CMAKE_MATCH_1}")
else()
elseif(NOT "${CastXML_VERSION_PATCH}" VERSION_LESS 20000000)
# Generic development version.
set(CastXML_VERSION "${CastXML_VERSION}-git")
endif()
if(CastXML_VERSION MATCHES "^([0-9]+)\\.([0-9]+)(\\.([0-9]+))?")
set(CastXML_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(CastXML_VERSION_MINOR "${CMAKE_MATCH_2}")
if(CMAKE_MATCH_4)
set(CastXML_VERSION_PATCH "${CMAKE_MATCH_4}")
else()
set(CastXML_VERSION_PATCH 0)
endif()
else()
message(FATAL_ERROR "Failed to extract version components from '${CastXML_VERSION}'")
endif()