ClangRefactoring: Don't update the database if something went wrong

We can get an compile error. In that case we should not update the
database. In the future we should have a mechanism to report about the
database state.

Task-number: QTCREATORBUG-21949
Change-Id: I203346d536b007171f7bf255047409431c44a85a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2019-02-07 12:20:51 +01:00
parent c52c531c3f
commit 97ec6b9ad2
9 changed files with 154 additions and 56 deletions

View File

@@ -124,33 +124,23 @@ bool IndexDataConsumer::skipSymbol(clang::FileID fileId, clang::index::SymbolRol
return isParsedDeclaration || isParsedReference;
}
bool IndexDataConsumer::handleDeclOccurence(const clang::Decl *declaration,
clang::index::SymbolRoleSet symbolRoles,
llvm::ArrayRef<clang::index::SymbolRelation> symbolRelations,
#if LLVM_VERSION_MAJOR >= 7
clang::SourceLocation sourceLocation,
#else
clang::FileID fileId,
unsigned offset,
#endif
IndexDataConsumer::ASTNodeInfo astNodeInfo)
bool IndexDataConsumer::handleDeclOccurence(
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) {
if (!namedDeclaration->getIdentifier())
return true;
#if LLVM_VERSION_MAJOR >= 7
if (skipSymbol(m_sourceManager->getFileID(sourceLocation), symbolRoles))
#else
if (skipSymbol(fileId, symbolRoles))
#endif
return true;
SymbolIndex globalId = toSymbolIndex(declaration->getCanonicalDecl());
#if LLVM_VERSION_MAJOR < 7
clang::SourceLocation sourceLocation = m_sourceManager->getLocForStartOfFile(fileId).getLocWithOffset(offset);
#endif
auto found = m_symbolEntries.find(globalId);
if (found == m_symbolEntries.end()) {