Skip to content

Commit

Permalink
Don't update mLastCursor for unexposed cursors (and other unknowns).
Browse files Browse the repository at this point in the history
Otherwise the following example doesn't work:

struct crap
{
    ~crap()
    {}
};
struct fisk
{
struct C
{
    C(int) {}
    crap c;
};
};

int main(int argc, char **argv)
{
    fisk::C c = fisk::C(12);
    return 0;
}

struct crap
{
};
struct fisk
{
struct C
{
    C(int) {}
    crap c;
};
};

int main(int argc, char **argv)
{
    fisk::C c = fisk::C(12);
    return 0;
}

If crap has a destructor we get an unexposed expr between the callexpr
and the typeref and thus our callexpr constructor uglehack (see
ClangIndexer::indexVisitor) falls apart.
  • Loading branch information
Andersbakken committed Dec 13, 2016
1 parent f05f87f commit e378aba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.6)
project(rtags)
set(RTAGS_VERSION_MAJOR 2)
set(RTAGS_VERSION_MINOR 5)
set(RTAGS_VERSION_DATABASE 104)
set(RTAGS_VERSION_DATABASE 105)
set(RTAGS_VERSION_SOURCES_FILE 7)
set(RTAGS_VERSION ${RTAGS_VERSION_MAJOR}.${RTAGS_VERSION_MINOR}.${RTAGS_VERSION_DATABASE})

Expand Down
9 changes: 5 additions & 4 deletions src/ClangIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,6 @@ CXChildVisitResult ClangIndexer::visitorHelper(CXCursor cursor, CXCursor, CXClie

CXChildVisitResult ClangIndexer::indexVisitor(CXCursor cursor)
{
struct UpdateLastCursor {
~UpdateLastCursor() { func(); }
std::function<void()> func;
} call = { [this, cursor]() { mLastCursor = cursor; } };
++mCursorsVisited;
// error() << "indexVisitor" << cursor;
// FILE *f = fopen("/tmp/clangindex.log", "a");
Expand All @@ -692,6 +688,11 @@ CXChildVisitResult ClangIndexer::indexVisitor(CXCursor cursor)
return CXChildVisit_Recurse;
}

struct UpdateLastCursor {
~UpdateLastCursor() { func(); }
std::function<void()> func;
} call = { [this, cursor]() { mLastCursor = cursor; } };

bool blocked = false;

Location loc = createLocation(cursor, &blocked);
Expand Down

0 comments on commit e378aba

Please sign in to comment.