ronantakizawa/codereview-bench huggingface dataset:
Repository: llvm/llvm-project
File: libc/src/stdio/baremetal/file_internal.h (C/C++)

Code before:
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {

// TODO: Deduplicate this with __support/File/file.h.
struct FileIOResult {
  size_t value;
  int error;

  constexpr FileIOResult(size_t val) : value(val), error(0) {}
  constexpr FileIOResult(size_t val, int error) : value(val), error(error) {}

  constexpr bool has_error() { return error != 0; }

  constexpr operator size_t() { return value; }
};

// ungetc handling.
int push_ungetc_value(::FILE *stream, int c);
bool pop_ungetc_value(::FILE *stream, unsigned char &out);
namespace internal {
int ungetc_internal(int c, ::FILE *stream);
} // namespace internal

LIBC_INLINE FileIOResult read_internal(char *buf, size_t size, ::FILE *stream) {
  if (size == 0)
    return 0;

  unsigned char ungetc_value = 0;
  size_t ungetc_value_copied = 0;

  if (pop_ungetc_value(stream, ungetc_value)) {
    buf[0] = static_cast<char>(ungetc_value);
    ungetc_value_copied = 1;

    if (size == 1)
      return 1;
  }

  ssize_t ret = __llvm_libc_stdio_read(stream, buf + ungetc_value_copied,
                                       size - ungetc_value_copied);
  if (ret < 0)
    return {ungetc_value_copied, static_cast<int>(-ret)};

  return ret + ungetc_value_copied;
}

LIBC_INLINE FileIOResult write_internal(const char *buf, size_t size,

Review comment (suggestion):
We don't put the other functions like `read_internal` or `write_internal` into `internal` namespace so I'd avoid it here as well for consistency plus I don't think it's really needed since the function already has `_internal` in the name.

```suggestion
int ungetc_internal(int c, ::FILE *stream);
```

Code after:
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {

// TODO: Deduplicate this with __support/File/file.h.
struct FileIOResult {
  size_t value;
  int error;

  constexpr FileIOResult(size_t val) : value(val), error(0) {}
  constexpr FileIOResult(size_t val, int error) : value(val), error(error) {}

  constexpr bool has_error() { return error != 0; }

  constexpr operator size_t() { return value; }
};

// ungetc handling.
int push_ungetc_value(::FILE *stream, int c);
bool pop_ungetc_value(::FILE *stream, unsigned char &out);

LIBC_INLINE int ungetc_internal(int c, ::FILE *stream) {
  return push_ungetc_value(stream, c);
}

LIBC_INLINE FileIOResult read_internal(char *buf, size_t size, ::FILE *stream) {
  if (size == 0)
    return 0;

  unsigned char ungetc_value = 0;
  size_t ungetc_value_copied = 0;

  if (pop_ungetc_value(stream, ungetc_value)) {
    buf[0] = static_cast<char>(ungetc_value);
    ungetc_value_copied = 1;

    if (size == 1)
      return 1;
  }

  ssize_t ret = __llvm_libc_stdio_read(stream, buf + ungetc_value_copied,
                                       size - ungetc_value_copied);
  if (ret < 0)
    return {ungetc_value_copied, static_cast<int>(-ret)};

  return ret + ungetc_value_copied;
}
Repository: llvm/llvm-project
File: libc/src/stdio/baremetal/file_internal.h (C/C++)

Code before:
#include "src/__support/macros/config.h"

#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {

// TODO: Deduplicate this with __support/File/file.h.
struct FileIOResult {
  size_t value;
  int error;

  constexpr FileIOResult(size_t val) : value(val), error(0) {}
  constexpr FileIOResult(size_t val, int error) : value(val), error(error) {}

  constexpr bool has_error() { return error != 0; }

  constexpr operator size_t() { return value; }
};

// ungetc handling.
int push_ungetc_value(::FILE *stream, int c);
bool pop_ungetc_value(::FILE *stream, unsigned char &out);
LIBC_INLINE int ungetc_internal(int c, ::FILE *stream) {
  return push_ungetc_value(stream, c);
}

LIBC_INLINE FileIOResult read_internal(char *buf, size_t size, ::FILE *stream) {
  if (size == 0)
    return 0;

  unsigned char ungetc_value = 0;
  size_t ungetc_value_copied = 0;

  if (pop_ungetc_value(stream, ungetc_value)) {
    buf[0] = static_cast<char>(ungetc_value);
    ungetc_value_copied = 1;

    if (size == 1)
      return 1;
  }

  ssize_t ret = __llvm_libc_stdio_read(stream, buf + ungetc_value_copied,
                                       size - ungetc_value_copied);
  if (ret < 0)
    return {ungetc_value_copied, static_cast<int>(-ret)};

  return ret + ungetc_value_copied;
}

LIBC_INLINE FileIOResult write_internal(const char *buf, size_t size,
                                        ::FILE *stream) {

Review comment (suggestion):
Nit: This is just a formatting suggestion.
```suggestion
int push_ungetc_value(::FILE *stream, int c);
bool pop_ungetc_value(::FILE *stream, unsigned char &out);

LIBC_INLINE int ungetc_internal(int c, ::FILE *stream) {
  return push_ungetc_value(stream, c);
}
```

Code after:
#include "src/__support/macros/config.h"

#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {

// TODO: Deduplicate this with __support/File/file.h.
struct FileIOResult {
  size_t value;
  int error;

  constexpr FileIOResult(size_t val) : value(val), error(0) {}
  constexpr FileIOResult(size_t val, int error) : value(val), error(error) {}

  constexpr bool has_error() { return error != 0; }

  constexpr operator size_t() { return value; }
};

// ungetc handling.
int push_ungetc_value(::FILE *stream, int c);
bool pop_ungetc_value(::FILE *stream, unsigned char &out);

LIBC_INLINE int ungetc_internal(int c, ::FILE *stream) {
  return push_ungetc_value(stream, c);
}

LIBC_INLINE FileIOResult read_internal(char *buf, size_t size, ::FILE *stream) {
  if (size == 0)
    return 0;

  unsigned char ungetc_value = 0;
  size_t ungetc_value_copied = 0;

  if (pop_ungetc_value(stream, ungetc_value)) {
    buf[0] = static_cast<char>(ungetc_value);
    ungetc_value_copied = 1;

    if (size == 1)
      return 1;
  }

  ssize_t ret = __llvm_libc_stdio_read(stream, buf + ungetc_value_copied,
                                       size - ungetc_value_copied);
  if (ret < 0)
    return {ungetc_value_copied, static_cast<int>(-ret)};

  return ret + ungetc_value_copied;
}

LIBC_INLINE FileIOResult write_internal(const char *buf, size_t size,
Repository: llvm/llvm-project
File: clang/test/Driver/sycl-offload-jit-xarch.cpp (C++)

Code before:
// Test passing of -Xarch_<arch> <option> to SYCL offload compilations.

// Verify that -Xarch_spirv64 forwards options to the SYCL device compilation
// and clang-linker-wrapper call.
// RUN: %clang -fsycl -Xarch_spirv64 -O3 -### %s 2>&1 \
// RUN: | FileCheck -check-prefixes=SYCL-DEVICE-O3,CLW-O3 %s
// SYCL-DEVICE-O3: "-triple" "spirv64-unknown-unknown" "-O3"{{.*}} "-fsycl-is-device"
// CLW-O3: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-compiler=spirv64-unknown-unknown=-O3"}}

// Verify that `-Xarch_spirv64` forwards libraries to the device linker.
// RUN: %clang -fsycl -Xarch_spirv64 -Wl,-lfoo -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=DEVICE-LINKER %s
// DEVICE-LINKER: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-linker=spirv64-unknown-unknown=-lfoo"}}


Review comment (suggestion):
```suggestion
// RUN: %clang -fsycl -fsycl-targets=spirv64 -Xarch_spirv64 -O3 -### %s 2>&1 \
```

Code after:
// Test passing of -Xarch_<arch> <option> to SYCL offload compilations.

// Verify that -Xarch_spirv64 forwards options to the SYCL device compilation
// and clang-linker-wrapper call.
// RUN: %clang -fsycl --offload-targets=spirv64-unknown-unknown -Xarch_spirv64 -O3 -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SYCL-DEVICE-O3 %s
// SYCL-DEVICE-O3: "-triple" "spirv64-unknown-unknown" "-O3"{{.*}} "-fsycl-is-device"
// SYCL-DEVICE-O3: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-compiler=spirv64-unknown-unknown=-O3"}}

// Verify that `-Xarch_spirv64` forwards libraries to the device linker.
// RUN: %clang -fsycl --offload-targets=spirv64-unknown-unknown -Xarch_spirv64 -Wl,-lfoo -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=DEVICE-LINKER %s
// DEVICE-LINKER: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-linker=spirv64-unknown-unknown=-lfoo"}}
Repository: llvm/llvm-project
File: clang/test/Driver/sycl-offload-jit-xarch.cpp (C++)

Code before:
// Test passing of -Xarch_<arch> <option> to SYCL offload compilations.

// Verify that -Xarch_spirv64 forwards options to the SYCL device compilation
// and clang-linker-wrapper call.
// RUN: %clang -fsycl -Xarch_spirv64 -O3 -### %s 2>&1 \
// RUN: | FileCheck -check-prefixes=SYCL-DEVICE-O3,CLW-O3 %s
// SYCL-DEVICE-O3: "-triple" "spirv64-unknown-unknown" "-O3"{{.*}} "-fsycl-is-device"
// CLW-O3: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-compiler=spirv64-unknown-unknown=-O3"}}

// Verify that `-Xarch_spirv64` forwards libraries to the device linker.
// RUN: %clang -fsycl -Xarch_spirv64 -Wl,-lfoo -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=DEVICE-LINKER %s
// DEVICE-LINKER: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-linker=spirv64-unknown-unknown=-lfoo"}}


Review comment (suggestion):
```suggestion
// RUN: %clang -fsycl -fsycl-targets=spirv64 -Xarch_spirv64 -Wl,-lfoo -### %s 2>&1 \
```

Code after:
// Test passing of -Xarch_<arch> <option> to SYCL offload compilations.

// Verify that -Xarch_spirv64 forwards options to the SYCL device compilation
// and clang-linker-wrapper call.
// RUN: %clang -fsycl --offload-targets=spirv64-unknown-unknown -Xarch_spirv64 -O3 -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SYCL-DEVICE-O3 %s
// SYCL-DEVICE-O3: "-triple" "spirv64-unknown-unknown" "-O3"{{.*}} "-fsycl-is-device"
// SYCL-DEVICE-O3: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-compiler=spirv64-unknown-unknown=-O3"}}

// Verify that `-Xarch_spirv64` forwards libraries to the device linker.
// RUN: %clang -fsycl --offload-targets=spirv64-unknown-unknown -Xarch_spirv64 -Wl,-lfoo -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=DEVICE-LINKER %s
// DEVICE-LINKER: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-linker=spirv64-unknown-unknown=-lfoo"}}
Repository: llvm/llvm-project
File: clang/test/Driver/sycl-offload-jit-xarch.cpp (C++)

Code before:
// Test passing of -Xarch_<arch> <option> to SYCL offload compilations.

// Verify that -Xarch_spirv64 forwards options to the SYCL device compilation
// and clang-linker-wrapper call.
// RUN: %clang -fsycl -Xarch_spirv64 -O3 -### %s 2>&1 \
// RUN: | FileCheck -check-prefixes=SYCL-DEVICE-O3,CLW-O3 %s
// SYCL-DEVICE-O3: "-triple" "spirv64-unknown-unknown" "-O3"{{.*}} "-fsycl-is-device"
// CLW-O3: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-compiler=spirv64-unknown-unknown=-O3"}}

// Verify that `-Xarch_spirv64` forwards libraries to the device linker.
// RUN: %clang -fsycl -Xarch_spirv64 -Wl,-lfoo -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=DEVICE-LINKER %s
// DEVICE-LINKER: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-linker=spirv64-unknown-unknown=-lfoo"}}


Review comment (suggestion):
I think the idiomatic way to use prefixes is one per test. 
```suggestion
// RUN: | FileCheck -check-prefixes=SYCL-DEVICE-O3 %s
// SYCL-DEVICE-O3: "-triple" "spirv64-unknown-unknown" "-O3"{{.*}} "-fsycl-is-device"
// SYCL-DEVICE-O3: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-compiler=spirv64-unknown-unknown=-O3"}}
```

Code after:
// Test passing of -Xarch_<arch> <option> to SYCL offload compilations.

// Verify that -Xarch_spirv64 forwards options to the SYCL device compilation
// and clang-linker-wrapper call.
// RUN: %clang -fsycl --offload-targets=spirv64-unknown-unknown -Xarch_spirv64 -O3 -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SYCL-DEVICE-O3 %s
// SYCL-DEVICE-O3: "-triple" "spirv64-unknown-unknown" "-O3"{{.*}} "-fsycl-is-device"
// SYCL-DEVICE-O3: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-compiler=spirv64-unknown-unknown=-O3"}}

// Verify that `-Xarch_spirv64` forwards libraries to the device linker.
// RUN: %clang -fsycl --offload-targets=spirv64-unknown-unknown -Xarch_spirv64 -Wl,-lfoo -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=DEVICE-LINKER %s
// DEVICE-LINKER: {{"[^"]*clang-linker-wrapper[^"]*".* "--device-linker=spirv64-unknown-unknown=-lfoo"}}
Repository: llvm/llvm-project
File: clang/test/Analysis/taint-generic.c (C)

Code before:
void testProctitle2(char *real_argv[]) {
  char *app = getenv("APP_NAME");
  if (!app)
    return;
  char *argv[] = {app, "--foobar"};
  setproctitle_init(1, argv, 0);         // expected-warning {{Untrusted data is passed to a user-defined sink}}
  setproctitle_init(1, real_argv, argv); // expected-warning {{Untrusted data is passed to a user-defined sink}}
}

void testAcceptPropagates() {
  int listenSocket = socket(2, 1, 6);
  clang_analyzer_isTainted_int(listenSocket); // expected-warning {{YES}}
  int acceptSocket = accept(listenSocket, 0, 0);
  clang_analyzer_isTainted_int(acceptSocket); // expected-warning {{YES}}
}

int main(int argc, char * argv[]) {
   if (argc < 2)
     return 1;
   char cmd[2048] = "/bin/cat ";
   clang_analyzer_isTainted_char(*argv[1]); // expected-warning{{YES}}
   strncat(cmd, argv[1], sizeof(cmd) - strlen(cmd)-1);
   system(cmd);// expected-warning {{Untrusted data is passed to a system call}}
   return 0;
 }
 

Review comment (suggestion):
```suggestion

```
This trailing whitespace actually suggests to me that this file wasn't clang-formatted. :(

Code after:
void testProctitle2(char *real_argv[]) {
  char *app = getenv("APP_NAME");
  if (!app)
    return;
  char *argv[] = {app, "--foobar"};
  setproctitle_init(1, argv, 0);         // expected-warning {{Untrusted data is passed to a user-defined sink}}
  setproctitle_init(1, real_argv, argv); // expected-warning {{Untrusted data is passed to a user-defined sink}}
}

void testAcceptPropagates() {
  int listenSocket = socket(2, 1, 6);
  clang_analyzer_isTainted_int(listenSocket); // expected-warning {{YES}}
  int acceptSocket = accept(listenSocket, 0, 0);
  clang_analyzer_isTainted_int(acceptSocket); // expected-warning {{YES}}
}

int main(int argc, char * argv[]) {
   if (argc < 2)
     return 1;
   char cmd[2048] = "/bin/cat ";
   clang_analyzer_isTainted_char(*argv[1]); // expected-warning{{YES}}
   strncat(cmd, argv[1], sizeof(cmd) - strlen(cmd)-1);
   system(cmd);// expected-warning {{Untrusted data is passed to a system call}}
   return 0;
 }
Repository: llvm/llvm-project
File: clang/test/CIR/CodeGen/pred-info-builtins.c (C)

Code before:
// RUN: %clang_cc1 -O0 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s --check-prefix=CIR-O0
// RUN: %clang_cc1 -O2 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s --check-prefix=CIR-O2
// RUN: %clang_cc1 -O0 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s --check-prefix=LLVM
// RUN: %clang_cc1 -O0 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=OGCG

extern void __attribute__((noinline)) bar(void);

void expect(int x) {
  if (__builtin_expect(x, 0))
    bar();
}
// CIR-O0: cir.func dso_local @expect
// CIR-O0:   cir.if {{%.*}} {
// CIR-O0:     cir.call @bar() : () -> ()

// CIR-O2: cir.func dso_local @expect
// CIR-O2:   [[EXPECT:%.*]] = cir.expect({{.*}}, {{.*}}) : !s64i
// CIR-O2:   [[EXPECT_BOOL:%.*]] = cir.cast int_to_bool [[EXPECT]] : !s64i -> !cir.bool
// CIR-O2:   cir.if [[EXPECT_BOOL]]
// CIR-O2:     cir.call @bar() : () -> ()

// LLVM-LABEL: @expect
// LLVM: br i1 {{.*}}, label %[[THEN:.*]], label %[[END:.*]]
// LLVM: [[THEN]]:
// LLVM: call void @bar()

// OGCG-LABEL: @expect
// OGCG: br i1 {{.*}}, label %[[THEN:.*]], label %[[END:.*]]
// OGCG: [[THEN]]:

Review comment (suggestion):
```suggestion
// RUN: %clang_cc1 -O2 -disable-llvm-passes -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s --check-prefix=LLVM
// RUN: %clang_cc1 -O2 -disable-llvm-passes -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=OGCG
```
This will generate code according to the O2 rules without running any LLVM optimization passes.

Code after:
// Test __builtin_expect, __builtin_expect_with_probability, and __builtin_unpredictable.
// Focus: O0 vs O2 CIR output (no cir.expect at O0), and LLVM/OGCG with -O2 -disable-llvm-passes.
// Builtin call lowering is also covered by builtin_call.cpp.
//
// RUN: %clang_cc1 -O0 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s --check-prefix=CIR-O0
// CIR-O0-NOT: cir.expect
// RUN: %clang_cc1 -O2 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s --check-prefix=CIR-O2
// RUN: %clang_cc1 -O2 -disable-llvm-passes -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s --check-prefix=LLVM
// RUN: %clang_cc1 -O2 -disable-llvm-passes -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=OGCG

extern void __attribute__((noinline)) bar(void);

void expect(int x) {
  if (__builtin_expect(x, 0))
    bar();
}
// CIR-O0: cir.func {{.*}} @expect
// CIR-O0:   cir.if {{%.*}} {
// CIR-O0:     cir.call @bar() : () -> ()

// CIR-O2: cir.func {{.*}} @expect
// CIR-O2:   [[EXPECT:%.*]] = cir.expect({{.*}}, {{.*}}) : !s64i
// CIR-O2:   [[EXPECT_BOOL:%.*]] = cir.cast int_to_bool [[EXPECT]] : !s64i -> !cir.bool
// CIR-O2:   cir.if [[EXPECT_BOOL]]
// CIR-O2:     cir.call @bar() : () -> ()

// LLVM-LABEL: @expect
// LLVM: br i1 {{.*}}, label %[[THEN:.*]], label %[[END:.*]]
// LLVM: [[THEN]]:
Repository: llvm/llvm-project
File: clang/test/Analysis/suppress-namespace-redecl-core.cpp (C++)

Code before:
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
// expected-no-diagnostics

void clang_analyzer_warnIfReached();

// Forward declaration
namespace N { // 1st
template <class T> struct Wrapper;
} // namespace N

// This becomes the lexical parent for implicit specializations
namespace N { // 2nd
template <class T> struct Wrapper; // DeclWithIssue changes to this 1st.
template <class T> void trigger() {
  Wrapper<T>::get();
}
} // namespace N

// [[clang::suppress]] is here, at the primary template
namespace N { // 3rd
template <class T> struct Wrapper {
  static void get() {
    // This [[clang::suppress]] should suppress the warning.
    // Bug: Without the fix, it doesn't work because the implicit
    // specialization's lexical parent points to second namespace block.
    [[clang::suppress]] clang_analyzer_warnIfReached(); // no-warning
  }
};
} // namespace N

void rdar_168941095() {
  N::trigger<int>();
}

Review comment (suggestion):
~~I'm looking at the printed AST: https://godbolt.org/z/rx6GjGq1b.   It seems that traversing the `ClassTemplateDecl` at this line should not skip the suppression because the `ClassTemplateSpecializationDecl` is a child of it.~~

Code after:
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
// expected-no-diagnostics

void clang_analyzer_warnIfReached();

// Forward declaration
namespace N { // 1st
template <class T> struct Wrapper;
} // namespace N

// This becomes the lexical parent for implicit specializations
namespace N { // 2nd
template <class T> struct Wrapper;
template <class T> void trigger() {
  Wrapper<T>::get();
}
} // namespace N

// [[clang::suppress]] is here, at the primary template
namespace N { // 3rd
template <class T> struct Wrapper {
  static void get() {
    // This [[clang::suppress]] should suppress the warning.
    // In earlier revisions this did not work because the implicit
    // specialization's lexical parent points to second namespace block.
    [[clang::suppress]] clang_analyzer_warnIfReached(); // no-warning
  }
};
} // namespace N

void rdar_168941095() {
  N::trigger<int>();
}
Repository: llvm/llvm-project
File: clang/test/Analysis/suppress-namespace-redecl-core.cpp (C++)

Code before:
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
// expected-no-diagnostics

void clang_analyzer_warnIfReached();

// Forward declaration
namespace N { // 1st
template <class T> struct Wrapper;
} // namespace N

// This becomes the lexical parent for implicit specializations
namespace N { // 2nd
template <class T> struct Wrapper;
template <class T> void trigger() {
  Wrapper<T>::get();
}
} // namespace N

// [[clang::suppress]] is here, at the primary template
namespace N { // 3rd
template <class T> struct Wrapper {
  static void get() {
    // This [[clang::suppress]] should suppress the warning.
    // Bug: Without the fix, it doesn't work because the implicit
    // specialization's lexical parent points to second namespace block.
    [[clang::suppress]] clang_analyzer_warnIfReached(); // no-warning
  }
};
} // namespace N

void rdar_168941095() {
  N::trigger<int>();
}


Review comment (suggestion):
```suggestion
    // In earlier revisions this did not work because the implicit
```
"the fix" would be unclear who reads this code later.

Code after:
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
// expected-no-diagnostics

void clang_analyzer_warnIfReached();

// Forward declaration
namespace N { // 1st
template <class T> struct Wrapper;
} // namespace N

// This becomes the lexical parent for implicit specializations
namespace N { // 2nd
template <class T> struct Wrapper;
template <class T> void trigger() {
  Wrapper<T>::get();
}
} // namespace N

// [[clang::suppress]] is here, at the primary template
namespace N { // 3rd
template <class T> struct Wrapper {
  static void get() {
    // This [[clang::suppress]] should suppress the warning.
    // In earlier revisions this did not work because the implicit
    // specialization's lexical parent points to second namespace block.
    [[clang::suppress]] clang_analyzer_warnIfReached(); // no-warning
  }
};
} // namespace N

void rdar_168941095() {
  N::trigger<int>();
}