Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an isDefn field to the tags table in the database (and fix a warning) #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/Modules/FindLibclang.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
find_path (Libclang_INCLUDE_DIR clang-c/Index.h
HINTS "${LIBCLANG_ROOT}/include"
PATH "/usr/lib/llvm-3.2/include")
PATH "/usr/lib/llvm-3.5/include")

find_library (Libclang_LIBRARY clang
HINTS "${LIBCLANG_ROOT}/lib"
PATH "/usr/lib/llvm-3.2/lib")
PATH "/usr/lib/llvm-3.5/lib")

set (Libclang_LIBRARIES ${Libclang_LIBRARY})
set (Libclang_INCLUDE_DIRS ${Libclang_INCLUDE_DIR})
Expand Down
2 changes: 1 addition & 1 deletion index.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Indexer : public LibClang::Visitor<Indexer> {
storage_.addTag (usr, cursor.kindStr(), cursor.spelling(), fileName,
begin.line, begin.column, begin.offset,
end.line, end.column, end.offset,
cursor.isDeclaration());
cursor.isDeclaration(), cursor.isDefinition());
}

return CXChildVisit_Recurse;
Expand Down
4 changes: 4 additions & 0 deletions libclang++/cursor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ namespace LibClang {
return clang_isDeclaration(clang_getCursorKind(raw()));
}

bool Cursor::isDefinition () const {
return clang_isCursorDefinition(raw());
}

Cursor Cursor::referenced () const {
return clang_getCursorReferenced (raw());
}
Expand Down
6 changes: 6 additions & 0 deletions libclang++/cursor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ namespace LibClang {
*/
bool isDeclaration () const;

/** @brief Determine whether the cursor represents a definition
*
* @return true if the cursor represents a definition
*/
bool isDefinition () const;

/** @brief Get the cursor referenced
*
* For cursors which represent references to other entities in the AST,
Expand Down
2 changes: 1 addition & 1 deletion request/request.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ namespace Request {

virtual void set (const Json::Value & json) {
destination_.resize (json.size());
for (int i = 0 ; i<json.size() ; ++i) {
for (unsigned i = 0 ; i<json.size() ; ++i) {
setValue (json[i], destination_[i]);
}
}
Expand Down
10 changes: 6 additions & 4 deletions storage.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public:
" line2 INTEGER,"
" col2 INTEGER,"
" offset2 INTEGER,"
" isDecl BOOLEAN"
" isDecl BOOLEAN,"
" isDefn BOOLEAN"
")");
db_.execute ("CREATE TABLE IF NOT EXISTS options ( "
" name TEXT, "
Expand Down Expand Up @@ -220,7 +221,8 @@ public:
const std::string & fileName,
const int line1, const int col1, const int offset1,
const int line2, const int col2, const int offset2,
bool isDeclaration) {
bool isDeclaration,
bool isDefinition) {
int fileId = fileId_ (fileName);
if (fileId == -1) {
return;
Expand All @@ -234,11 +236,11 @@ public:
" AND offset2=?")
.bind (fileId).bind (usr).bind (offset1).bind (offset2);
if (stmt.step() == SQLITE_DONE) { // no matching row
db_.prepare ("INSERT INTO tags VALUES (?,?,?,?,?,?,?,?,?,?,?)")
db_.prepare ("INSERT INTO tags VALUES (?,?,?,?,?,?,?,?,?,?,?,?)")
.bind(fileId) .bind(usr) .bind(kind) .bind(spelling)
.bind(line1) .bind(col1) .bind(offset1)
.bind(line2) .bind(col2) .bind(offset2)
.bind(isDeclaration)
.bind(isDeclaration) .bind(isDefinition)
.step();
}
}
Expand Down