Clang: Store the symbol kind in the database

It is cleaning up some other stuff too.

Change-Id: I75274356fd35f2ee8c84aedf8839c67506ab2355
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-04-05 10:58:33 +02:00
parent b0fd6c30ce
commit ee85cf4518
16 changed files with 60 additions and 102 deletions

View File

@@ -39,7 +39,6 @@ SOURCES += \
$$PWD/collectmacrossourcefilecallbacks.cpp \
$$PWD/symbolscollector.cpp \
$$PWD/clangquerygatherer.cpp \
$$PWD/symbolstorage.cpp \
$$PWD/symbolindexing.cpp \
$$PWD/indexdataconsumer.cpp

View File

@@ -54,6 +54,7 @@ public:
const Sqlite::Column &symbolIdColumn = table.addColumn("symbolId", Sqlite::ColumnType::Integer);
const Sqlite::Column &usrColumn = table.addColumn("usr", Sqlite::ColumnType::Text);
const Sqlite::Column &symbolNameColumn = table.addColumn("symbolName", Sqlite::ColumnType::Text);
table.addColumn("symbolKind", Sqlite::ColumnType::Integer);
table.addIndex({usrColumn, symbolNameColumn});
table.addIndex({symbolIdColumn});
@@ -115,7 +116,7 @@ public:
Sqlite::Table newUsedMacroTable{createNewUsedMacrosTable()};
Sqlite::Table newNewSourceDependenciesTable{createNewSourceDependenciesTable()};
WriteStatement insertSymbolsToNewSymbolsStatement{
"INSERT INTO newSymbols(temporarySymbolId, usr, symbolName) VALUES(?,?,?)",
"INSERT INTO newSymbols(temporarySymbolId, usr, symbolName, symbolKind) VALUES(?,?,?,?)",
database};
WriteStatement insertLocationsToNewLocationsStatement{
"INSERT OR IGNORE INTO newLocations(temporarySymbolId, line, column, sourceId) VALUES(?,?,?,?)",
@@ -126,8 +127,8 @@ public:
database
};
WriteStatement addNewSymbolsToSymbolsStatement{
"INSERT INTO symbols(usr, symbolName) "
"SELECT usr, symbolName FROM newSymbols WHERE NOT EXISTS "
"INSERT INTO symbols(usr, symbolName, symbolKind) "
"SELECT usr, symbolName, symbolKind FROM newSymbols WHERE NOT EXISTS "
"(SELECT usr FROM symbols WHERE symbols.usr == newSymbols.usr)",
database
};

View File

@@ -27,6 +27,8 @@
#include <stringcachefwd.h>
#include <clangsupport_global.h>
#include <utils/smallstring.h>
#include <utils/sizedarray.h>
@@ -38,27 +40,6 @@ namespace ClangBackEnd {
using SymbolIndex = long long;
enum class SymbolKind : uchar
{
None = 0,
Enumeration,
Record,
Function,
Variable,
Macro
};
enum class SymbolTag : uchar
{
None = 0,
Class,
Struct,
Union,
MsvcInterface
};
using SymbolTags = Utils::SizedArray<SymbolTag, 7>;
class SymbolEntry
{
public:

View File

@@ -1,30 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "symbolstorage.h"
namespace ClangBackEnd {
} // namespace ClangBackEnd

View File

@@ -201,7 +201,8 @@ public:
for (const auto &symbolEntry : symbolEntries) {
statement.write(symbolEntry.first,
symbolEntry.second.usr,
symbolEntry.second.symbolName);
symbolEntry.second.symbolName,
static_cast<uint>(symbolEntry.second.symbolKind));
}
}