From 6ec6bf6cc7e122d18ca6abe67f7b3a36afe917a6 Mon Sep 17 00:00:00 2001 From: Oliver Kunz Date: Mon, 22 Apr 2024 01:51:26 -0700 Subject: [PATCH] clang_generator: clean-up includes and other minor changes PiperOrigin-RevId: 626956477 Change-Id: Ic26ecb7bc1e361db270933fa3c2306a94a766e8c --- sandboxed_api/tools/clang_generator/BUILD | 5 ++++- sandboxed_api/tools/clang_generator/compilation_database.cc | 5 +++++ sandboxed_api/tools/clang_generator/compilation_database.h | 3 --- sandboxed_api/tools/clang_generator/diagnostics.cc | 2 ++ sandboxed_api/tools/clang_generator/emitter.cc | 6 ++++++ sandboxed_api/tools/clang_generator/emitter.h | 1 - .../tools/clang_generator/frontend_action_test_util.cc | 6 ++++-- .../tools/clang_generator/frontend_action_test_util.h | 6 ++---- sandboxed_api/tools/clang_generator/generator.cc | 5 ++++- sandboxed_api/tools/clang_generator/generator.h | 3 +++ sandboxed_api/tools/clang_generator/generator_tool.cc | 4 ++-- sandboxed_api/tools/clang_generator/types.cc | 2 ++ sandboxed_api/tools/clang_generator/types.h | 1 - 13 files changed, 34 insertions(+), 15 deletions(-) diff --git a/sandboxed_api/tools/clang_generator/BUILD b/sandboxed_api/tools/clang_generator/BUILD index 210a4f9ac..684b0042a 100644 --- a/sandboxed_api/tools/clang_generator/BUILD +++ b/sandboxed_api/tools/clang_generator/BUILD @@ -47,8 +47,11 @@ cc_library( "@llvm-project//clang:format", "@llvm-project//clang:frontend", "@llvm-project//clang:lex", + "@llvm-project//clang:serialization", "@llvm-project//clang:tooling", + "@llvm-project//clang:tooling_core", "@llvm-project//llvm:Support", + "@llvm-project//llvm:config", ], ) @@ -73,6 +76,7 @@ cc_test( "@llvm-project//clang:frontend", "@llvm-project//clang:tooling", "@llvm-project//llvm:Support", + "@llvm-project//llvm:config", ], ) @@ -93,7 +97,6 @@ cc_binary( "//sandboxed_api/util:fileops", "//sandboxed_api/util:status", "@com_google_absl//absl/status", - "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@llvm-project//clang:driver", diff --git a/sandboxed_api/tools/clang_generator/compilation_database.cc b/sandboxed_api/tools/clang_generator/compilation_database.cc index 879796b3e..45b496465 100644 --- a/sandboxed_api/tools/clang_generator/compilation_database.cc +++ b/sandboxed_api/tools/clang_generator/compilation_database.cc @@ -23,8 +23,13 @@ #include "absl/strings/string_view.h" #include "absl/strings/strip.h" #include "clang/Driver/Types.h" +#include "clang/Tooling/ArgumentsAdjusters.h" +#include "clang/Tooling/CommonOptionsParser.h" #include "clang/Tooling/CompilationDatabase.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Error.h" #include "llvm/Support/Path.h" +#include "llvm/Support/raw_ostream.h" namespace sapi { diff --git a/sandboxed_api/tools/clang_generator/compilation_database.h b/sandboxed_api/tools/clang_generator/compilation_database.h index 7575df09b..81bd2a7a3 100644 --- a/sandboxed_api/tools/clang_generator/compilation_database.h +++ b/sandboxed_api/tools/clang_generator/compilation_database.h @@ -17,13 +17,10 @@ #include #include -#include #include #include "clang/Tooling/ArgumentsAdjusters.h" -#include "clang/Tooling/CommonOptionsParser.h" #include "clang/Tooling/CompilationDatabase.h" -#include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Error.h" diff --git a/sandboxed_api/tools/clang_generator/diagnostics.cc b/sandboxed_api/tools/clang_generator/diagnostics.cc index a8880be76..8f02f85ff 100644 --- a/sandboxed_api/tools/clang_generator/diagnostics.cc +++ b/sandboxed_api/tools/clang_generator/diagnostics.cc @@ -23,6 +23,8 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/StringRef.h" namespace sapi { diff --git a/sandboxed_api/tools/clang_generator/emitter.cc b/sandboxed_api/tools/clang_generator/emitter.cc index ab14b0d55..a98b90636 100644 --- a/sandboxed_api/tools/clang_generator/emitter.cc +++ b/sandboxed_api/tools/clang_generator/emitter.cc @@ -36,11 +36,17 @@ #include "absl/strings/strip.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/QualTypeNames.h" #include "clang/AST/Type.h" #include "clang/Format/Format.h" +#include "clang/Tooling/Core/Replacement.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/raw_ostream.h" #include "sandboxed_api/tools/clang_generator/diagnostics.h" #include "sandboxed_api/tools/clang_generator/generator.h" #include "sandboxed_api/tools/clang_generator/types.h" diff --git a/sandboxed_api/tools/clang_generator/emitter.h b/sandboxed_api/tools/clang_generator/emitter.h index f0f599652..fc0b3ec33 100644 --- a/sandboxed_api/tools/clang_generator/emitter.h +++ b/sandboxed_api/tools/clang_generator/emitter.h @@ -26,7 +26,6 @@ #include "absl/strings/string_view.h" #include "clang/AST/Decl.h" #include "clang/AST/Type.h" -#include "sandboxed_api/tools/clang_generator/types.h" namespace sapi { namespace internal { diff --git a/sandboxed_api/tools/clang_generator/frontend_action_test_util.cc b/sandboxed_api/tools/clang_generator/frontend_action_test_util.cc index b29b71c04..5573b2673 100644 --- a/sandboxed_api/tools/clang_generator/frontend_action_test_util.cc +++ b/sandboxed_api/tools/clang_generator/frontend_action_test_util.cc @@ -31,7 +31,9 @@ #include "clang/Basic/FileSystemOptions.h" #include "clang/Frontend/FrontendAction.h" #include "clang/Tooling/Tooling.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Config/llvm-config.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/VirtualFileSystem.h" @@ -39,8 +41,8 @@ namespace sapi { namespace internal { absl::Status RunClangTool( - const std::vector command_line, - const absl::flat_hash_map file_contents, + const std::vector& command_line, + const absl::flat_hash_map& file_contents, std::unique_ptr action) { // Setup an in-memory virtual filesystem llvm::IntrusiveRefCntPtr fs( diff --git a/sandboxed_api/tools/clang_generator/frontend_action_test_util.h b/sandboxed_api/tools/clang_generator/frontend_action_test_util.h index 502d66aa8..2dcbb35cd 100644 --- a/sandboxed_api/tools/clang_generator/frontend_action_test_util.h +++ b/sandboxed_api/tools/clang_generator/frontend_action_test_util.h @@ -20,7 +20,6 @@ #include #include -#include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/container/flat_hash_map.h" #include "absl/memory/memory.h" @@ -28,14 +27,13 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "clang/Frontend/FrontendAction.h" -#include "sandboxed_api/util/status_matchers.h" namespace sapi { namespace internal { absl::Status RunClangTool( - const std::vector command_line, - const absl::flat_hash_map file_contents, + const std::vector& command_line, + const absl::flat_hash_map& file_contents, std::unique_ptr action); } // namespace internal diff --git a/sandboxed_api/tools/clang_generator/generator.cc b/sandboxed_api/tools/clang_generator/generator.cc index ebfc16217..6439cd0ea 100644 --- a/sandboxed_api/tools/clang_generator/generator.cc +++ b/sandboxed_api/tools/clang_generator/generator.cc @@ -15,7 +15,6 @@ #include "sandboxed_api/tools/clang_generator/generator.h" #include -#include #include #include #include @@ -29,9 +28,13 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/Type.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" +#include "clang/Frontend/CompilerInvocation.h" #include "clang/Lex/PreprocessorOptions.h" +#include "clang/Serialization/PCHContainerOperations.h" +#include "clang/Tooling/Tooling.h" #include "sandboxed_api/tools/clang_generator/diagnostics.h" #include "sandboxed_api/tools/clang_generator/emitter.h" diff --git a/sandboxed_api/tools/clang_generator/generator.h b/sandboxed_api/tools/clang_generator/generator.h index ce6b5fb33..c3f836a64 100644 --- a/sandboxed_api/tools/clang_generator/generator.h +++ b/sandboxed_api/tools/clang_generator/generator.h @@ -29,7 +29,10 @@ #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/FrontendAction.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Serialization/PCHContainerOperations.h" #include "clang/Tooling/Tooling.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Config/llvm-config.h" #include "sandboxed_api/tools/clang_generator/emitter.h" #include "sandboxed_api/tools/clang_generator/types.h" diff --git a/sandboxed_api/tools/clang_generator/generator_tool.cc b/sandboxed_api/tools/clang_generator/generator_tool.cc index 9fc0d4128..598085d6d 100644 --- a/sandboxed_api/tools/clang_generator/generator_tool.cc +++ b/sandboxed_api/tools/clang_generator/generator_tool.cc @@ -12,20 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include #include #include "absl/status/status.h" -#include "absl/status/statusor.h" #include "absl/strings/match.h" #include "absl/strings/str_format.h" #include "clang/Tooling/CommonOptionsParser.h" #include "clang/Tooling/CompilationDatabase.h" +#include "clang/Tooling/Tooling.h" #include "llvm/Support/CommandLine.h" #include "sandboxed_api/tools/clang_generator/compilation_database.h" +#include "sandboxed_api/tools/clang_generator/emitter.h" #include "sandboxed_api/tools/clang_generator/generator.h" #include "sandboxed_api/util/file_helpers.h" #include "sandboxed_api/util/fileops.h" diff --git a/sandboxed_api/tools/clang_generator/types.cc b/sandboxed_api/tools/clang_generator/types.cc index b4c90c935..0fabcfaf5 100644 --- a/sandboxed_api/tools/clang_generator/types.cc +++ b/sandboxed_api/tools/clang_generator/types.cc @@ -23,6 +23,8 @@ #include "clang/AST/Decl.h" #include "clang/AST/QualTypeNames.h" #include "clang/AST/Type.h" +#include "llvm/Config/llvm-config.h" +#include "llvm/Support/Casting.h" namespace sapi { namespace { diff --git a/sandboxed_api/tools/clang_generator/types.h b/sandboxed_api/tools/clang_generator/types.h index cbc96076a..403fb29e5 100644 --- a/sandboxed_api/tools/clang_generator/types.h +++ b/sandboxed_api/tools/clang_generator/types.h @@ -18,7 +18,6 @@ #include #include -#include "absl/container/flat_hash_set.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/Type.h"