Skip to content

Commit fd2d902

Browse files
committed
issue #11282 getDefsNew fails to find symbols if a filename matches a namespace name
1 parent 8342610 commit fd2d902

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

src/symbolresolver.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ static std::unordered_map<std::string, std::pair<QCString,const MemberDef *> > g
4343

4444
//--------------------------------------------------------------------------------------
4545

46+
static bool isCodeSymbol(Definition::DefType defType)
47+
{
48+
return defType==Definition::TypeClass || defType==Definition::TypeNamespace ||
49+
defType==Definition::TypeModule || defType==Definition::TypeMember ||
50+
defType==Definition::TypePackage || defType==Definition::TypeConcept;
51+
}
52+
53+
//--------------------------------------------------------------------------------------
54+
4655
/** Helper class representing the stack of items considered while resolving
4756
* the scope.
4857
*/
@@ -339,8 +348,11 @@ const ClassDef *SymbolResolver::Private::getResolvedTypeRec(
339348

340349
for (Definition *d : range)
341350
{
342-
getResolvedType(visitedKeys,scope,d,explicitScopePart,actTemplParams.get(),
343-
minDistance,bestMatch,bestTypedef,bestTemplSpec,bestResolvedType);
351+
if (isCodeSymbol(d->definitionType()))
352+
{
353+
getResolvedType(visitedKeys,scope,d,explicitScopePart,actTemplParams.get(),
354+
minDistance,bestMatch,bestTypedef,bestTemplSpec,bestResolvedType);
355+
}
344356
if (minDistance==0) break; // we can stop reaching if we already reached distance 0
345357
}
346358

@@ -507,8 +519,11 @@ const Definition *SymbolResolver::Private::getResolvedSymbolRec(
507519

508520
for (Definition *d : range)
509521
{
510-
getResolvedSymbol(visitedKeys,scope,d,args,checkCV,insideCode,explicitScopePart,false,
511-
minDistance,bestMatch,bestTypedef,bestTemplSpec,bestResolvedType);
522+
if (isCodeSymbol(d->definitionType()))
523+
{
524+
getResolvedSymbol(visitedKeys,scope,d,args,checkCV,insideCode,explicitScopePart,false,
525+
minDistance,bestMatch,bestTypedef,bestTemplSpec,bestResolvedType);
526+
}
512527
if (minDistance==0) break; // we can stop reaching if we already reached distance 0
513528
}
514529

@@ -518,8 +533,11 @@ const Definition *SymbolResolver::Private::getResolvedSymbolRec(
518533
{
519534
for (Definition *d : range)
520535
{
521-
getResolvedSymbol(visitedKeys,scope,d,QCString(),false,insideCode,explicitScopePart,true,
536+
if (isCodeSymbol(d->definitionType()))
537+
{
538+
getResolvedSymbol(visitedKeys,scope,d,QCString(),false,insideCode,explicitScopePart,true,
522539
minDistance,bestMatch,bestTypedef,bestTemplSpec,bestResolvedType);
540+
}
523541
if (minDistance==0) break; // we can stop reaching if we already reached distance 0
524542
}
525543
}
@@ -1325,8 +1343,9 @@ int SymbolResolver::Private::isAccessibleFrom(VisitedKeys &visitedKeys,
13251343
const Definition *scope,
13261344
const Definition *item)
13271345
{
1328-
AUTO_TRACE("scope={} item={}",
1329-
scope?scope->name():QCString(), item?item->name():QCString());
1346+
AUTO_TRACE("scope={} item={} item.definitionType={}",
1347+
scope?scope->name():QCString(), item?item->name():QCString(),
1348+
item?(int)item->definitionType():-1);
13301349

13311350
if (accessStack.find(scope,m_fileScope,item))
13321351
{
@@ -1390,8 +1409,8 @@ int SymbolResolver::Private::isAccessibleFrom(VisitedKeys &visitedKeys,
13901409
if (nestedClassInsideBaseClass)
13911410
{
13921411
result++; // penalty for base class to prevent
1393-
// this is preferred over nested class in this class
1394-
// see bug 686956
1412+
// this is preferred over nested class in this class
1413+
// see bug 686956
13951414
}
13961415
else if (memberAccessibleFromScope &&
13971416
itemScope &&

src/trace.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ class AutoTrace
130130
}
131131
}
132132
template<typename... Args>
133-
void setExit(const std::string &msg,Args&&...args)
133+
void setExit(spdlog::source_loc loc,
134+
const std::string &msg,Args&&...args)
134135
{
136+
m_loc = loc;
135137
m_exitMessage = fmt::format(msg,std::forward<Args>(args)...);
136138
}
137139
private:
@@ -142,7 +144,7 @@ class AutoTrace
142144
#if ENABLE_TRACING
143145
#define AUTO_TRACE(...) AutoTrace trace_{spdlog::source_loc{__FILE__,__LINE__,SPDLOG_FUNCTION},__VA_ARGS__}
144146
#define AUTO_TRACE_ADD(...) trace_.add(spdlog::source_loc{__FILE__,__LINE__,SPDLOG_FUNCTION},__VA_ARGS__)
145-
#define AUTO_TRACE_EXIT(...) trace_.setExit(__VA_ARGS__)
147+
#define AUTO_TRACE_EXIT(...) trace_.setExit(spdlog::source_loc{__FILE__,__LINE__,SPDLOG_FUNCTION},__VA_ARGS__)
146148
#else
147149
#define AUTO_TRACE(...) (void)0
148150
#define AUTO_TRACE_ADD(...) (void)0

0 commit comments

Comments
 (0)