forked from qt-creator/qt-creator
Clang: Fix build with Clang/LLVM 10
Change-Id: I740286c9dcfd325b1c31ab863fb5c91bf9c6ec70 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
79612417e3
commit
44023c8f43
@@ -57,7 +57,11 @@ static clang::format::FormatStyle qtcStyle()
|
||||
style.AlignOperands = true;
|
||||
style.AlignTrailingComments = true;
|
||||
style.AllowAllParametersOfDeclarationOnNextLine = true;
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
|
||||
#else
|
||||
style.AllowShortBlocksOnASingleLine = false;
|
||||
#endif
|
||||
style.AllowShortCaseLabelsOnASingleLine = false;
|
||||
style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
|
||||
#if LLVM_VERSION_MAJOR >= 9
|
||||
@@ -72,7 +76,11 @@ static clang::format::FormatStyle qtcStyle()
|
||||
style.BinPackArguments = false;
|
||||
style.BinPackParameters = false;
|
||||
style.BraceWrapping.AfterClass = true;
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
|
||||
#else
|
||||
style.BraceWrapping.AfterControlStatement = false;
|
||||
#endif
|
||||
style.BraceWrapping.AfterEnum = false;
|
||||
style.BraceWrapping.AfterFunction = true;
|
||||
style.BraceWrapping.AfterNamespace = false;
|
||||
|
||||
@@ -60,6 +60,16 @@ public:
|
||||
diagnosticConsumer);
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
std::unique_ptr<clang::FrontendAction> create() override
|
||||
{
|
||||
return std::make_unique<CollectBuildDependencyAction>(
|
||||
m_buildDependency,
|
||||
m_filePathCache,
|
||||
m_excludedIncludeUIDs,
|
||||
m_alreadyIncludedFileUIDs);
|
||||
}
|
||||
#else
|
||||
clang::FrontendAction *create() override
|
||||
{
|
||||
return new CollectBuildDependencyAction(m_buildDependency,
|
||||
@@ -67,6 +77,7 @@ public:
|
||||
m_excludedIncludeUIDs,
|
||||
m_alreadyIncludedFileUIDs);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<uint> generateExcludedIncludeFileUIDs(clang::FileManager &fileManager) const
|
||||
{
|
||||
@@ -77,7 +88,11 @@ public:
|
||||
NativeFilePath nativeFilePath{filePath};
|
||||
const clang::FileEntry *file = fileManager.getFile({nativeFilePath.path().data(),
|
||||
nativeFilePath.path().size()},
|
||||
true);
|
||||
true)
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
.get()
|
||||
#endif
|
||||
;
|
||||
|
||||
if (file)
|
||||
fileUIDs.push_back(file->getUID());
|
||||
|
||||
@@ -61,6 +61,17 @@ public:
|
||||
diagnosticConsumer);
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
std::unique_ptr<clang::FrontendAction> create() override
|
||||
{
|
||||
return std::make_unique<CollectUsedMacrosAction>(
|
||||
m_usedMacros,
|
||||
m_filePathCache,
|
||||
m_sourceDependencies,
|
||||
m_sourceFiles,
|
||||
m_fileStatuses);
|
||||
}
|
||||
#else
|
||||
clang::FrontendAction *create() override
|
||||
{
|
||||
return new CollectUsedMacrosAction(m_usedMacros,
|
||||
@@ -69,6 +80,7 @@ public:
|
||||
m_sourceFiles,
|
||||
m_fileStatuses);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
UsedMacros &m_usedMacros;
|
||||
|
||||
@@ -68,10 +68,17 @@ public:
|
||||
, m_fileContent(fileContent)
|
||||
{}
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
std::unique_ptr<clang::FrontendAction> create() override
|
||||
{
|
||||
return std::make_unique<GeneratePCHAction>(m_filePath, m_fileContent);
|
||||
}
|
||||
#else
|
||||
clang::FrontendAction *create() override
|
||||
{
|
||||
return new GeneratePCHAction{m_filePath, m_fileContent};
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
llvm::StringRef m_filePath;
|
||||
|
||||
@@ -78,7 +78,8 @@ void ClangQuery::findLocations()
|
||||
std::make_move_iterator(asts.end()),
|
||||
[&] (std::unique_ptr<clang::ASTUnit> &&ast) {
|
||||
Diagnostics diagnostics;
|
||||
auto optionalMatcher = Parser::parseMatcherExpression({m_query.data(), m_query.size()},
|
||||
llvm::StringRef query{m_query.data(), m_query.size()};
|
||||
auto optionalMatcher = Parser::parseMatcherExpression(query,
|
||||
nullptr,
|
||||
&diagnostics);
|
||||
parseDiagnostics(diagnostics);
|
||||
|
||||
@@ -48,7 +48,11 @@ class CollectSymbolsAction : public clang::WrapperFrontendAction
|
||||
public:
|
||||
CollectSymbolsAction(std::shared_ptr<IndexDataConsumer> indexDataConsumer)
|
||||
: clang::WrapperFrontendAction(
|
||||
clang::index::createIndexingAction(indexDataConsumer, createIndexingOptions(), nullptr))
|
||||
clang::index::createIndexingAction(indexDataConsumer, createIndexingOptions()
|
||||
#if LLVM_VERSION_MAJOR < 10
|
||||
, nullptr
|
||||
#endif
|
||||
))
|
||||
, m_indexDataConsumer(indexDataConsumer)
|
||||
{}
|
||||
|
||||
|
||||
@@ -118,11 +118,16 @@ bool IndexDataConsumer::isAlreadyParsed(clang::FileID fileId, SourcesManager &so
|
||||
return sourcesManager.alreadyParsed(filePathId(fileEntry), fileEntry->getModificationTime());
|
||||
}
|
||||
|
||||
bool IndexDataConsumer::handleDeclOccurence(const clang::Decl *declaration,
|
||||
clang::index::SymbolRoleSet symbolRoles,
|
||||
llvm::ArrayRef<clang::index::SymbolRelation> /*symbolRelations*/,
|
||||
clang::SourceLocation sourceLocation,
|
||||
IndexDataConsumer::ASTNodeInfo /*astNodeInfo*/)
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
bool IndexDataConsumer::handleDeclOccurrence(
|
||||
#else
|
||||
bool IndexDataConsumer::handleDeclOccurence(
|
||||
#endif
|
||||
const clang::Decl *declaration,
|
||||
clang::index::SymbolRoleSet symbolRoles,
|
||||
llvm::ArrayRef<clang::index::SymbolRelation> /*symbolRelations*/,
|
||||
clang::SourceLocation sourceLocation,
|
||||
IndexDataConsumer::ASTNodeInfo /*astNodeInfo*/)
|
||||
{
|
||||
const auto *namedDeclaration = clang::dyn_cast<clang::NamedDecl>(declaration);
|
||||
if (namedDeclaration) {
|
||||
@@ -175,10 +180,15 @@ SourceLocationKind macroSymbolType(clang::index::SymbolRoleSet roles)
|
||||
|
||||
} // namespace
|
||||
|
||||
bool IndexDataConsumer::handleMacroOccurence(const clang::IdentifierInfo *identifierInfo,
|
||||
const clang::MacroInfo *macroInfo,
|
||||
clang::index::SymbolRoleSet roles,
|
||||
clang::SourceLocation sourceLocation)
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
bool IndexDataConsumer::handleMacroOccurrence(
|
||||
#else
|
||||
bool IndexDataConsumer::handleMacroOccurence(
|
||||
#endif
|
||||
const clang::IdentifierInfo *identifierInfo,
|
||||
const clang::MacroInfo *macroInfo,
|
||||
clang::index::SymbolRoleSet roles,
|
||||
clang::SourceLocation sourceLocation)
|
||||
{
|
||||
if (macroInfo && sourceLocation.isFileID()
|
||||
&& !isAlreadyParsed(m_sourceManager->getFileID(sourceLocation), m_macroSourcesManager)
|
||||
|
||||
@@ -57,16 +57,26 @@ public:
|
||||
IndexDataConsumer(const IndexDataConsumer &) = delete;
|
||||
IndexDataConsumer &operator=(const IndexDataConsumer &) = delete;
|
||||
|
||||
bool handleDeclOccurence(const clang::Decl *declaration,
|
||||
clang::index::SymbolRoleSet symbolRoles,
|
||||
llvm::ArrayRef<clang::index::SymbolRelation> symbolRelations,
|
||||
clang::SourceLocation sourceLocation,
|
||||
ASTNodeInfo astNodeInfo) override;
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
bool handleDeclOccurrence(
|
||||
#else
|
||||
bool handleDeclOccurence(
|
||||
#endif
|
||||
const clang::Decl *declaration,
|
||||
clang::index::SymbolRoleSet symbolRoles,
|
||||
llvm::ArrayRef<clang::index::SymbolRelation> symbolRelations,
|
||||
clang::SourceLocation sourceLocation,
|
||||
ASTNodeInfo astNodeInfo) override;
|
||||
|
||||
bool handleMacroOccurence(const clang::IdentifierInfo *identifierInfo,
|
||||
const clang::MacroInfo *macroInfo,
|
||||
clang::index::SymbolRoleSet roles,
|
||||
clang::SourceLocation sourceLocation) override;
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
bool handleMacroOccurrence(
|
||||
#else
|
||||
bool handleMacroOccurence(
|
||||
#endif
|
||||
const clang::IdentifierInfo *identifierInfo,
|
||||
const clang::MacroInfo *macroInfo,
|
||||
clang::index::SymbolRoleSet roles,
|
||||
clang::SourceLocation sourceLocation) override;
|
||||
|
||||
void finish() override;
|
||||
|
||||
|
||||
@@ -74,7 +74,11 @@ std::unique_ptr<clang::tooling::FrontendActionFactory> newFrontendActionFactory(
|
||||
: m_action(consumerFactory)
|
||||
{}
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
std::unique_ptr<clang::FrontendAction> create() override { return std::make_unique<AdaptorAction>(m_action); }
|
||||
#else
|
||||
clang::FrontendAction *create() override { return new AdaptorAction(m_action); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
class AdaptorAction : public clang::ASTFrontendAction
|
||||
|
||||
Reference in New Issue
Block a user