Skip to content

Commit 1d02dd2

Browse files
committed
[clang-tidy] Fix warning in portability-simd-intrinsics
When portability-simd-intrinsics.Suggest were set to false, produced warning were missing source location, and due to that such warning coudn't be NOLINTed. Added missing tests. Fixes issues: #52831 Differential Revision: https://reviews.llvm.org/D142565
1 parent 409f42b commit 1d02dd2

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void SIMDIntrinsicsCheck::check(const MatchFinder::MatchResult &Result) {
138138
<< SimdRegex.sub(SmallString<32>({Std, "::simd"}),
139139
StdRegex.sub(Std, New));
140140
} else {
141-
diag("'%0' is a non-portable %1 intrinsic function")
141+
diag(Call->getExprLoc(), "'%0' is a non-portable %1 intrinsic function")
142142
<< Old << llvm::Triple::getArchTypeName(Arch);
143143
}
144144
}

clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s portability-simd-intrinsics %t -- \
1+
// RUN: %check_clang_tidy -std=c++11-or-later %s portability-simd-intrinsics %t -- \
2+
// RUN: -config='{CheckOptions: [ \
3+
// RUN: {key: portability-simd-intrinsics.Suggest, value: false} \
4+
// RUN: ]}' -- -target ppc64le -maltivec
5+
// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s portability-simd-intrinsics -check-suffix=BEFORE-CXX20 %t -- \
26
// RUN: -config='{CheckOptions: [ \
37
// RUN: {key: portability-simd-intrinsics.Suggest, value: true} \
48
// RUN: ]}' -- -target ppc64le -maltivec
@@ -13,6 +17,7 @@ void PPC() {
1317
vector int i0, i1;
1418

1519
vec_add(i0, i1);
16-
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'vec_add' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
20+
// CHECK-MESSAGES-BEFORE-CXX20: :[[@LINE-1]]:3: warning: 'vec_add' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
1721
// CHECK-MESSAGES-CXX20: :[[@LINE-2]]:3: warning: 'vec_add' can be replaced by operator+ on std::simd objects [portability-simd-intrinsics]
22+
// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 'vec_add' is a non-portable powerpc64le intrinsic function [portability-simd-intrinsics]
1823
}

clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s portability-simd-intrinsics %t -- \
1+
// RUN: %check_clang_tidy -std=c++11-or-later %s portability-simd-intrinsics %t -- \
2+
// RUN: -config='{CheckOptions: [ \
3+
// RUN: {key: portability-simd-intrinsics.Suggest, value: false} \
4+
// RUN: ]}' -- -target x86_64
5+
// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s portability-simd-intrinsics -check-suffix=BEFORE-CXX20 %t -- \
26
// RUN: -config='{CheckOptions: [ \
37
// RUN: {key: portability-simd-intrinsics.Suggest, value: true} \
48
// RUN: ]}' -- -target x86_64
@@ -21,8 +25,9 @@ void X86() {
2125
__m256 d0;
2226

2327
_mm_add_epi32(i0, i1);
24-
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
28+
// CHECK-MESSAGES-BEFORE-CXX20: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
2529
// CHECK-MESSAGES-CXX20: :[[@LINE-2]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::simd objects [portability-simd-intrinsics]
30+
// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: '_mm_add_epi32' is a non-portable x86_64 intrinsic function [portability-simd-intrinsics]
2631
d0 = _mm256_load_pd(0);
2732
_mm256_store_pd(0, d0);
2833

0 commit comments

Comments
 (0)