Primarily FrontendAction now gets passed as unique_ptr, but also StringRef was added in a few places. See https://releases.llvm.org/10.0.0/tools/clang/docs/ReleaseNotes.html#internal-api-changes and http://llvm.org/docs/ProgrammersManual.html#the-stringref-class Also, llvm::make_unique is now std::make_unique: https://reviews.llvm.org/D66259 because LLVM requires C++14.
This commit is contained in:
@@ -6,5 +6,6 @@ Eberhard Gräther (@egraether) <egraether@coati.io>
|
||||
Malte Langkabel (@mlangkabel) <mlangkabel@coati.io>
|
||||
Manuel Dobusch
|
||||
Viktoria Pfausler
|
||||
Louis St-Amour (@LouisStAmour) <LouisStAmour@gmail.com>
|
||||
|
||||
Note: (@user) means a github user name.
|
||||
|
||||
@@ -142,9 +142,10 @@ Building Sourcetrail requires several dependencies to be in place on your machin
|
||||
|
||||
### Required dependencies
|
||||
|
||||
* __LLVM/Clang 9.0.0__
|
||||
* __LLVM/Clang 10.0.0__
|
||||
* __Reason__: Used for running the preprocessor on the indexedes source code, building and traversing an Abstract Syntax Tree and generating error messages.
|
||||
* __Building for Windows__: Follow [these steps](https://clang.llvm.org/get_started.html) to build the project. Make sure to check out the correct tag and to run the cmake command exactly as described.
|
||||
* __Building__: Make sure to check out the correct tag: `git checkout llvmorg-10.0.0`
|
||||
* __Building for Windows__: Follow [these steps](https://clang.llvm.org/get_started.html) to build the project. Run the cmake command exactly as described.
|
||||
* __Building for Unix__: Follow this [installation guide](http://clang.llvm.org/docs/LibASTMatchersTutorial.html) to build the project. Make sure to build with `-DLLVM_ENABLE_RTTI=ON`.
|
||||
|
||||
### Building
|
||||
|
||||
@@ -55,7 +55,7 @@ make -j8 && \
|
||||
make -j8 install && rm -Rf /qt
|
||||
|
||||
# LLVM/Clang
|
||||
ARG LLVM_VERSION=9.0.0
|
||||
ARG LLVM_VERSION=10.0.0
|
||||
RUN mkdir -p /llvm && cd /llvm && \
|
||||
wget http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz && \
|
||||
tar xvf llvm-${LLVM_VERSION}.src.tar.xz && \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM coatisoftware/centos7_64_qt_llvm:qt5126-llvm900
|
||||
FROM coatisoftware/centos7_64_qt_llvm:qt5126-llvm1000
|
||||
|
||||
# TODO: remove after full image rebuilt ------------------------------------
|
||||
USER root
|
||||
|
||||
@@ -30,7 +30,7 @@ std::unique_ptr<clang::ASTConsumer> ASTAction::CreateASTConsumer(
|
||||
bool ASTAction::BeginSourceFileAction(clang::CompilerInstance& compiler)
|
||||
{
|
||||
clang::Preprocessor& preprocessor = compiler.getPreprocessor();
|
||||
preprocessor.addPPCallbacks(llvm::make_unique<PreprocessorCallbacks>(
|
||||
preprocessor.addPPCallbacks(std::make_unique<PreprocessorCallbacks>(
|
||||
compiler.getSourceManager(), m_client, m_canonicalFilePathCache));
|
||||
preprocessor.addCommentHandler(&m_commentHandler);
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "CanonicalFilePathCache.h"
|
||||
|
||||
#include <clang/AST/ASTContext.h>
|
||||
|
||||
#include <clang/Basic/FileManager.h>
|
||||
#include "utilityClang.h"
|
||||
#include "utilityString.h"
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <clang/Tooling/Tooling.h>
|
||||
#include <llvm/Option/ArgList.h>
|
||||
#include <llvm/Support/TargetSelect.h>
|
||||
#include <llvm/Support/Host.h>
|
||||
|
||||
#include "CxxCompilationDatabaseSingle.h"
|
||||
#include "CxxDiagnosticConsumer.h"
|
||||
@@ -44,8 +45,8 @@ ClangInvocationInfo ClangInvocationInfo::getClangInvocationString(
|
||||
const char* const BinaryName = Argv[0];
|
||||
clang::IntrusiveRefCntPtr<clang::DiagnosticOptions> DiagOpts = new clang::DiagnosticOptions();
|
||||
unsigned MissingArgIndex, MissingArgCount;
|
||||
std::unique_ptr<llvm::opt::OptTable> Opts = clang::driver::createDriverOptTable();
|
||||
llvm::opt::InputArgList ParsedArgs = Opts->ParseArgs(
|
||||
llvm::opt::OptTable Opts = clang::driver::getDriverOptTable();
|
||||
llvm::opt::InputArgList ParsedArgs = Opts.ParseArgs(
|
||||
clang::ArrayRef<const char*>(Argv).slice(1), MissingArgIndex, MissingArgCount);
|
||||
clang::ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ void CxxDiagnosticConsumer::HandleDiagnostic(
|
||||
{
|
||||
llvm::SmallString<100> messageStr;
|
||||
info.FormatDiagnostic(messageStr);
|
||||
std::string message = messageStr.str();
|
||||
std::string message = messageStr.str().str();
|
||||
|
||||
if (message ==
|
||||
"MS-style inline assembly is not available: Unable to find target for this triple (no "
|
||||
|
||||
@@ -41,7 +41,7 @@ std::vector<std::string> appendFilePath(const std::vector<std::string>& args, ll
|
||||
// custom implementation of clang::runToolOnCodeWithArgs which also sets our custon DiagnosticConsumer
|
||||
bool runToolOnCodeWithArgs(
|
||||
clang::DiagnosticConsumer* DiagConsumer,
|
||||
clang::FrontendAction* ToolAction,
|
||||
std::unique_ptr<clang::FrontendAction> ToolAction,
|
||||
const llvm::Twine& Code,
|
||||
const std::vector<std::string>& Args,
|
||||
const llvm::Twine& FileName = "input.cc",
|
||||
@@ -62,7 +62,7 @@ bool runToolOnCodeWithArgs(
|
||||
new clang::FileManager(clang::FileSystemOptions(), OverlayFileSystem));
|
||||
|
||||
clang::tooling::ToolInvocation Invocation(
|
||||
prependSyntaxOnlyToolArgs(appendFilePath(Args, FileNameRef)), ToolAction, Files.get());
|
||||
prependSyntaxOnlyToolArgs(appendFilePath(Args, FileNameRef)), std::move(ToolAction), Files.get());
|
||||
|
||||
llvm::SmallString<1024> CodeStorage;
|
||||
llvm::StringRef CodeRef = Code.toNullTerminatedStringRef(CodeStorage);
|
||||
@@ -155,13 +155,13 @@ void CxxParser::buildIndex(
|
||||
|
||||
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(
|
||||
FilePath(), canonicalFilePathCache, false);
|
||||
clang::ASTFrontendAction* action = new ASTAction(
|
||||
std::unique_ptr<clang::ASTFrontendAction> action = std::make_unique<ASTAction>(
|
||||
m_client, canonicalFilePathCache, m_indexerStateInfo);
|
||||
|
||||
std::vector<std::string> args = getCommandlineArgumentsEssential(compilerFlags);
|
||||
|
||||
runToolOnCodeWithArgs(
|
||||
diagnostics.get(), action, fileContent->getText(), args, utility::encodeToUtf8(fileName));
|
||||
diagnostics.get(), std::move(action), fileContent->getText(), args, utility::encodeToUtf8(fileName));
|
||||
}
|
||||
|
||||
void CxxParser::runTool(
|
||||
|
||||
@@ -38,12 +38,13 @@ private:
|
||||
#define TYPE(Class, Base) \
|
||||
case clang::TypeLoc::Class: \
|
||||
return STRINGIFY(Class);
|
||||
#include <clang/AST/TypeNodes.def>
|
||||
#include <clang/AST/TypeLoc.h>
|
||||
case clang::TypeLoc::TypeLocClass::Qualified:
|
||||
return "Qualified";
|
||||
}
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
FilePath m_currentFilePath;
|
||||
unsigned int m_indentation;
|
||||
|
||||
@@ -48,15 +48,15 @@ std::unique_ptr<clang::ASTConsumer> GeneratePCHAction::CreateASTConsumer(
|
||||
FrontendOpts.IncludeTimestamps,
|
||||
+CI.getLangOpts().CacheGeneratedPCH));
|
||||
Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
|
||||
CI, InFile, OutputFile, std::move(OS), Buffer));
|
||||
CI, InFile.str(), OutputFile, std::move(OS), Buffer));
|
||||
|
||||
return llvm::make_unique<clang::MultiplexConsumer>(std::move(Consumers));
|
||||
return std::make_unique<clang::MultiplexConsumer>(std::move(Consumers));
|
||||
}
|
||||
|
||||
bool GeneratePCHAction::BeginSourceFileAction(clang::CompilerInstance& compiler)
|
||||
{
|
||||
clang::Preprocessor& preprocessor = compiler.getPreprocessor();
|
||||
preprocessor.addPPCallbacks(llvm::make_unique<PreprocessorCallbacks>(
|
||||
preprocessor.addPPCallbacks(std::make_unique<PreprocessorCallbacks>(
|
||||
compiler.getSourceManager(), m_client, m_canonicalFilePathCache));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ SingleFrontendActionFactory::SingleFrontendActionFactory(clang::FrontendAction*
|
||||
{
|
||||
}
|
||||
|
||||
clang::FrontendAction* SingleFrontendActionFactory::create()
|
||||
std::unique_ptr<clang::FrontendAction> SingleFrontendActionFactory::create()
|
||||
{
|
||||
return m_action;
|
||||
return std::unique_ptr<clang::FrontendAction>(m_action);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class SingleFrontendActionFactory: public clang::tooling::FrontendActionFactory
|
||||
{
|
||||
public:
|
||||
SingleFrontendActionFactory(clang::FrontendAction* action);
|
||||
clang::FrontendAction* create() override;
|
||||
std::unique_ptr<clang::FrontendAction> create() override;
|
||||
|
||||
private:
|
||||
clang::FrontendAction* m_action;
|
||||
|
||||
@@ -29,7 +29,7 @@ std::unique_ptr<CxxName> CxxSpecifierNameResolver::getName(
|
||||
case clang::NestedNameSpecifier::Identifier:
|
||||
{
|
||||
std::unique_ptr<CxxName> name = std::make_unique<CxxDeclName>(
|
||||
utility::decodeFromUtf8(nestedNameSpecifier->getAsIdentifier()->getName()));
|
||||
utility::decodeFromUtf8(nestedNameSpecifier->getAsIdentifier()->getName().str()));
|
||||
|
||||
if (const clang::NestedNameSpecifier* prefix = nestedNameSpecifier->getPrefix())
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ std::wstring CxxTemplateParameterStringResolver::getTemplateParameterString(
|
||||
break;
|
||||
}
|
||||
|
||||
const std::wstring parameterName = utility::decodeFromUtf8(parameter->getName());
|
||||
const std::wstring parameterName = utility::decodeFromUtf8(parameter->getName().str());
|
||||
if (!parameterName.empty())
|
||||
{
|
||||
templateParameterTypeString += L' ' + parameterName;
|
||||
|
||||
@@ -125,7 +125,7 @@ std::unique_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
pp.Bool = true; // value "true": prints bool type as "bool" instead of "_Bool"
|
||||
|
||||
return std::make_unique<CxxTypeName>(
|
||||
utility::decodeFromUtf8(type->getAs<clang::BuiltinType>()->getName(pp)),
|
||||
utility::decodeFromUtf8(type->getAs<clang::BuiltinType>()->getName(pp).str()),
|
||||
std::vector<std::wstring>());
|
||||
}
|
||||
case clang::Type::TemplateSpecialization:
|
||||
@@ -285,7 +285,7 @@ std::unique_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
clang::SmallString<64> Buf;
|
||||
llvm::raw_svector_ostream StrOS(Buf);
|
||||
clang::QualType::print(type, clang::Qualifiers(), StrOS, pp, clang::Twine());
|
||||
std::wstring nameString = utility::decodeFromUtf8(StrOS.str());
|
||||
std::wstring nameString = utility::decodeFromUtf8(StrOS.str().str());
|
||||
|
||||
return std::make_unique<CxxTypeName>(std::move(nameString));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <clang/AST/DeclCXX.h>
|
||||
#include <clang/AST/DeclTemplate.h>
|
||||
#include <clang/Lex/Preprocessor.h>
|
||||
#include <clang/Basic/FileManager.h>
|
||||
|
||||
#include "CanonicalFilePathCache.h"
|
||||
#include "FilePath.h"
|
||||
@@ -130,10 +131,10 @@ std::wstring utility::getFileNameOfFileEntry(const clang::FileEntry* entry)
|
||||
std::wstring fileName = L"";
|
||||
if (entry != nullptr && entry->isValid())
|
||||
{
|
||||
fileName = utility::decodeFromUtf8(entry->tryGetRealPathName());
|
||||
fileName = utility::decodeFromUtf8(entry->tryGetRealPathName().str());
|
||||
if (fileName.empty())
|
||||
{
|
||||
fileName = utility::decodeFromUtf8(entry->getName());
|
||||
fileName = utility::decodeFromUtf8(entry->getName().str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user