Skip to content

Commit

Permalink
clang_generator: clean-up includes and other minor changes
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 626956477
Change-Id: Ic26ecb7bc1e361db270933fa3c2306a94a766e8c
  • Loading branch information
okunz authored and copybara-github committed Apr 22, 2024
1 parent 737ebd3 commit 6ec6bf6
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 15 deletions.
5 changes: 4 additions & 1 deletion sandboxed_api/tools/clang_generator/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand All @@ -73,6 +76,7 @@ cc_test(
"@llvm-project//clang:frontend",
"@llvm-project//clang:tooling",
"@llvm-project//llvm:Support",
"@llvm-project//llvm:config",
],
)

Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions sandboxed_api/tools/clang_generator/compilation_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
3 changes: 0 additions & 3 deletions sandboxed_api/tools/clang_generator/compilation_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@

#include <memory>
#include <string>
#include <utility>
#include <vector>

#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"

Expand Down
2 changes: 2 additions & 0 deletions sandboxed_api/tools/clang_generator/diagnostics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
6 changes: 6 additions & 0 deletions sandboxed_api/tools/clang_generator/emitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion sandboxed_api/tools/clang_generator/emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@
#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"

namespace sapi {
namespace internal {

absl::Status RunClangTool(
const std::vector<std::string> command_line,
const absl::flat_hash_map<std::string, std::string> file_contents,
const std::vector<std::string>& command_line,
const absl::flat_hash_map<std::string, std::string>& file_contents,
std::unique_ptr<clang::FrontendAction> action) {
// Setup an in-memory virtual filesystem
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> fs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,20 @@
#include <utility>
#include <vector>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/container/flat_hash_map.h"
#include "absl/memory/memory.h"
#include "absl/status/status.h"
#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<std::string> command_line,
const absl::flat_hash_map<std::string, std::string> file_contents,
const std::vector<std::string>& command_line,
const absl::flat_hash_map<std::string, std::string>& file_contents,
std::unique_ptr<clang::FrontendAction> action);

} // namespace internal
Expand Down
5 changes: 4 additions & 1 deletion sandboxed_api/tools/clang_generator/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "sandboxed_api/tools/clang_generator/generator.h"

#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
Expand All @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions sandboxed_api/tools/clang_generator/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions sandboxed_api/tools/clang_generator/generator_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <cstdio>
#include <cstdlib>
#include <memory>
#include <string>
#include <vector>

#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"
Expand Down
2 changes: 2 additions & 0 deletions sandboxed_api/tools/clang_generator/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion sandboxed_api/tools/clang_generator/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <string>
#include <vector>

#include "absl/container/flat_hash_set.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Type.h"
Expand Down

0 comments on commit 6ec6bf6

Please sign in to comment.