| // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| // Exceptions. See /LICENSE for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| // Tests for parenthesized expressions. |
| #include "nullability/test/check_diagnostics.h" |
| #include "third_party/llvm/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h" |
| namespace clang::tidy::nullability { |
| TEST(PointerNullabilityTest, ParenthesizedExpressions) { |
| EXPECT_TRUE(checkDiagnostics(R"cc( |
| void target(Struct1Arg<int *_Nullable> p) { |
| *((p)).arg0; // [[unsafe]] |
| *(p).getT0(); // [[unsafe]] |
| *(((p))).getT0(); // [[unsafe]] |
| EXPECT_TRUE(checkDiagnostics(R"cc( |
| template <int I0, typename T1, typename T2> |
| struct Struct3ArgWithInt { |
| void target(Struct3ArgWithInt<1, int *, int *_Nullable> p) { |
| (*((p)).arg2); // [[unsafe]] |
| *(((((p)))).getT2()); // [[unsafe]] |
| } // namespace clang::tidy::nullability |