1 //===--- ASTSignals.cpp ------------------------------------------*- C++-*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "ASTSignals.h"
11 #include "FindTarget.h"
13 #include "support/Trace.h"
14 #include "clang/AST/DeclObjC.h"
18 ASTSignals
ASTSignals::derive(const ParsedAST
&AST
) {
19 trace::Span
Span("ASTSignals::derive");
21 Signals
.InsertionDirective
= preferredIncludeDirective(
22 AST
.tuPath(), AST
.getLangOpts(),
23 AST
.getIncludeStructure().MainFileIncludes
, AST
.getLocalTopLevelDecls());
24 const SourceManager
&SM
= AST
.getSourceManager();
25 findExplicitReferences(
27 [&](ReferenceLoc Ref
) {
28 for (const NamedDecl
*ND
: Ref
.Targets
) {
29 if (!isInsideMainFile(Ref
.NameLoc
, SM
))
31 SymbolID ID
= getSymbolID(ND
);
34 unsigned &SymbolCount
= Signals
.ReferencedSymbols
[ID
];
36 // Process namespace only when we see the symbol for the first time.
39 if (const auto *NSD
= dyn_cast
<NamespaceDecl
>(ND
->getDeclContext())) {
40 if (NSD
->isAnonymousNamespace())
42 std::string NS
= printNamespaceScope(*NSD
);
44 Signals
.RelatedNamespaces
[NS
]++;
48 AST
.getHeuristicResolver());