Files
TheRock/compiler/amd-llvm/clang/test/Analysis/suppress-namespace-redecl-webkit.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

86 lines
3.2 KiB
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncheckedCallArgsChecker -std=c++20 -verify %s
// expected-no-diagnostics
// Previously [[clang::suppress]] failed for implicit template specializations when
// namespace has multiple redeclarations and suppression is in a different
// redeclaration than the lexical parent of the implicit specialization.
//
// The bug occurred when:
// 1. A template is forward-declared in one namespace block
// 2. A partial specialization with [[clang::suppress]] is in a different block
// 3. An implicit instantiation's getLexicalDeclContext() points to the wrong block
typedef __SIZE_TYPE__ size_t;
namespace std {
template<class T> struct remove_cvref { using type = T; };
template<class T> struct remove_cvref<T&> { using type = T; };
template<class T> using remove_cvref_t = typename remove_cvref<T>::type;
template<class... Ts> struct tuple {};
template<size_t I, class T> struct tuple_element;
template<class T, class... Rs> struct tuple_element<0, tuple<T, Rs...>> { using type = T; };
template<size_t I, class T, class... Rs> struct tuple_element<I, tuple<T, Rs...>> : tuple_element<I-1, tuple<Rs...>> {};
template<size_t I, class T> using tuple_element_t = typename tuple_element<I, T>::type;
template<class T> struct optional { T v; T&& operator*() && { return static_cast<T&&>(v); } operator bool() const { return true; } };
template<class T, class... As> optional<T> make_optional(As...);
} // namespace std
namespace WTF { template<class T> T&& move(T&); }
void WTFCrash();
template<class T> struct CanMakeCheckedPtrBase {
void incrementCheckedPtrCount() const { ++m; }
void decrementCheckedPtrCount() const { if (!m) WTFCrash(); --m; }
mutable T m{};
};
struct Checked : CanMakeCheckedPtrBase<unsigned> {};
Checked* get();
// First namespace block - forward declaration
# 1 "Header1.h" 1
namespace N {
template<class> struct C;
template<class T> struct C<T*> {
template<class D> static std::optional<T*> decode(D&) { return {get()}; }
};
} // namespace N
# 50 "test.cpp" 2
// Second namespace block - this becomes the lexical parent for implicit specializations
# 1 "Header2.h" 1
namespace N {
template<class> struct C;
struct Dec {
template<class T> std::optional<T> decode() { return {C<std::remove_cvref_t<T>>::decode(*this)}; }
};
} // namespace N
# 100 "test.cpp" 2
// Third namespace block - [[clang::suppress]] is here
# 1 "Header3.h" 1
namespace N {
template<class... Es> struct C<std::tuple<Es...>> {
template<class D, class... Os>
static std::optional<std::tuple<Es...>> decode(D& d, std::optional<Os>&&... os) {
if constexpr (sizeof...(Os) < sizeof...(Es)) {
auto o = d.template decode<std::tuple_element_t<sizeof...(Os), std::tuple<Es...>>>();
if (!o) return {};
return decode(d, WTF::move(os)..., WTF::move(o));
} else {
// This [[clang::suppress]] should suppress the warning.
// Bug: Without the fix, it doesn't work because the implicit
// specialization's lexical parent points to Header2.h's namespace block.
[[clang::suppress]] return std::make_optional<std::tuple<Es...>>(*WTF::move(os)...);
}
}
};
} // namespace N
# 150 "test.cpp" 2
void rdar_168941095() {
N::Dec d;
(void)d.decode<std::tuple<Checked*, Checked*>>();
}