@@ -436,6 +436,8 @@ class ASTVisitor
436
436
std::pair<InfoTy&, bool >
437
437
getOrCreateInfo (const SymbolID& id)
438
438
{
439
+ assert (id != SymbolID::invalid &&
440
+ " creating symbol with invalid SymbolID?" );
439
441
Info* info = getInfo (id);
440
442
bool created = ! info;
441
443
if (! info)
@@ -535,17 +537,6 @@ class ASTVisitor
535
537
return false ;
536
538
}
537
539
538
- // Handling UsingDirectiveDecl
539
- if (const auto * UDD = dyn_cast<UsingDirectiveDecl>(D))
540
- {
541
- if (index ::generateUSRForDecl (UDD->getNominatedNamespace (), usr_)) {
542
- return true ;
543
- }
544
- usr_.append (" @UD" );
545
- usr_.append (UDD->getQualifiedNameAsString ());
546
- return false ;
547
- }
548
-
549
540
// Handling UsingDecl
550
541
if (const auto * UD = dyn_cast<UsingDecl>(D))
551
542
{
@@ -2194,39 +2185,6 @@ class ASTVisitor
2194
2185
getParentNamespaces (I, D);
2195
2186
}
2196
2187
2197
-
2198
- // ------------------------------------------------
2199
-
2200
- void
2201
- buildUsingDirective (
2202
- UsingInfo& I,
2203
- bool created,
2204
- UsingDirectiveDecl* D)
2205
- {
2206
- bool documented = parseRawComment (I.javadoc , D);
2207
- addSourceLocation (I, D->getBeginLoc (), true , documented);
2208
-
2209
- if (! created)
2210
- return ;
2211
-
2212
- I.Class = UsingClass::Namespace;
2213
-
2214
- if (D->getQualifier ())
2215
- {
2216
- I.Qualifier = buildNameInfo (D->getQualifier ());
2217
- }
2218
-
2219
- if (NamedDecl* ND = D->getNominatedNamespace ())
2220
- {
2221
- I.Name = extractName (ND);
2222
- SymbolID id;
2223
- getDependencyID (ND, id);
2224
- I.UsingSymbols .emplace_back (id);
2225
- }
2226
- getParentNamespaces (I, D);
2227
- }
2228
-
2229
-
2230
2188
// ------------------------------------------------
2231
2189
2232
2190
void
@@ -2601,12 +2559,23 @@ void
2601
2559
ASTVisitor::
2602
2560
traverse (UsingDirectiveDecl* D)
2603
2561
{
2604
- auto exp = getAsMrDocsInfo (D);
2605
- if (! exp ) { return ; }
2606
- auto [I, created] = *exp ;
2607
- buildUsingDirective (I, created, D);
2608
- }
2562
+ if (! shouldExtract (D, getAccess (D)))
2563
+ return ;
2609
2564
2565
+ Decl* PD = getParentDecl (D);
2566
+ // only extract using-directives in namespace scope
2567
+ if (! cast<DeclContext>(PD)->isFileContext ())
2568
+ return ;
2569
+
2570
+ if (Info* PI = getInfo (extractSymbolID (PD)))
2571
+ {
2572
+ assert (PI->isNamespace ());
2573
+ NamespaceInfo* NI = static_cast <NamespaceInfo*>(PI);
2574
+ getDependencyID (
2575
+ D->getNominatedNamespaceAsWritten (),
2576
+ NI->UsingDirectives .emplace_back ());
2577
+ }
2578
+ }
2610
2579
2611
2580
// ------------------------------------------------
2612
2581
// UsingDecl
0 commit comments