# This file is licensed 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 load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") package(default_visibility = ["//visibility:public"]) licenses(["notice"]) cc_test( name = "ast_tests", size = "medium", srcs = glob( [ "AST/*.cpp", "AST/*.h", ], allow_empty = False, ), shard_count = 20, deps = [ "//clang:ast", "//clang:ast_matchers", "//clang:basic", "//clang:frontend", "//clang:lex", "//clang:testing", "//clang:tooling", "//llvm:Core", "//llvm:Support", "//llvm:TargetParser", "//llvm:TestingAnnotations", "//llvm:TestingSupport", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_library( name = "ast_matchers_tests_hdrs", testonly = 1, hdrs = glob( ["ASTMatchers/*.h"], allow_empty = False, ), deps = [ "//clang:ast_matchers", "//clang:frontend", "//clang:testing", "//clang:tooling", "//third-party/unittest:gtest", ], ) cc_test( name = "ast_matchers_tests", size = "medium", srcs = glob( ["ASTMatchers/*.cpp"], allow_empty = False, ), shard_count = 20, deps = [ ":ast_matchers_tests_hdrs", "//clang:ast", "//clang:ast_matchers", "//clang:frontend", "//clang:testing", "//clang:tooling", "//llvm:Support", "//llvm:TargetParser", "//llvm:TestingSupport", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "ast_matchers_dynamic_tests", size = "small", srcs = glob( ["ASTMatchers/Dynamic/*.cpp"], allow_empty = False, ), deps = [ ":ast_matchers_tests_hdrs", "//clang:ast_matchers", "//clang:ast_matchers_dynamic", "//clang:frontend", "//clang:tooling", "//llvm:Support", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_library( name = "dataflow_testing_support", testonly = 1, srcs = ["Analysis/FlowSensitive/TestingSupport.cpp"], hdrs = ["Analysis/FlowSensitive/TestingSupport.h"], deps = [ "//clang:analysis", "//clang:ast", "//clang:ast_matchers", "//clang:basic", "//clang:lex", "//clang:serialization", "//clang:tooling", "//llvm:Support", "//llvm:TestingAnnotations", "//third-party/unittest:gtest", ], ) cc_library( name = "dataflow_solver_test", testonly = 1, hdrs = ["Analysis/FlowSensitive/SolverTest.h"], deps = [ ":dataflow_testing_support", "//clang:analysis", "//third-party/unittest:gmock", "//third-party/unittest:gtest", ], ) cc_test( name = "analysis_tests", size = "small", srcs = glob( [ "Analysis/*.cpp", "Analysis/*.h", ], allow_empty = False, ), deps = [ "//clang:analysis", "//clang:ast", "//clang:ast_matchers", "//clang:basic", "//clang:frontend", "//clang:lex", "//clang:parse", "//clang:testing", "//clang:tooling", "//llvm:Support", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "analysis_flow_sensitive_tests", srcs = glob( [ "Analysis/FlowSensitive/*.cpp", "Analysis/FlowSensitive/*.h", ], allow_empty = False, ), deps = [ "//clang:analysis", "//clang:ast", "//clang:ast_matchers", "//clang:basic", "//clang:frontend", "//clang:lex", "//clang:serialization", "//clang:testing", "//clang:tooling", "//llvm:Support", "//llvm:TestingADT", "//llvm:TestingAnnotations", "//llvm:TestingSupport", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "basic_tests", size = "small", srcs = glob( ["Basic/*.cpp"], allow_empty = False, ), deps = [ "//clang:basic", "//clang:frontend", "//clang:lex", "//llvm:Support", "//llvm:TestingSupport", "//llvm:config", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "codegen_tests", size = "small", srcs = glob( [ "CodeGen/*.cpp", "CodeGen/*.h", ], allow_empty = False, ), deps = [ "//clang:ast", "//clang:basic", "//clang:codegen", "//clang:frontend", "//clang:lex", "//clang:parse", "//clang:sema", "//llvm:Core", "//llvm:Support", "//llvm:TargetParser", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "format_tests", size = "medium", srcs = glob( [ "Format/*.cpp", "Format/*.h", ], allow_empty = False, ), copts = ["$(STACK_FRAME_UNLIMITED)"], features = ["-layering_check"], # #include "../../lib/Format/TokenAnalyzer.h" shard_count = 20, deps = [ ":tooling_tests_hdrs", "//clang:basic", "//clang:format", "//clang:frontend", "//clang:tooling_core", "//llvm:Support", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "frontend_tests", size = "small", srcs = glob( ["Frontend/*.cpp"], allow_empty = False, ), deps = [ "//clang:ast", "//clang:basic", "//clang:codegen", "//clang:driver_options_inc_gen", "//clang:frontend", "//clang:frontend_tool", "//clang:lex", "//clang:sema", "//clang:serialization", "//clang:tooling", "//llvm:Option", "//llvm:Support", "//llvm:TargetParser", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "lex_tests", size = "small", srcs = glob( [ "Lex/*.cpp", "Lex/*.h", ], allow_empty = False, ), copts = ["$(STACK_FRAME_UNLIMITED)"], deps = [ "//clang:ast", "//clang:basic", "//clang:frontend", "//clang:lex", "//clang:parse", "//clang:sema", "//clang:serialization", "//llvm:Support", "//llvm:TestingAnnotations", "//llvm:TestingSupport", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "rewrite_tests", size = "small", srcs = glob( ["Rewrite/*.cpp"], allow_empty = False, ), deps = [ "//clang:rewrite", "//clang:tooling", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "sema_tests", size = "small", srcs = glob( ["Sema/*.cpp"], allow_empty = False, ), deps = [ ":ast_matchers_tests_hdrs", "//clang:ast", "//clang:ast_matchers", "//clang:frontend", "//clang:lex", "//clang:parse", "//clang:sema", "//clang:tooling", "//llvm:TestingAnnotations", "//llvm:TestingSupport", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_library( name = "static_analyzer_test_headers", testonly = 1, hdrs = glob( ["StaticAnalyzer/*.h"], allow_empty = False, ), deps = [ "//clang:analysis", "//clang:ast_matchers", "//clang:crosstu", "//clang:frontend", "//clang:static_analyzer_core", "//clang:static_analyzer_frontend", "//clang:tooling", "//third-party/unittest:gtest", ], ) cc_test( name = "static_analyzer_tests", size = "small", srcs = glob( ["StaticAnalyzer/*.cpp"], allow_empty = False, exclude = [ # New test has unused-variable warnings. "StaticAnalyzer/ParamRegionTest.cpp", ], ), deps = [ ":static_analyzer_test_headers", "//clang:analysis", "//clang:ast", "//clang:ast_matchers", "//clang:basic", "//clang:frontend", "//clang:static_analyzer_core", "//clang:static_analyzer_frontend", "//clang:testing", "//clang:tooling", "//llvm:Support", "//llvm:config", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_library( name = "tooling_tests_hdrs", testonly = 1, hdrs = glob( ["Tooling/*.h"], allow_empty = False, ), deps = [ "//clang:ast", "//clang:basic", "//clang:frontend", "//clang:rewrite", "//clang:tooling", "//clang:tooling_core", "//llvm:Support", "//third-party/unittest:gtest", ], ) cc_test( name = "tooling_tests", size = "medium", srcs = glob( ["Tooling/*.cpp"], allow_empty = False, ), shard_count = 20, deps = [ ":tooling_tests_hdrs", "//clang:ast", "//clang:ast_matchers", "//clang:basic", "//clang:driver", "//clang:format", "//clang:frontend", "//clang:lex", "//clang:rewrite", "//clang:testing", "//clang:tooling", "//clang:tooling_core", "//clang:tooling_dependency_scanning", "//clang:tooling_inclusions", "//clang:tooling_refactoring", "//clang:transformer", "//llvm:MC", "//llvm:Support", "//llvm:TargetParser", "//llvm:TestingAnnotations", "//llvm:TestingSupport", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) # A library to carefully expose the tooling headers using the include prefix # expected by the `tooling_recursive_ast_visitor_tests`. cc_library( name = "tooling_recursive_ast_visitor_tests_tooling_hdrs", testonly = 1, hdrs = glob( ["Tooling/*.h"], allow_empty = False, ), strip_include_prefix = "Tooling", deps = [ "//clang:ast", "//clang:basic", "//clang:frontend", "//clang:rewrite", "//clang:tooling", "//clang:tooling_core", "//llvm:Support", "//third-party/unittest:gtest", ], ) cc_test( name = "tooling_recursive_ast_visitor_tests", size = "medium", srcs = glob( ["Tooling/RecursiveASTVisitorTests/*.cpp"], allow_empty = False, ) + [ "Tooling/RecursiveASTVisitorTests/CallbacksCommon.h", ], deps = [ ":tooling_recursive_ast_visitor_tests_tooling_hdrs", "//clang:ast", "//clang:basic", "//clang:frontend", "//clang:lex", "//clang:tooling", "//clang:tooling_syntax", "//llvm:Support", "//llvm:TargetParser", "//llvm:TestingSupport", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "tooling_syntax_tests", size = "medium", srcs = glob( [ "Tooling/Syntax/*.cpp", "Tooling/Syntax/*.h", ], allow_empty = False, ), shard_count = 20, deps = [ "//clang:ast", "//clang:basic", "//clang:frontend", "//clang:lex", "//clang:testing", "//clang:tooling", "//clang:tooling_core", "//clang:tooling_syntax", "//llvm:Support", "//llvm:TestingAnnotations", "//llvm:TestingSupport", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "libclang_tests", size = "small", srcs = glob( ["libclang/*.cpp"], allow_empty = False, ) + [ "libclang/TestUtils.h", ], args = select({ "@platforms//os:windows": [ # Need to disable the VFS tests that don't use Windows friendly # paths. These are also disabled on Windows in the CMake build. "--gtest_filter=-*VirtualFileOverlay*", ], "//conditions:default": [], }), deps = [ "//clang:libclang", "//llvm:Support", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "crosstu_tests", size = "small", srcs = glob( ["CrossTU/*.cpp"], allow_empty = False, ), deps = [ "//clang:ast", "//clang:crosstu", "//clang:frontend", "//clang:tooling", "//llvm:Support", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "driver_tests", size = "small", srcs = glob( [ "Driver/*.cpp", "Driver/*.h", ], allow_empty = False, exclude = [ "Driver/GCCVersionTest.cpp", # Includes private headers ], ), deps = [ "//clang:basic", "//clang:driver", "//clang:frontend", "//llvm:FrontendDebug", "//llvm:MC", "//llvm:Support", "//llvm:TargetParser", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "parse_tests", size = "small", srcs = glob( ["Parse/*.cpp"], allow_empty = False, ), deps = [ "//clang:ast", "//clang:basic", "//clang:lex", "//clang:parse", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "directory_watcher_tests", size = "small", srcs = glob( ["DirectoryWatcher/*.cpp"], allow_empty = False, ), deps = [ "//clang:directory_watcher", "//llvm:Support", "//llvm:TestingSupport", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "index_tests", size = "small", srcs = glob( ["Index/*.cpp"], allow_empty = False, ), deps = [ "//clang:ast", "//clang:basic", "//clang:frontend", "//clang:index", "//clang:lex", "//clang:tooling", "//llvm:Support", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "install_api_tests", size = "small", srcs = glob( ["InstallAPI/*.cpp"], allow_empty = False, ), deps = [ "//clang:install_api", "//llvm:Support", "//llvm:TestingSupport", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "interpreter_tests", size = "small", srcs = glob( [ "Interpreter/*.cpp", "Interpreter/*.h", ], allow_empty = False, ), args = [ # TODO: some tests fail with: "JIT session error: Symbols not found: # [ _ZnwmPv26__clang_Interpreter_NewTag, __clang_Interpreter_SetValueWithAlloc ] "--gtest_filter=-InterpreterTest.*:InterpreterTestBase.*", ], deps = [ "//clang:ast", "//clang:basic", "//clang:codegen", "//clang:config", "//clang:frontend", "//clang:interpreter", "//clang:lex", "//clang:parse", "//clang:sema", "//llvm:LineEditor", "//llvm:MC", "//llvm:OrcJIT", "//llvm:OrcShared", "//llvm:Support", "//llvm:TargetParser", "//llvm:TestingSupport", "//llvm:ir_headers", "//third-party/unittest:gmock", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "serialization_tests", size = "small", srcs = glob( ["Serialization/*.cpp"], allow_empty = False, ), deps = [ "//clang:ast_matchers", "//clang:basic", "//clang:frontend", "//clang:lex", "//clang:parse", "//clang:serialization", "//clang:tooling", "//llvm:Support", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], ) cc_test( name = "support_tests", size = "small", srcs = glob( ["Support/*.cpp"], allow_empty = False, ), deps = [ "//clang:frontend", "//clang:lex", "//llvm:Support", "//third-party/unittest:gtest", "//third-party/unittest:gtest_main", ], )