
The immediate goal is to start producing an HTML report to debug and explain include-cleaner recommendations. For now, this includes only the lowest-level piece: a list of the references found in the source code. How this fits into future ideas: - under refs we can also show the headers providing the symbol, which includes match those headers etc - we can also annotate the #include lines with which symbols they cover, and add whichever includes we're suggesting too - the include-cleaner tool will likely have modes where it emits diagnostics and/or applies edits, so the HTML report is behind a flag Differential Revision: https://reviews.llvm.org/D135956
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
//===--- Record.h - Record compiler events ------------------------- C++-*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Where Analysis.h analyzes AST nodes and recorded preprocessor events, this
|
|
// file defines ways to capture AST and preprocessor information from a parse.
|
|
//
|
|
// These are the simplest way to connect include-cleaner logic to the parser,
|
|
// but other ways are possible (for example clangd records includes separately).
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef CLANG_INCLUDE_CLEANER_RECORD_H
|
|
#define CLANG_INCLUDE_CLEANER_RECORD_H
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace clang {
|
|
class ASTConsumer;
|
|
class ASTContext;
|
|
class Decl;
|
|
namespace include_cleaner {
|
|
|
|
// Contains recorded parser events relevant to include-cleaner.
|
|
struct RecordedAST {
|
|
// The consumer (when installed into clang) tracks declarations in this.
|
|
std::unique_ptr<ASTConsumer> record();
|
|
|
|
ASTContext *Ctx = nullptr;
|
|
// The set of declarations written at file scope inside the main file.
|
|
//
|
|
// These are the roots of the subtrees that should be traversed to find uses.
|
|
// (Traversing the TranslationUnitDecl would find uses inside headers!)
|
|
std::vector<Decl *> Roots;
|
|
};
|
|
|
|
} // namespace include_cleaner
|
|
} // namespace clang
|
|
|
|
#endif |