Repository: llvm/llvm-project
File: clang/test/Analysis/suppress-namespace-redecl-webkit.cpp (C++)

Code before:
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncheckedCallArgsChecker -std=c++20 -verify %s
// expected-no-diagnostics

// Test: [[clang::suppress]] fails 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 occured 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


Review comment (bug):
The present tense in "fails" sounds like this testcase documents a known  – but not yet fixed – failure of the analyzer. (I've seen many tests that use phrasing like that.) As this failure is will no longer occur in the codebase when this PR is merged, this comment should be in past tense, e.g. as
```suggestion
// Previously [[clang::suppress]] failed for implicit template specializations when
```
Note that "The bug occured" is already in past tense.

Code after:
// 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