Skip to content

Commit 17e2df5

Browse files
committed
Port to LLVM/Clang SVN r370248 (trunk)
LLVM now compiles as C++14. It does not provide `llvm::make_unique`. The `clang::CompilerInvocation::CreateFromArgs` signature now accepts an `ArrayRef` for the argument range instead of iterators.
1 parent db74bd1 commit 17e2df5

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ if(CYGWIN OR MINGW)
127127
else()
128128
set(CMAKE_CXX_EXTENSIONS OFF)
129129
endif()
130-
set(CMAKE_CXX_STANDARD 11)
130+
if(LLVM_VERSION_MAJOR GREATER 9)
131+
set(CMAKE_CXX_STANDARD 14)
132+
else()
133+
set(CMAKE_CXX_STANDARD 11)
134+
endif()
131135

132136
add_definitions(${LLVM_DEFINITIONS})
133137
include_directories(${CLANG_INCLUDE_DIRS})

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ To build CastXML from source, first obtain the prerequisites:
4646
* `LLVM/Clang`_ compiler SDK install tree built using the C++ compiler.
4747
This version of CastXML has been tested with LLVM/Clang
4848

49-
- SVN revision ``356914`` (trunk)
49+
- SVN revision ``370248`` (trunk)
5050
- Release ``9.0``
5151
- Release ``8.0``
5252
- Release ``7.0``

src/RunClang.cxx

+15-3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
# define CASTXML_OWNS_OSTREAM
5757
#endif
5858

59+
#if LLVM_VERSION_MAJOR > 9
60+
# define CASTXML_MAKE_UNIQUE std::make_unique
61+
#else
62+
# define CASTXML_MAKE_UNIQUE llvm::make_unique
63+
#endif
64+
5965
class ASTConsumer : public clang::ASTConsumer
6066
{
6167
clang::CompilerInstance& CI;
@@ -443,11 +449,11 @@ class CastXMLSyntaxOnlyAction
443449
#ifdef CASTXML_OWNS_OSTREAM
444450
} else if (std::unique_ptr<llvm::raw_ostream> OS =
445451
CI.createDefaultOutputFile(false, filename(InFile), "xml")) {
446-
return llvm::make_unique<ASTConsumer>(CI, std::move(OS), this->Opts);
452+
return CASTXML_MAKE_UNIQUE<ASTConsumer>(CI, std::move(OS), this->Opts);
447453
#else
448454
} else if (llvm::raw_ostream* OS =
449455
CI.createDefaultOutputFile(false, filename(InFile), "xml")) {
450-
return llvm::make_unique<ASTConsumer>(CI, *OS, this->Opts);
456+
return CASTXML_MAKE_UNIQUE<ASTConsumer>(CI, *OS, this->Opts);
451457
#endif
452458
} else {
453459
return nullptr;
@@ -612,7 +618,13 @@ static int runClangImpl(const char* const* argBeg, const char* const* argEnd,
612618
const char* const* cmdArgBeg = cmd->getArguments().data();
613619
const char* const* cmdArgEnd = cmdArgBeg + cmd->getArguments().size();
614620
if (clang::CompilerInvocation::CreateFromArgs(
615-
CI->getInvocation(), cmdArgBeg, cmdArgEnd, *diags)) {
621+
CI->getInvocation(),
622+
#if LLVM_VERSION_MAJOR > 9
623+
llvm::makeArrayRef(cmdArgBeg, cmdArgEnd),
624+
#else
625+
cmdArgBeg, cmdArgEnd,
626+
#endif
627+
*diags)) {
616628
if (diags->hasErrorOccurred()) {
617629
return 1;
618630
}

0 commit comments

Comments
 (0)