2016-05-24 23:10:58 +08:00
|
|
|
//===-- FindAllSymbolsAction.cpp - find all symbols action --------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
2016-05-24 23:10:58 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "FindAllSymbolsAction.h"
|
2016-09-07 03:53:26 +08:00
|
|
|
#include "FindAllMacros.h"
|
|
|
|
#include "clang/Lex/PPCallbacks.h"
|
|
|
|
#include "clang/Lex/Preprocessor.h"
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2016-05-24 23:10:58 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace find_all_symbols {
|
|
|
|
|
|
|
|
FindAllSymbolsAction::FindAllSymbolsAction(
|
2016-07-04 19:22:35 +08:00
|
|
|
SymbolReporter *Reporter,
|
|
|
|
const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap)
|
|
|
|
: Reporter(Reporter), Collector(RegexHeaderMap), Handler(&Collector),
|
2016-05-24 23:10:58 +08:00
|
|
|
Matcher(Reporter, &Collector) {
|
|
|
|
Matcher.registerMatchers(&MatchFinder);
|
|
|
|
}
|
|
|
|
|
2017-02-28 16:13:15 +08:00
|
|
|
std::unique_ptr<ASTConsumer>
|
|
|
|
FindAllSymbolsAction::CreateASTConsumer(CompilerInstance &Compiler,
|
2016-05-24 23:10:58 +08:00
|
|
|
StringRef InFile) {
|
|
|
|
Compiler.getPreprocessor().addCommentHandler(&Handler);
|
2019-08-15 07:52:23 +08:00
|
|
|
Compiler.getPreprocessor().addPPCallbacks(std::make_unique<FindAllMacros>(
|
2016-05-24 23:10:58 +08:00
|
|
|
Reporter, &Compiler.getSourceManager(), &Collector));
|
|
|
|
return MatchFinder.newASTConsumer();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace find_all_symbols
|
|
|
|
} // namespace clang
|