Skip to content

Commit

Permalink
You can forward declare a class as a struct and vice versa.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Feb 26, 2015
1 parent bf1ad0c commit 5e1b5af
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,14 @@ Set<Symbol> Project::findTargets(const Symbol &symbol)
if (symbol.isClass() && symbol.isDefinition())
return ret;

auto sameKind = [&symbol](CXCursorKind kind) {
if (kind == symbol.kind)
return true;
if (symbol.isClass())
return kind == CXCursor_ClassDecl || kind == CXCursor_StructDecl;
return false;
};

switch (symbol.kind) {
case CXCursor_ClassDecl:
case CXCursor_ClassTemplate:
Expand All @@ -969,7 +977,7 @@ Set<Symbol> Project::findTargets(const Symbol &symbol)
case CXCursor_FunctionTemplate: {
const Set<Symbol> symbols = findByUsr(symbol.usr, symbol.location.fileId(), symbol.isDefinition() ? ArgDependsOn : DependsOnArg);
for (const auto &c : symbols) {
if (symbol.kind == c.kind && symbol.isDefinition() != c.isDefinition()) {
if (sameKind(c.kind) && symbol.isDefinition() != c.isDefinition()) {
ret.insert(c);
break;
}
Expand Down

0 comments on commit 5e1b5af

Please sign in to comment.