Skip to content

Commit

Permalink
Fix bug introduced by fix for rtags/tests/nestedClassConstructorCallU…
Browse files Browse the repository at this point in the history
…gleHack,

For the following example rtags jumps to the wrong location for Bar bar

struct Bar
{
    Bar(const std::string& str)
    {
    }
};

int main()
{
    auto faen = []() { return std::string(); };
    Bar bar(faen());
    return 14;
}
  • Loading branch information
jhanssen committed Mar 7, 2017
1 parent ec6d0dc commit 2089bd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 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 8)
set(RTAGS_VERSION_DATABASE 115)
set(RTAGS_VERSION_DATABASE 116)
set(RTAGS_VERSION_SOURCES_FILE 7)
set(RTAGS_VERSION ${RTAGS_VERSION_MAJOR}.${RTAGS_VERSION_MINOR}.${RTAGS_VERSION_DATABASE})

Expand Down
23 changes: 18 additions & 5 deletions src/ClangIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,12 +769,25 @@ CXChildVisitResult ClangIndexer::indexVisitor(CXCursor cursor)
Location oldLoc;
std::swap(mLastCallExprSymbol, old);
const CXCursor ref = clang_getCursorReferenced(cursor);
bool handled = false;
if (clang_getCursorKind(ref) == CXCursor_Constructor
&& (clang_getCursorKind(mLastCursor) == CXCursor_TypeRef || clang_getCursorKind(mLastCursor) == CXCursor_TemplateRef)
&& clang_getCursorKind(mParents.back()) != CXCursor_VarDecl) {
loc = createLocation(mLastCursor);
handleReference(mLastCursor, kind, loc, ref);
} else {
&& (clang_getCursorKind(mLastCursor) == CXCursor_TypeRef || clang_getCursorKind(mLastCursor) == CXCursor_TemplateRef)) {
handled = true;
for (int pos = mParents.size() - 1; pos >= 0; --pos) {
const CXCursorKind k = clang_getCursorKind(mParents[pos]);
if (k == CXCursor_VarDecl) {
handled = false;
break;
} else if (k != CXCursor_UnexposedExpr) {
break;
}
}
if (handled) {
loc = createLocation(mLastCursor);
handleReference(mLastCursor, kind, loc, ref);
}
}
if (!handled) {
handleReference(cursor, kind, loc, ref);
}
List<Symbol::Argument> destArguments;
Expand Down

0 comments on commit 2089bd4

Please sign in to comment.