Skip to content

Commit f106c28

Browse files
authored
Merge branch 'main' into cir_vec_logical_and
2 parents 761d02d + bedfee0 commit f106c28

File tree

60 files changed

+2375
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2375
-286
lines changed

clang-tools-extra/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(CLANG_TOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
99

1010
llvm_canonicalize_cmake_booleans(
1111
CLANG_TIDY_ENABLE_STATIC_ANALYZER
12+
CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
1213
CLANG_PLUGIN_SUPPORT
1314
LLVM_INSTALL_TOOLCHAIN_ONLY
1415
)

clang-tools-extra/test/clang-tidy/checkers/custom/query-incorrect-query.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// REQUIRES: custom-check
12
// RUN: %check_clang_tidy %s custom-* %t --config-file=%S/Inputs/incorrect-clang-tidy.yml
23

34
// CHECK-MESSAGES: warning: 1:1: Matcher not found: varDeclInvalid in 'test-let-bind-invalid-2' [clang-tidy-config]

clang-tools-extra/test/clang-tidy/checkers/custom/query-partially-active-check.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// REQUIRES: custom-check
12
// RUN: %check_clang_tidy %s custom-test-let-bind %t --config-file=%S/Inputs/clang-tidy.yml
23

34
extern long E;

clang-tools-extra/test/clang-tidy/checkers/custom/query.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// REQUIRES: custom-check
12
// RUN: %check_clang_tidy %s custom-* %t --config-file=%S/Inputs/clang-tidy.yml
23

34
extern long E;

clang-tools-extra/test/clang-tidy/infrastructure/custom-query-check.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// REQUIRES: shell
2+
// REQUIRES: custom-check
3+
14
// RUN: sed -e "s:INPUT_DIR:%S/Inputs/custom-query-check:g" -e "s:OUT_DIR:%t:g" -e "s:MAIN_FILE:%s:g" %S/Inputs/custom-query-check/vfsoverlay.yaml > %t.yaml
25
// RUN: clang-tidy --experimental-custom-checks %t/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SAME-DIR
36
// RUN: clang-tidy --experimental-custom-checks %t/subdir/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SUB-DIR-BASE
@@ -6,7 +9,6 @@
69
// RUN: clang-tidy --experimental-custom-checks %t/subdir-append/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml | FileCheck %s --check-prefix=CHECK-SUB-DIR-APPEND
710
// RUN: clang-tidy --experimental-custom-checks %t/subdir-append/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml --list-checks | FileCheck %s --check-prefix=LIST-CHECK
811
// RUN: clang-tidy --experimental-custom-checks %t/subdir-append/main.cpp -checks='-*,custom-*' -vfsoverlay %t.yaml --dump-config | FileCheck %s --check-prefix=DUMP-CONFIG
9-
// REQUIRES: shell
1012

1113

1214
long V;

clang-tools-extra/test/lit.cfg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454

5555
if config.clang_tidy_staticanalyzer:
5656
config.available_features.add("static-analyzer")
57-
57+
if config.clang_tidy_custom_check:
58+
config.available_features.add("custom-check")
5859
python_exec = shlex.quote(config.python_executable)
5960
check_clang_tidy = os.path.join(
6061
config.test_source_root, "clang-tidy", "check_clang_tidy.py"

clang-tools-extra/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ config.python_executable = "@Python3_EXECUTABLE@"
1010
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1111
config.host_triple = "@LLVM_HOST_TRIPLE@"
1212
config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
13+
config.clang_tidy_custom_check = @CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS@
1314
config.has_plugins = @CLANG_PLUGIN_SUPPORT@
1415
# Support substitution of the tools and libs dirs with user parameters. This is
1516
# used when we can't determine the tool dir at configuration time.

clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ target_link_libraries(ClangTidyTests
5454
PRIVATE
5555
clangTidy
5656
clangTidyAndroidModule
57-
clangTidyCustomModule
5857
clangTidyGoogleModule
5958
clangTidyMiscModule
6059
clangTidyLLVMModule
@@ -65,3 +64,10 @@ target_link_libraries(ClangTidyTests
6564
LLVMTestingAnnotations
6665
LLVMTestingSupport
6766
)
67+
68+
if(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS)
69+
target_link_libraries(ClangTidyTests
70+
PRIVATE
71+
clangTidyCustomModule
72+
)
73+
endif()

clang/include/clang/CIR/Dialect/IR/CIRAttrConstraints.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,27 @@ def CIR_AnyIntOrFloatAttr : AnyAttrOf<[CIR_AnyIntAttr, CIR_AnyFPAttr],
3838
string cppType = "::mlir::TypedAttr";
3939
}
4040

41+
//===----------------------------------------------------------------------===//
42+
// GlobalViewAttr constraints
43+
//===----------------------------------------------------------------------===//
44+
45+
def CIR_AnyGlobalViewAttr : CIR_AttrConstraint<"::cir::GlobalViewAttr", "GlobalView attribute">;
46+
47+
def CIR_AnyIntOrGlobalViewAttr : AnyAttrOf<[CIR_AnyIntAttr, CIR_AnyGlobalViewAttr],
48+
"integer or global view attribute"> {
49+
string cppType = "::mlir::TypedAttr";
50+
}
51+
4152
//===----------------------------------------------------------------------===//
4253
// ArrayAttr constraints
4354
//===----------------------------------------------------------------------===//
4455

4556
def CIR_IntArrayAttr : TypedArrayAttrBase<CIR_AnyIntAttr,
4657
"integer array attribute">;
4758

59+
def CIR_IntOrGlobalViewArrayAttr : TypedArrayAttrBase<CIR_AnyIntOrGlobalViewAttr,
60+
"integer or global view array attribute">{
61+
string cppType = "::mlir::ArrayAttr";
62+
}
63+
4864
#endif // CLANG_CIR_DIALECT_IR_CIRATTRCONSTRAINTS_TD

clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,4 +779,56 @@ def CIR_AddressPointAttr : CIR_Attr<"AddressPoint", "address_point"> {
779779
}];
780780
}
781781

782+
//===----------------------------------------------------------------------===//
783+
// TypeInfoAttr
784+
//===----------------------------------------------------------------------===//
785+
786+
def CIR_TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> {
787+
let summary = "Represents a typeinfo used for RTTI";
788+
let description = [{
789+
The typeinfo data for a given class is stored into an ArrayAttr. The
790+
layout is determined by the C++ ABI used (clang only implements
791+
itanium on CIRGen).
792+
793+
The verifier enforces that the output type is always a `!cir.record`,
794+
and that the ArrayAttr element types match the equivalent member type
795+
for the resulting record, i.e, a GlobalViewAttr for symbol reference or
796+
an IntAttr for flags.
797+
798+
Example:
799+
800+
```
801+
cir.global "private" external @_ZTVN10__cxxabiv120__si_class_type_infoE
802+
: !cir.ptr<i32>
803+
804+
!rec_anon_struct = !cir.record<struct {!cir.ptr<!u8i>, !cir.ptr<!u8i>,
805+
!cir.ptr<!u8i>}>
806+
807+
cir.global constant external @type_info = #cir.typeinfo<{
808+
#cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2 : i32]>
809+
: !cir.ptr<!u8i>, #cir.global_view<@_ZTS1B> : !cir.ptr<!u8i>,
810+
#cir.global_view<@_ZTI1A> : !cir.ptr<!u8i>}> : !rec_anon_struct
811+
```
812+
}];
813+
814+
let parameters = (ins
815+
AttributeSelfTypeParameter<"">:$type,
816+
CIR_IntOrGlobalViewArrayAttr:$data
817+
);
818+
819+
let builders = [
820+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
821+
"mlir::ArrayAttr":$data), [{
822+
return $_get(type.getContext(), type, data);
823+
}]>
824+
];
825+
826+
// Checks record element types should match the array for every equivalent
827+
// element type.
828+
let genVerifyDecl = 1;
829+
let assemblyFormat = [{
830+
`<` custom<RecordMembers>($data) `>`
831+
}];
832+
}
833+
782834
#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_TD

0 commit comments

Comments
 (0)