Skip to content
Commits on Source (9)
......@@ -33,7 +33,11 @@ if(NOT CastXML_INSTALL_DATA_DIR)
set(CastXML_INSTALL_DATA_DIR share/castxml)
endif()
if(NOT CastXML_INSTALL_DOC_DIR)
set(CastXML_INSTALL_DOC_DIR share/doc/castxml)
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)
......@@ -55,12 +59,51 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${std_cxx11}")
endif()
find_package(LLVM REQUIRED)
macro(hint_clang_from_llvm)
if(LLVM_DIR AND NOT Clang_DIR)
if(LLVM_DIR MATCHES "share/llvm/cmake$")
# LLVM/Clang 3.8 installs in <prefix>/share/{llvm,clang}/cmake
get_filename_component(Clang_DIR "${LLVM_DIR}/../../clang/cmake" ABSOLUTE)
else()
# LLVM/Clang 3.9+ installs in <prefix>/lib/cmake/{llvm,clang}
get_filename_component(Clang_DIR "${LLVM_DIR}/../clang" ABSOLUTE)
endif()
endif()
endmacro()
macro(hint_llvm_from_clang)
if(Clang_DIR AND NOT LLVM_DIR)
if(Clang_DIR MATCHES "share/clang/cmake$")
# LLVM/Clang 3.8 installs in <prefix>/share/{llvm,clang}/cmake
get_filename_component(LLVM_DIR "${Clang_DIR}/../../llvm/cmake" ABSOLUTE)
else()
# LLVM/Clang 3.9+ installs in <prefix>/lib/cmake/{llvm,clang}
get_filename_component(LLVM_DIR "${Clang_DIR}/../llvm" ABSOLUTE)
endif()
endif()
endmacro()
# Build scripts may set either LLVM_DIR or Clang_DIR.
hint_llvm_from_clang()
hint_clang_from_llvm()
# Clang 3.8+ installs its own CMake package. Try it first.
find_package(Clang QUIET)
# If Clang did not find LLVM for us, give our search below a hint.
hint_llvm_from_clang()
# Clang 3.9+ automatically searches for LLVM. For older versions we
# may need to search for LLVM directly. Either way we require LLVM.
if(NOT LLVM_FOUND)
find_package(LLVM REQUIRED)
endif()
if(DEFINED LLVM_BUILD_BINARY_DIR)
message(FATAL_ERROR
"LLVM_DIR refers to a LLVM/Clang build directory:\n"
" ${LLVM_DIR}\n"
"Clang_DIR or LLVM_DIR refers to a LLVM/Clang build directory:\n"
" Clang_DIR=${Clang_DIR}\n"
" LLVM_DIR=${LLVM_DIR}\n"
"CastXML must be built against a LLVM/Clang install tree as "
"specified in\n"
" ${CastXML_SOURCE_DIR}/README.rst")
......@@ -68,7 +111,7 @@ endif()
set(found_clang 0)
set(tried_clang)
foreach(inc ${LLVM_INCLUDE_DIRS})
foreach(inc ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
if(EXISTS "${inc}/clang/AST/ASTConsumer.h")
set(found_clang 1)
break()
......@@ -78,14 +121,16 @@ foreach(inc ${LLVM_INCLUDE_DIRS})
endforeach()
if(NOT found_clang)
message(FATAL_ERROR
"LLVM_DIR refers to a LLVM installation:\n"
" ${LLVM_DIR}\n"
"Clang_DIR or LLVM_DIR refers to a LLVM/Clang installation:\n"
" Clang_DIR=${Clang_DIR}\n"
" LLVM_DIR=${LLVM_DIR}\n"
"that does not have `clang/` headers in any include directory:\n"
"${tried_clang}"
)
endif()
add_definitions(${LLVM_DEFINITIONS})
include_directories(${CLANG_INCLUDE_DIRS})
include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
if(NOT DEFINED LLVM_VERSION_PATCH)
......@@ -96,7 +141,19 @@ set(CLANG_RESOURCE_DIR "" CACHE PATH "Clang resource directory")
if(NOT CLANG_RESOURCE_DIR)
set(v ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH})
set(tried "")
set(dirs "")
foreach(d ${LLVM_LIBRARY_DIRS})
# Clang resources are typically inside LLVM's library directory.
list(APPEND dirs ${d})
# Some distros use a layout of the form
# <prefix>/lib/llvm/<major-version>/lib
# <prefix>/lib/clang/<full-version>/include
if("${d}" MATCHES "^(.*)/llvm/.*$")
list(APPEND dirs "${CMAKE_MATCH_1}")
endif()
endforeach()
# Look in each candidate directory for Clang resources.
foreach(d ${dirs})
if(IS_DIRECTORY "${d}/clang/${v}/include")
set(CLANG_RESOURCE_DIR ${d}/clang/${v})
break()
......
......@@ -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 ``280011``
- SVN revision ``319768`` (trunk)
- Release ``5.0``
- Release ``4.0``
- Release ``3.9``
- Release ``3.8``
- Release ``3.7``
......@@ -58,10 +60,10 @@ Run CMake on the CastXML source tree to generate a build tree using
a C++ compiler compatible with that used to build the LLVM/Clang SDK.
CMake options include:
``LLVM_DIR``
Location of the LLVM/Clang SDK.
Set to ``<prefix>/share/llvm/cmake``, where ``<prefix>`` is the top
of the LLVM/Clang SDK install tree.
``Clang_DIR``
Location of the LLVM/Clang SDK. Set to ``<prefix>/lib/cmake/clang``,
where ``<prefix>`` is the top of the LLVM/Clang SDK install tree.
Alternatively, ``LLVM_DIR`` may be set to ``<prefix>/lib/cmake/llvm``.
``SPHINX_EXECUTABLE``
Location of the ``sphinx-build`` executable.
......
castxml (0.1+git20180702-1) UNRELEASED; urgency=medium
* New upstream version 0.1+git20180702 Closes: #902811
* d/control: Update standards to 4.1.4 (no changes)
* d/copyright: Update url to use https
* d/p/0002: Add description
* d/p/0003: Fix linking issue with llvm >= 6.0
-- Gert Wollny <gewo@debian.org> Sun, 01 Jul 2018 17:33:11 +0200
castxml (0.1+git20170823-2) unstable; urgency=medium
* d/control: Build-dep on llvm default version, Closes: #893405
......
......@@ -10,9 +10,7 @@ Build-Depends: debhelper (>= 10),
llvm-dev,
libedit-dev,
zlib1g-dev
Standards-Version: 4.1.3
Vcs-Browser: https://anonscm.debian.org/cgit/debian-med/castxml.git
Vcs-Git: https://anonscm.debian.org/git/debian-med/castxml.git
Standards-Version: 4.1.4
Homepage: https://github.com/CastXML/CastXML
Package: castxml
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: CastXML
Upstream-Contact: castxml@public.kitware.com
Source: https://github.com/CastXML/CastXML
......
Description: dont install license file
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -118,7 +118,6 @@
......
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})
0001-fix-version-test-to-allow-text-before-clang.patch
0002-dont-install-license-file.patch
0003-fix-dynamic-linking.patch
......@@ -65,6 +65,9 @@
#ifdef _MSC_VER
# pragma message(TO_DEFINE(_MSC_VER))
#endif
#ifdef _MSVC_LANG
# pragma message(TO_DEFINE(_MSVC_LANG))
#endif
#ifdef _MT
# pragma message(TO_DEFINE(_MT))
#endif
......
......@@ -34,6 +34,7 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/raw_ostream.h"
#include <fstream>
......@@ -472,9 +473,10 @@ class ASTVisitor : public ASTVisitorBase
/** Output a function element using the name and flags given by
the caller. This encompasses functionality common to all the
function declaration output methods. */
void OutputFunctionHelper(clang::FunctionDecl const* d, DumpNode const* dn,
const char* tag, std::string const& name,
unsigned int flags);
void OutputFunctionHelper(
clang::FunctionDecl const* d, DumpNode const* dn, const char* tag,
unsigned int flags,
llvm::Optional<std::string> const& name = llvm::Optional<std::string>());
/** Output a function type element using the tag given by the caller.
This encompasses functionality common to all the function type
......@@ -512,6 +514,7 @@ class ASTVisitor : public ASTVisitorBase
void OutputClassTemplateSpecializationDecl(
clang::ClassTemplateSpecializationDecl const* d, DumpNode const* dn);
void OutputTypedefDecl(clang::TypedefDecl const* d, DumpNode const* dn);
void OutputTypeAliasDecl(clang::TypeAliasDecl const* d, DumpNode const* dn);
void OutputEnumDecl(clang::EnumDecl const* d, DumpNode const* dn);
void OutputFieldDecl(clang::FieldDecl const* d, DumpNode const* dn);
void OutputVarDecl(clang::VarDecl const* d, DumpNode const* dn);
......@@ -672,10 +675,6 @@ ASTVisitor::DumpId ASTVisitor::AddDeclDumpNode(clang::Decl const* d,
}
}
if (clang::dyn_cast<clang::TypeAliasDecl>(d)) {
return DumpId();
}
if (clang::dyn_cast<clang::TypeAliasTemplateDecl>(d)) {
return DumpId();
}
......@@ -732,6 +731,12 @@ ASTVisitor::DumpId ASTVisitor::AddTypeDumpNode(DumpType dt, bool complete,
return this->AddTypeDumpNode(
DumpType(t->getAs<clang::AttributedType>()->getEquivalentType(), c),
complete, dq);
case clang::Type::Auto: {
clang::AutoType const* at = t->getAs<clang::AutoType>();
if (at->isSugared()) {
return this->AddTypeDumpNode(DumpType(at->desugar(), c), complete, dq);
}
} break;
case clang::Type::Decayed:
return this->AddTypeDumpNode(
DumpType(t->getAs<clang::DecayedType>()->getDecayedType(), c),
......@@ -1442,6 +1447,18 @@ void ASTVisitor::GetDeclAttributes(clang::Decl const* d,
for (auto const* a : d->specific_attrs<clang::AnnotateAttr>()) {
attrs.push_back("annotate(" + a->getAnnotation().str() + ")");
}
if (d->hasAttr<clang::DeprecatedAttr>()) {
attrs.push_back("deprecated");
}
if (d->hasAttr<clang::DLLExportAttr>()) {
attrs.push_back("dllexport");
}
if (d->hasAttr<clang::DLLImportAttr>()) {
attrs.push_back("dllimport");
}
}
void ASTVisitor::PrintThrowsAttribute(clang::FunctionProtoType const* fpt,
......@@ -1508,13 +1525,13 @@ void ASTVisitor::PrintFloat128Type(DumpNode const* dn)
void ASTVisitor::OutputFunctionHelper(clang::FunctionDecl const* d,
DumpNode const* dn, const char* tag,
std::string const& name,
unsigned int flags)
unsigned int flags,
llvm::Optional<std::string> const& name)
{
this->OS << " <" << tag;
this->PrintIdAttribute(dn);
if (!name.empty()) {
this->PrintNameAttribute(name);
if (name) {
this->PrintNameAttribute(name.getValue());
}
if (flags & FH_Returns) {
this->PrintReturnsAttribute(d->getReturnType(), dn->Complete);
......@@ -1654,6 +1671,13 @@ void ASTVisitor::OutputFunctionArgument(clang::ParmVarDecl const* a,
this->PrintNameAttribute(name);
}
this->PrintTypeAttribute(a->getType(), complete);
if (a->getOriginalType() != a->getType()) {
this->OS << " original_type=\"";
this->PrintTypeIdRef(a->getOriginalType(), complete);
this->OS << "\"";
}
this->PrintLocationAttribute(a);
if (def) {
this->OS << " default=\"";
......@@ -1724,7 +1748,7 @@ void ASTVisitor::OutputRecordDecl(clang::RecordDecl const* d,
this->OS << " <" << tag;
this->PrintIdAttribute(dn);
if (!d->isAnonymousStructOrUnion()) {
if (!d->isAnonymousStructOrUnion() && !d->isLambda()) {
std::string s;
llvm::raw_string_ostream rso(s);
d->getNameForDiagnostic(rso, this->PrintingPolicy, false);
......@@ -1745,7 +1769,7 @@ void ASTVisitor::OutputRecordDecl(clang::RecordDecl const* d,
if (dx && dx->isAbstract()) {
this->OS << " abstract=\"1\"";
}
if (dn->Complete && !d->isInvalidDecl()) {
if (dn->Complete && !d->isInvalidDecl() && !d->isLambda()) {
this->PrintMembersAttribute(d);
doBases = dx && dx->getNumBases();
if (doBases) {
......@@ -1828,6 +1852,19 @@ void ASTVisitor::OutputTypedefDecl(clang::TypedefDecl const* d,
this->OS << "/>\n";
}
void ASTVisitor::OutputTypeAliasDecl(clang::TypeAliasDecl const* d,
DumpNode const* dn)
{
this->OS << " <Typedef";
this->PrintIdAttribute(dn);
this->PrintNameAttribute(d->getName().str());
this->PrintTypeAttribute(d->getUnderlyingType(), dn->Complete);
this->PrintContextAttribute(d);
this->PrintLocationAttribute(d);
this->PrintAttributesAttribute(d);
this->OS << "/>\n";
}
void ASTVisitor::OutputEnumDecl(clang::EnumDecl const* d, DumpNode const* dn)
{
this->OS << " <Enumeration";
......@@ -1927,10 +1964,10 @@ void ASTVisitor::OutputFunctionDecl(clang::FunctionDecl const* d,
}
if (d->isOverloadedOperator()) {
this->OutputFunctionHelper(
d, dn, "OperatorFunction",
clang::getOperatorSpelling(d->getOverloadedOperator()), flags);
d, dn, "OperatorFunction", flags,
std::string(clang::getOperatorSpelling(d->getOverloadedOperator())));
} else if (clang::IdentifierInfo const* ii = d->getIdentifier()) {
this->OutputFunctionHelper(d, dn, "Function", ii->getName().str(), flags);
this->OutputFunctionHelper(d, dn, "Function", flags, ii->getName().str());
} else {
this->OutputUnimplementedDecl(d, dn);
}
......@@ -1960,10 +1997,10 @@ void ASTVisitor::OutputCXXMethodDecl(clang::CXXMethodDecl const* d,
}
if (d->isOverloadedOperator()) {
this->OutputFunctionHelper(
d, dn, "OperatorMethod",
clang::getOperatorSpelling(d->getOverloadedOperator()), flags);
d, dn, "OperatorMethod", flags,
std::string(clang::getOperatorSpelling(d->getOverloadedOperator())));
} else if (clang::IdentifierInfo const* ii = d->getIdentifier()) {
this->OutputFunctionHelper(d, dn, "Method", ii->getName().str(), flags);
this->OutputFunctionHelper(d, dn, "Method", flags, ii->getName().str());
} else {
this->OutputUnimplementedDecl(d, dn);
}
......@@ -1988,7 +2025,7 @@ void ASTVisitor::OutputCXXConversionDecl(clang::CXXConversionDecl const* d,
if (d->isPure()) {
flags |= FH_Pure;
}
this->OutputFunctionHelper(d, dn, "Converter", "", flags);
this->OutputFunctionHelper(d, dn, "Converter", flags);
}
void ASTVisitor::OutputCXXConstructorDecl(clang::CXXConstructorDecl const* d,
......@@ -2004,8 +2041,8 @@ void ASTVisitor::OutputCXXConstructorDecl(clang::CXXConstructorDecl const* d,
if (d->isExplicit()) {
flags |= FH_Explicit;
}
this->OutputFunctionHelper(d, dn, "Constructor", this->GetContextName(d),
flags);
this->OutputFunctionHelper(d, dn, "Constructor", flags,
this->GetContextName(d));
}
void ASTVisitor::OutputCXXDestructorDecl(clang::CXXDestructorDecl const* d,
......@@ -2024,8 +2061,8 @@ void ASTVisitor::OutputCXXDestructorDecl(clang::CXXDestructorDecl const* d,
if (d->isPure()) {
flags |= FH_Pure;
}
this->OutputFunctionHelper(d, dn, "Destructor", this->GetContextName(d),
flags);
this->OutputFunctionHelper(d, dn, "Destructor", flags,
this->GetContextName(d));
}
void ASTVisitor::OutputBuiltinType(clang::BuiltinType const* t,
......@@ -2097,6 +2134,7 @@ void ASTVisitor::OutputLValueReferenceType(clang::LValueReferenceType const* t,
this->OS << " <ReferenceType";
this->PrintIdAttribute(dn);
this->PrintTypeAttribute(t->getPointeeType(), false);
this->PrintABIAttributes(this->CTX.getTypeInfo(t));
this->OS << "/>\n";
}
......@@ -2161,14 +2199,14 @@ void ASTVisitor::OutputStartXMLTags()
// Start dump with castxml-compatible format.
/* clang-format off */
this->OS <<
"<CastXML format=\"" << Opts.CastXmlEpicFormatVersion << ".1.0\">\n"
"<CastXML format=\"" << Opts.CastXmlEpicFormatVersion << ".1.5\">\n"
;
/* clang-format on */
} else if (this->Opts.GccXml) {
// Start dump with gccxml-compatible format (legacy).
/* clang-format off */
this->OS <<
"<GCC_XML version=\"0.9.0\" cvs_revision=\"1.140\">\n"
"<GCC_XML version=\"0.9.0\" cvs_revision=\"1.145\">\n"
;
/* clang-format on */
}
......
......@@ -123,6 +123,7 @@ public:
(m->isCopyAssignmentOperator() || m->isMoveAssignmentOperator());
}
if (mark) {
clang::DiagnosticErrorTrap Trap(sema.getDiagnostics());
/* Ensure the member is defined. */
sema.MarkFunctionReferenced(clang::SourceLocation(), m);
if (c && c->isDefaulted() && c->isDefaultConstructor() &&
......@@ -132,6 +133,9 @@ public:
until they are used. Force semantic checking. */
sema.DefineImplicitDefaultConstructor(clang::SourceLocation(), c);
}
if (Trap.hasErrorOccurred()) {
m->setInvalidDecl();
}
/* Finish implicitly instantiated member. */
sema.PerformPendingInstantiations();
}
......@@ -312,6 +316,17 @@ protected:
}
#endif
#if LLVM_VERSION_MAJOR < 6
if (this->NeedHasUniqueObjectRepresentations(this->Opts.Predefines,
CI)) {
// Clang 6 and above provide a __has_unique_object_representations
// builtin needed in C++17 mode. Provide an approximation for older
// Clang versions.
builtins += "\n"
"#define __has_unique_object_representations(x) false\n";
}
#endif
// Prevent glibc use of a GNU extension not implemented by Clang.
if (this->NeedNoMathInlines(this->Opts.Predefines)) {
builtins += "\n"
......@@ -356,6 +371,14 @@ protected:
#endif
}
#if LLVM_VERSION_MAJOR < 6
bool NeedHasUniqueObjectRepresentations(
std::string const& pd, clang::CompilerInstance const& CI) const
{
return (this->IsActualGNU(pd) && CI.getLangOpts().CPlusPlus1z);
}
#endif
bool NeedNoMathInlines(std::string const& pd) const
{
return (this->IsActualGNU(pd) &&
......@@ -364,8 +387,12 @@ protected:
pd.find("#define __NO_MATH_INLINES ") == pd.npos));
}
bool BeginSourceFileAction(clang::CompilerInstance& CI,
llvm::StringRef /*Filename*/)
bool BeginSourceFileAction(clang::CompilerInstance& CI
#if LLVM_VERSION_MAJOR < 5
,
llvm::StringRef /*Filename*/
#endif
) override
{
CI.getPreprocessor().setPredefines(this->UpdatePredefines(CI));
......@@ -641,7 +668,22 @@ int runClang(const char* const* argBeg, const char* const* argEnd,
msc_ver = 1600;
}
if (msc_ver >= 1900) {
args.push_back("-std=c++14");
long msvc_lang = 0;
if (const char* l = strstr(pd.c_str(), "#define _MSVC_LANG ")) {
l += 19;
if (const char* le = strchr(l, '\n')) {
if (*(le - 1) == '\r') {
--le;
}
std::string const msvc_lang_str(l, le - l);
msvc_lang = std::strtol(msvc_lang_str.c_str(), nullptr, 10);
}
}
if (msvc_lang >= 201703L) {
args.push_back("-std=c++17");
} else {
args.push_back("-std=c++14");
}
} else if (msc_ver >= 1600) {
args.push_back("-std=c++11");
} else {
......@@ -678,7 +720,13 @@ int runClang(const char* const* argBeg, const char* const* argEnd,
std_date = 0;
}
std_flag += "++";
if (std_date >= 201406L) {
if (std_date >= 201703L) {
#if LLVM_VERSION_MAJOR >= 5
std_flag += "17";
#else
std_flag += "1z";
#endif
} else if (std_date >= 201406L) {
std_flag += "1z";
} else if (std_date >= 201402L) {
std_flag += "14";
......
......@@ -18,6 +18,7 @@
#include "Version.h"
#include <fstream>
#include <llvm/ADT/Optional.h>
#include <llvm/ADT/SmallString.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/Path.h>
......@@ -134,10 +135,17 @@ bool runCommand(int argc, const char* const* argv, int& ret, std::string& out,
llvm::StringRef inFile; // empty means /dev/null
llvm::StringRef outFile = tmpOut.str();
llvm::StringRef errFile = tmpErr.str();
#if LLVM_VERSION_MAJOR >= 6
llvm::Optional<llvm::StringRef> redirects[3];
redirects[0] = inFile;
redirects[1] = outFile;
redirects[2] = errFile;
#else
llvm::StringRef const* redirects[3];
redirects[0] = &inFile;
redirects[1] = &outFile;
redirects[2] = &errFile;
#endif
std::vector<const char*> cmd(argv, argv + argc);
cmd.push_back(0);
......
......@@ -39,7 +39,7 @@ elseif(COMMAND _git)
set(CastXML_VERSION "${CastXML_VERSION}-git")
endif()
endif()
elseif("927c739" MATCHES "^([0-9a-f]+)$")
elseif("db257aa" MATCHES "^([0-9a-f]+)$")
# Use version exported by 'git archive'.
set(CastXML_VERSION "${CastXML_VERSION}-g${CMAKE_MATCH_1}")
else()
......
......@@ -60,10 +60,17 @@ macro(castxml_test_output_common prefix ext std test)
set(flag --castxml-output=1)
endif()
set(std_flag -std=${std})
if(LLVM_VERSION_MAJOR VERSION_LESS 5)
if("${std_flag}" MATCHES "^(.*)17$")
set(std_flag "${CMAKE_MATCH_1}1z")
endif()
endif()
set(command $<TARGET_FILE:castxml>
${flag}
${_castxml_start}
-std=${std}
${std_flag}
${CMAKE_CURRENT_LIST_DIR}/input/${_castxml_input}.${ext}
-o ${prefix}.${std}.${test}.xml
${castxml_test_output_extra_arguments}
......@@ -139,6 +146,16 @@ macro(castxml_test_output_gnuxx14 test)
castxml_test_output_common(castxml1 cxx gnu++14 ${test})
endmacro()
macro(castxml_test_output_cxx17 test)
castxml_test_output_common(gccxml cxx c++17 ${test})
castxml_test_output_common(castxml1 cxx c++17 ${test})
endmacro()
macro(castxml_test_output_gnuxx17 test)
castxml_test_output_common(gccxml cxx gnu++17 ${test})
castxml_test_output_common(castxml1 cxx gnu++17 ${test})
endmacro()
macro(castxml_test_output_broken_cxx98 test)
castxml_test_output_common(gccxml.broken cxx c++98 ${test})
castxml_test_output_common(castxml1.broken cxx c++98 ${test})
......@@ -169,6 +186,16 @@ macro(castxml_test_output_broken_gnuxx14 test)
castxml_test_output_common(castxml1.broken cxx gnu++14 ${test})
endmacro()
macro(castxml_test_output_broken_cxx17 test)
castxml_test_output_common(gccxml.broken cxx c++17 ${test})
castxml_test_output_common(castxml1.broken cxx c++17 ${test})
endmacro()
macro(castxml_test_output_broken_gnuxx17 test)
castxml_test_output_common(gccxml.broken cxx gnu++17 ${test})
castxml_test_output_common(castxml1.broken cxx gnu++17 ${test})
endmacro()
macro(castxml_test_output_c test)
castxml_test_output_c89(${test})
castxml_test_output_gnu89(${test})
......@@ -185,6 +212,33 @@ macro(castxml_test_output test)
castxml_test_output_gnuxx11(${test})
castxml_test_output_cxx14(${test})
castxml_test_output_gnuxx14(${test})
castxml_test_output_cxx17(${test})
castxml_test_output_gnuxx17(${test})
endmacro()
macro(castxml_test_output_11 test)
castxml_test_output_cxx11(${test})
castxml_test_output_gnuxx11(${test})
castxml_test_output_cxx14(${test})
castxml_test_output_gnuxx14(${test})
castxml_test_output_cxx17(${test})
castxml_test_output_gnuxx17(${test})
endmacro()
macro(castxml_test_output_14 test)
castxml_test_output_cxx14(${test})
castxml_test_output_gnuxx14(${test})
castxml_test_output_cxx17(${test})
castxml_test_output_gnuxx17(${test})
endmacro()
macro(castxml_test_output_14below test)
castxml_test_output_cxx98(${test})
castxml_test_output_gnuxx98(${test})
castxml_test_output_cxx11(${test})
castxml_test_output_gnuxx11(${test})
castxml_test_output_cxx14(${test})
castxml_test_output_gnuxx14(${test})
endmacro()
macro(castxml_test_output_broken test)
......@@ -194,6 +248,8 @@ macro(castxml_test_output_broken test)
castxml_test_output_broken_gnuxx11(${test})
castxml_test_output_broken_cxx14(${test})
castxml_test_output_broken_gnuxx14(${test})
castxml_test_output_broken_cxx17(${test})
castxml_test_output_broken_gnuxx17(${test})
endmacro()
set(input ${CMAKE_CURRENT_LIST_DIR}/input)
......@@ -238,6 +294,14 @@ castxml_test_cmd(castxml-and-c++11 --castxml-output=1 -std=c++11 ${empty_cxx})
castxml_test_cmd(gccxml-and-c++14 --castxml-gccxml -std=c++14 ${empty_cxx})
castxml_test_cmd(castxml-and-c++14 --castxml-output=1 -std=c++14 ${empty_cxx})
if(LLVM_VERSION_MAJOR VERSION_LESS 5)
castxml_test_cmd(gccxml-and-c++17 --castxml-gccxml -std=c++1z ${empty_cxx})
castxml_test_cmd(castxml-and-c++17 --castxml-output=1 -std=c++1z ${empty_cxx})
else()
castxml_test_cmd(gccxml-and-c++17 --castxml-gccxml -std=c++17 ${empty_cxx})
castxml_test_cmd(castxml-and-c++17 --castxml-output=1 -std=c++17 ${empty_cxx})
endif()
castxml_test_cmd(gccxml-and-objc1 --castxml-gccxml ${empty_m})
castxml_test_cmd(castxml-and-objc1 --castxml-output=1 ${empty_m})
......@@ -292,6 +356,15 @@ castxml_test_cmd(cc-gnu-std-c++14 --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -st
castxml_test_cmd(cc-gnu-std-gnu++98 --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> ")" ${empty_cxx} "-###")
castxml_test_cmd(cc-gnu-std-gnu++11 --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201103L ")" ${empty_cxx} "-###")
castxml_test_cmd(cc-gnu-std-gnu++14 --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201402L ")" ${empty_cxx} "-###")
if(LLVM_VERSION_MAJOR VERSION_LESS 5)
castxml_test_cmd(cc-gnu-std-c++1z --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201703L -ansi ")" ${empty_cxx} "-###")
castxml_test_cmd(cc-gnu-std-gnu++1z --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201703L ")" ${empty_cxx} "-###")
else()
castxml_test_cmd(cc-gnu-std-c++1z --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201406L -ansi ")" ${empty_cxx} "-###")
castxml_test_cmd(cc-gnu-std-c++17 --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201703L -ansi ")" ${empty_cxx} "-###")
castxml_test_cmd(cc-gnu-std-gnu++1z --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201406L ")" ${empty_cxx} "-###")
castxml_test_cmd(cc-gnu-std-gnu++17 --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201703L ")" ${empty_cxx} "-###")
endif()
castxml_test_cmd(cc-gnu-std-explicit --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=199901L ")" -std=c++14 ${empty_cxx} "-###")
castxml_test_cmd(cc-gnu-c-bad-cmd --castxml-cc-gnu-c "(" cc-gnu-c-bad-cmd ")" ${empty_c})
castxml_test_cmd(cc-gnu-c-src-c-E --castxml-cc-gnu-c $<TARGET_FILE:cc-gnu> ${empty_c} -E -dM)
......@@ -303,6 +376,7 @@ castxml_test_cmd(cc-gnu-c-std-gnu89 --castxml-cc-gnu-c "(" $<TARGET_FILE:cc-gnu>
castxml_test_cmd(cc-gnu-c-std-gnu99 --castxml-cc-gnu-c "(" $<TARGET_FILE:cc-gnu> -std=199901L ")" ${empty_c} "-###")
castxml_test_cmd(cc-gnu-c-std-gnu11 --castxml-cc-gnu-c "(" $<TARGET_FILE:cc-gnu> -std=201112L ")" ${empty_c} "-###")
castxml_test_cmd(cc-gnu-c-tgt-i386-opt-E --castxml-cc-gnu-c "(" $<TARGET_FILE:cc-gnu> --cc-define=__i386__ --cc-define=__OPTIMIZE__ ")" ${empty_c} -E -dM)
castxml_test_cmd(cc-gnu-builtin-unique-object-representations --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> -std=201703L ")" ${input}/has_unique_object_representations.cxx)
# Test --castxml-cc-msvc detection.
add_executable(cc-msvc cc-msvc.c)
......@@ -319,6 +393,7 @@ castxml_test_cmd(cc-msvc-tgt-x86_64 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc>
castxml_test_cmd(cc-msvc-std-c++98 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1500 ")" ${empty_cxx} "-###")
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-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)
......@@ -334,6 +409,7 @@ castxml_test_output(ArrayType-incomplete)
castxml_test_output(Class)
castxml_test_output(Class-abstract)
castxml_test_output(Class-annotate)
castxml_test_output(Class-deprecated)
castxml_test_output(Class-base-offset)
castxml_test_output(Class-base-typedef)
castxml_test_output(Class-bases)
......@@ -349,8 +425,10 @@ castxml_test_output(Class-implicit-member-reference)
castxml_test_output(Class-implicit-members)
castxml_test_output(Class-incomplete)
castxml_test_output(Class-incomplete-twice)
castxml_test_output(Class-member-Struct-anonymous)
castxml_test_output(Class-member-template)
castxml_test_output(Class-member-template-access)
castxml_test_output(Class-member-Union-anonymous)
castxml_test_output(Class-partial-template-member-Typedef)
castxml_test_output(Class-template)
castxml_test_output(Class-template-Method-Argument-const)
......@@ -366,28 +444,37 @@ castxml_test_output(Class-template-member-template)
castxml_test_output(Class-template-recurse)
castxml_test_output(Constructor)
castxml_test_output(Constructor-annotate)
castxml_test_output(Constructor-deprecated)
castxml_test_output(Converter)
castxml_test_output(Converter-annotate)
castxml_test_output(Converter-deprecated)
castxml_test_output(CvQualifiedType)
castxml_test_output(CXXLiteral)
castxml_test_output(Destructor)
castxml_test_output(Destructor-annotate)
castxml_test_output(Destructor-deprecated)
castxml_test_output(Elaborated)
castxml_test_output(Enumeration)
castxml_test_output(Enumeration-annotate)
castxml_test_output(Enumeration-deprecated)
castxml_test_output(Enumeration-anonymous)
castxml_test_output(Field)
castxml_test_output(Field-annotate)
castxml_test_output(Field-deprecated)
castxml_test_output(Function)
castxml_test_output_14(Function-auto)
castxml_test_output(Function-annotate)
castxml_test_output(Function-deprecated)
castxml_test_output(Function-Argument-annotate)
castxml_test_output(Function-Argument-deprecated)
castxml_test_output(Function-Argument-decay)
castxml_test_output(Function-Argument-default)
castxml_test_output(Function-Argument-default-cast)
castxml_test_output(Function-Argument-default-ns)
castxml_test_output_11(Function-lambda)
castxml_test_output(Function-rvalue-reference)
castxml_test_output(Function-template)
castxml_test_output(Function-throw)
castxml_test_output_14below(Function-throw)
castxml_test_output(Function-variadic)
castxml_test_output(FunctionType)
castxml_test_output(FunctionType-variadic)
......@@ -395,6 +482,7 @@ castxml_test_output(FundamentalType)
castxml_test_output(FundamentalTypes)
castxml_test_output(Method)
castxml_test_output(Method-annotate)
castxml_test_output(Method-deprecated)
castxml_test_output(Method-Argument-default)
castxml_test_output(Method-Argument-default-cast)
castxml_test_output(Method-overrides)
......@@ -419,26 +507,33 @@ castxml_test_output(OffsetType)
castxml_test_output(OffsetType-cv)
castxml_test_output(OperatorFunction)
castxml_test_output(OperatorFunction-annotate)
castxml_test_output(OperatorFunction-deprecated)
castxml_test_output(OperatorMethod)
castxml_test_output(OperatorMethod-annotate)
castxml_test_output(OperatorMethod-deprecated)
castxml_test_output(PointerType)
castxml_test_output(ReferenceType)
castxml_test_output(RValueReferenceType)
castxml_test_output(TypeAlias)
castxml_test_output(TypeAliasTemplate)
castxml_test_output(Typedef-annotate)
castxml_test_output(Typedef-deprecated)
castxml_test_output(Typedef-paren)
castxml_test_output(Typedef-to-Class-template)
castxml_test_output(Typedef-to-Enumeration)
castxml_test_output(Typedef-to-Enumeration-anonymous)
castxml_test_output(Typedef-to-FundamentalType-mode)
castxml_test_output(Typedef-to-extern-C-FundamentalType-mode)
castxml_test_output(Typedef-to-Struct-anonymous)
castxml_test_output(Typedef-to-Union-anonymous)
castxml_test_output(Variable)
castxml_test_output(Variable-annotate)
castxml_test_output(Variable-deprecated)
castxml_test_output(Variable-in-Class)
castxml_test_output(Variable-init)
castxml_test_output(Variable-init-cast)
castxml_test_output(Variable-init-ns)
castxml_test_output_11(Variable-lambda)
# Test multiple start declarations.
set(castxml_test_output_custom_input Namespace-nested)
......@@ -463,8 +558,29 @@ unset(castxml_test_output_custom_start)
if(";${LLVM_TARGETS_TO_BUILD};" MATCHES ";X86;")
set(castxml_test_output_extra_arguments -target i386-pc-windows-msvc)
castxml_test_output(Class-ms-dllexport)
castxml_test_output(Class-ms-dllimport)
castxml_test_output(Constructor-ms-dllexport)
castxml_test_output(Constructor-ms-dllimport)
castxml_test_output(Converter-ms-dllexport)
castxml_test_output(Converter-ms-dllimport)
castxml_test_output(Destructor-ms-dllexport)
castxml_test_output(Destructor-ms-dllimport)
castxml_test_output(Function-ms-dllexport)
castxml_test_output(Function-ms-dllimport)
castxml_test_output(Method-ms-dllexport)
castxml_test_output(Method-ms-dllimport)
castxml_test_output(OperatorFunction-ms-dllexport)
castxml_test_output(OperatorFunction-ms-dllimport)
castxml_test_output(OperatorMethod-ms-dllexport)
castxml_test_output(OperatorMethod-ms-dllimport)
castxml_test_output(Variable-ms-dllexport)
castxml_test_output(Variable-ms-dllimport)
castxml_test_output(Function-calling-convention-ms)
castxml_test_output(Function-calling-convention-ms-annotate)
castxml_test_output(Function-calling-convention-ms-deprecated)
castxml_test_output(Function-calling-convention-ms-dllexport)
castxml_test_output(Function-calling-convention-ms-dllimport)
castxml_test_output(implicit-decl-ms)
castxml_test_output(inline-asm-ms)
unset(castxml_test_output_extra_arguments)
......
......@@ -5,12 +5,15 @@ int main(int argc, const char* argv[])
{
int cpp = 0;
const char* msc_ver = "1600";
const char* msvc_lang = 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) {
msvc_lang = argv[i]+11;
} else if (strstr(argv[i], ".cpp")) {
cpp = 1;
}
......@@ -26,6 +29,11 @@ int main(int argc, const char* argv[])
fprintf(stdout,
"#define _MSC_VER %s\n", msc_ver
);
if(msvc_lang) {
fprintf(stdout,
"#define _MSVC_LANG %s\n", msvc_lang
);
}
fprintf(stdout,
"#define __has_include(x) x\n"
"#define __has_include_next(x) x\n"
......
......@@ -14,8 +14,8 @@
<Argument type="_11" location="f1:1" file="f1" line="1"/>
</Constructor>
<FundamentalType id="_9" name="int" size="[0-9]+" align="[0-9]+"/>
<ReferenceType id="_10" type="_1"/>
<ReferenceType id="_11" type="_1c"/>
<ReferenceType id="_10" type="_1" size="[0-9]+" align="[0-9]+"/>
<ReferenceType id="_11" type="_1c" size="[0-9]+" align="[0-9]+"/>
<CvQualifiedType id="_1c" type="_1" const="1"/>
<Namespace id="_2" name="::"/>
<File id="f1" name=".*/test/input/Class-abstract.cxx"/>
......
......@@ -9,9 +9,9 @@
<Argument type="_7" location="f1:1" file="f1" line="1"/>
</OperatorMethod>
<Destructor id="_6" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
<ReferenceType id="_7" type="_1c"/>
<ReferenceType id="_7" type="_1c" size="[0-9]+" align="[0-9]+"/>
<CvQualifiedType id="_1c" type="_1" const="1"/>
<ReferenceType id="_8" type="_1"/>
<ReferenceType id="_8" type="_1" size="[0-9]+" align="[0-9]+"/>
<Namespace id="_2" name="::"/>
<File id="f1" name=".*/test/input/Class-annotate.cxx"/>
</CastXML>$
......@@ -12,9 +12,9 @@
</OperatorMethod>
<Destructor id="_6" name="start" context="_1" access="public" location="f1:5" file="f1" line="5" inline="1" artificial="1"( throw="")?/>
<Class id="_7" name="base" context="_2" location="f1:1" file="f1" line="1" members="_10 _11 _12 _13" size="[0-9]+" align="[0-9]+"/>
<ReferenceType id="_8" type="_1c"/>
<ReferenceType id="_8" type="_1c" size="[0-9]+" align="[0-9]+"/>
<CvQualifiedType id="_1c" type="_1" const="1"/>
<ReferenceType id="_9" type="_1"/>
<ReferenceType id="_9" type="_1" size="[0-9]+" align="[0-9]+"/>
<Constructor id="_10" name="base" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
<Constructor id="_11" name="base" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?>
<Argument type="_14" location="f1:1" file="f1" line="1"/>
......@@ -23,9 +23,9 @@
<Argument type="_14" location="f1:1" file="f1" line="1"/>
</OperatorMethod>
<Destructor id="_13" name="base" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
<ReferenceType id="_14" type="_7c"/>
<ReferenceType id="_14" type="_7c" size="[0-9]+" align="[0-9]+"/>
<CvQualifiedType id="_7c" type="_7" const="1"/>
<ReferenceType id="_15" type="_7"/>
<ReferenceType id="_15" type="_7" size="[0-9]+" align="[0-9]+"/>
<Namespace id="_2" name="::"/>
<File id="f1" name=".*/test/input/Class-base-typedef.cxx"/>
</CastXML>$
^<\?xml version="1.0"\?>
<CastXML[^>]*>
<Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6" size="[0-9]+" align="[0-9]+" attributes="deprecated"/>
<Constructor id="_3" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
<Constructor id="_4" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?>
<Argument type="_7" location="f1:1" file="f1" line="1"/>
</Constructor>
<OperatorMethod id="_5" name="=" returns="_8" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")? mangled="[^"]+">
<Argument type="_7" location="f1:1" file="f1" line="1"/>
</OperatorMethod>
<Destructor id="_6" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
<ReferenceType id="_7" type="_1c" size="[0-9]+" align="[0-9]+"/>
<CvQualifiedType id="_1c" type="_1" const="1"/>
<ReferenceType id="_8" type="_1" size="[0-9]+" align="[0-9]+"/>
<Namespace id="_2" name="::"/>
<File id="f1" name=".*/test/input/Class-deprecated.cxx"/>
</CastXML>$
......@@ -9,9 +9,9 @@
<Argument type="_7" location="f1:7" file="f1" line="7"/>
</OperatorMethod>
<Destructor id="_6" name="start" context="_1" access="public" location="f1:8" file="f1" line="8"/>
<ReferenceType id="_7" type="_1c"/>
<ReferenceType id="_7" type="_1c" size="[0-9]+" align="[0-9]+"/>
<CvQualifiedType id="_1c" type="_1" const="1"/>
<ReferenceType id="_8" type="_1"/>
<ReferenceType id="_8" type="_1" size="[0-9]+" align="[0-9]+"/>
<Namespace id="_2" name="::"/>
<File id="f1" name=".*/test/input/Class-forward.cxx"/>
</CastXML>$