1 //===--- AnalysisInternal.h - Analysis building blocks ------------- 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 // This file provides smaller, testable pieces of the used-header analysis.
10 // We find the headers by chaining together several mappings.
12 // AST => AST node => Symbol => Location => Header
16 // The individual steps are declared here.
17 // (AST => AST Node => Symbol is one API to avoid materializing DynTypedNodes).
19 //===----------------------------------------------------------------------===//
21 #ifndef CLANG_INCLUDE_CLEANER_ANALYSISINTERNAL_H
22 #define CLANG_INCLUDE_CLEANER_ANALYSISINTERNAL_H
24 #include "clang/Basic/SourceLocation.h"
25 #include "llvm/ADT/STLFunctionalExtras.h"
30 namespace include_cleaner
{
32 /// Traverses part of the AST from \p Root, finding uses of symbols.
34 /// Each use is reported to the callback:
35 /// - the SourceLocation describes where the symbol was used. This is usually
36 /// the primary location of the AST node found under Root.
37 /// - the NamedDecl is the symbol referenced. It is canonical, rather than e.g.
38 /// the redecl actually found by lookup.
40 /// walkAST is typically called once per top-level declaration in the file
41 /// being analyzed, in order to find all references within it.
42 void walkAST(Decl
&Root
, llvm::function_ref
<void(SourceLocation
, NamedDecl
&)>);
44 } // namespace include_cleaner