Commit bd1c32c0 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Fix compiling llvm test cases with llvm/clang version 8.x

parent 1342755b
......@@ -156,7 +156,7 @@ find_package(Clang CONFIG)
if(NOT Clang_FOUND)
find_package(CLANG QUIET)
endif()
if(LLVM_FOUND AND (Clang_FOUND OR CLANG_FOUND) AND LLVM_VERSION VERSION_LESS "8.0.0")
if(LLVM_FOUND AND (Clang_FOUND OR CLANG_FOUND))
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
......@@ -173,20 +173,20 @@ if(LLVM_FOUND AND (Clang_FOUND OR CLANG_FOUND) AND LLVM_VERSION VERSION_LESS "8.
# Find the libraries that correspond to the LLVM components
# that we wish to use
if(LLVM_VERSION_MAJOR STREQUAL "7")
if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL "7.0.0")
set(llvm_libs LLVM)
else()
llvm_map_components_to_libnames(llvm_libs support core irreader analysis)
endif()
# Link against LLVM libraries
target_link_libraries(testllvm ${llvm_libs} clangFrontend clangTooling clangBasic)
target_link_libraries(testllvm ${llvm_libs} clangFrontend clangTooling clangBasic clangSerialization)
add_executable(testllvmparser testllvmparser.cpp)
if(NOT LLVM_VERSION_MAJOR STREQUAL "7")
if(LLVM_PACKAGE_VERSION VERSION_LESS "7.0.0")
llvm_map_components_to_libnames(llvm_libs support)
endif()
target_link_libraries(testllvmparser ${llvm_libs} clangFrontend clangTooling clangAST clangBasic ${LIBS})
target_link_libraries(testllvmparser ${llvm_libs} clangFrontend clangTooling clangAST clangBasic clangSerialization ${LIBS})
ecm_mark_nongui_executable(testllvm testllvmparser)
endif()
......
......@@ -20,6 +20,7 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include <clang/Basic/Version.h>
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Tooling/Tooling.h"
......@@ -46,7 +47,11 @@ public:
bool VisitCXXRecordDecl(CXXRecordDecl *Declaration)
{
if (Declaration->getQualifiedNameAsString() == "n::m::C") {
#if CLANG_VERSION_MAJOR >= 8
FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getBeginLoc());
#else
FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart());
#endif
if (FullLocation.isValid())
llvm::outs() << "Found declaration at "
<< FullLocation.getSpellingLineNumber() << ":"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment