diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp b/clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp index 0dc06df4f18b4..6fa700bf06d4f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp @@ -31,7 +31,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1l; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}L{{$}} + // CHECK-MESSAGES-NEXT: {{^ *| *}}L{{$}} // CHECK-FIXES: static constexpr auto v5 = 1L; static_assert(is_same::value, ""); static_assert(v5 == 1, ""); @@ -46,7 +46,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'll', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1ll; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LL{{$}} + // CHECK-MESSAGES-NEXT: {{^ *| *}}LL{{$}} // CHECK-FIXES: static constexpr auto v7 = 1LL; static_assert(is_same::value, ""); static_assert(v7 == 1, ""); @@ -79,7 +79,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lu', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 1lu; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LU{{$}} + // CHECK-MESSAGES-NEXT: {{^ *| *}}LU{{$}} // CHECK-FIXES: static constexpr auto v13 = 1LU; static_assert(is_same::value, ""); static_assert(v13 == 1, ""); @@ -88,7 +88,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Lu', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1Lu; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LU{{$}} + // CHECK-MESSAGES-NEXT: {{^ *| *}}LU{{$}} // CHECK-FIXES: static constexpr auto v14 = 1LU; static_assert(is_same::value, ""); static_assert(v14 == 1, ""); @@ -97,7 +97,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lU', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1lU; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LU{{$}} + // CHECK-MESSAGES-NEXT: {{^ *| *}}LU{{$}} // CHECK-FIXES: static constexpr auto v15 = 1LU; static_assert(is_same::value, ""); static_assert(v15 == 1, ""); @@ -130,7 +130,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llu', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v21 = 1llu; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LLU{{$}} + // CHECK-MESSAGES-NEXT: {{^ *| *}}LLU{{$}} // CHECK-FIXES: static constexpr auto v21 = 1LLU; static_assert(is_same::value, ""); static_assert(v21 == 1, ""); @@ -139,7 +139,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'LLu', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v22 = 1LLu; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LLU{{$}} + // CHECK-MESSAGES-NEXT: {{^ *| *}}LLU{{$}} // CHECK-FIXES: static constexpr auto v22 = 1LLU; static_assert(is_same::value, ""); static_assert(v22 == 1, ""); @@ -148,7 +148,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llU', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v23 = 1llU; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LLU{{$}} + // CHECK-MESSAGES-NEXT: {{^ *| *}}LLU{{$}} // CHECK-FIXES: static constexpr auto v23 = 1LLU; static_assert(is_same::value, ""); static_assert(v23 == 1, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp index a790597fcff51..46d7bc1347d0d 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp @@ -9,7 +9,7 @@ void float16_normal_literals() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.f16; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}} + // CHECK-MESSAGES-NEXT: F16{{$}} // CHECK-FIXES: static constexpr auto v14 = 1.F16; static_assert(is_same::value, ""); static_assert(v14 == 1.F16, ""); @@ -18,7 +18,7 @@ void float16_normal_literals() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1.e0f16; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}} + // CHECK-MESSAGES-NEXT: F16{{$}} // CHECK-FIXES: static constexpr auto v15 = 1.e0F16; static_assert(is_same::value, ""); static_assert(v15 == 1.F16, ""); @@ -39,7 +39,7 @@ void float16_hexadecimal_literals() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 0xfp0f16; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}} + // CHECK-MESSAGES-NEXT: F16{{$}} // CHECK-FIXES: static constexpr auto v13 = 0xfp0F16; static_assert(is_same::value, ""); static_assert(v13 == 0xfp0F16, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp index 8cea2a4d827cb..ef905da6e9f95 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp @@ -14,14 +14,14 @@ void floating_point_half_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: floating point literal has suffix 'h', which is not uppercase // CHECK-MESSAGES-NEXT: static half v2 = 1.h; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}H{{$}} + // CHECK-MESSAGES-NEXT: H{{$}} // CHECK-HIXES: static half v2 = 1.H; static half v3 = 1.e0h; // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: floating point literal has suffix 'h', which is not uppercase // CHECK-MESSAGES-NEXT: static half v3 = 1.e0h; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}H{{$}} + // CHECK-MESSAGES-NEXT: H{{$}} // CHECK-HIXES: static half v3 = 1.e0H; static half v4 = 1.H; // OK. diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp index a0dcc38c8b231..d9f5bfbe3aa38 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp @@ -20,7 +20,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v2 = 1.f; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F{{$}} + // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v2 = 1.F; static_assert(is_same::value, ""); static_assert(v2 == 1.0F, ""); @@ -29,7 +29,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1.e0f; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F{{$}} + // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v3 = 1.e0F; static_assert(is_same::value, ""); static_assert(v3 == 1.0F, ""); @@ -48,7 +48,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'l', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v6 = 1.l; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}L{{$}} + // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v6 = 1.L; static_assert(is_same::value, ""); static_assert(v6 == 1., ""); @@ -57,7 +57,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'l', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1.e0l; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}L{{$}} + // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v7 = 1.e0L; static_assert(is_same::value, ""); static_assert(v7 == 1., ""); @@ -76,7 +76,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'q', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1.q; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}Q{{$}} + // CHECK-MESSAGES-NEXT: Q{{$}} // CHECK-FIXES: static constexpr auto v10 = 1.Q; static_assert(is_same::value, ""); static_assert(v10 == 1., ""); @@ -85,7 +85,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'q', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v11 = 1.e0q; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}Q{{$}} + // CHECK-MESSAGES-NEXT: Q{{$}} // CHECK-FIXES: static constexpr auto v11 = 1.e0Q; static_assert(is_same::value, ""); static_assert(v11 == 1., ""); @@ -106,7 +106,7 @@ void floating_point_complex_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'i', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.i; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}I{{$}} + // CHECK-MESSAGES-NEXT: I{{$}} // CHECK-FIXES: static constexpr auto v14 = 1.I; static_assert(is_same::value, ""); static_assert(v14 == 1.I, ""); @@ -115,7 +115,7 @@ void floating_point_complex_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'i', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1.e0i; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}I{{$}} + // CHECK-MESSAGES-NEXT: I{{$}} // CHECK-FIXES: static constexpr auto v15 = 1.e0I; static_assert(is_same::value, ""); static_assert(v15 == 1.I, ""); @@ -134,7 +134,7 @@ void floating_point_complex_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'j', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v18 = 1.j; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}J{{$}} + // CHECK-MESSAGES-NEXT: J{{$}} // CHECK-FIXES: static constexpr auto v18 = 1.J; static_assert(is_same::value, ""); static_assert(v18 == 1.J, ""); @@ -143,7 +143,7 @@ void floating_point_complex_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'j', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v19 = 1.e0j; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}J{{$}} + // CHECK-MESSAGES-NEXT: J{{$}} // CHECK-FIXES: static constexpr auto v19 = 1.e0J; static_assert(is_same::value, ""); static_assert(v19 == 1.J, ""); @@ -163,7 +163,7 @@ void macros() { // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: floating point literal has suffix 'f', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto m0 = PASSTHROUGH(1.f); // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F{{$}} + // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto m0 = PASSTHROUGH(1.F); static_assert(is_same::value, ""); static_assert(m0 == 1.0F, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp index 57d24fb5712c4..72077153fb718 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp @@ -16,7 +16,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v1 = 0xfp0f; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F{{$}} + // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v1 = 0xfp0F; static_assert(is_same::value, ""); static_assert(v1 == 15, ""); @@ -29,7 +29,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 0xfP0f; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F{{$}} + // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v3 = 0xfP0F; static_assert(is_same::value, ""); static_assert(v3 == 15, ""); @@ -42,7 +42,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 0xFP0f; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F{{$}} + // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v5 = 0xFP0F; static_assert(is_same::value, ""); static_assert(v5 == 15, ""); @@ -55,7 +55,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'f', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 0xFp0f; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F{{$}} + // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto v7 = 0xFp0F; static_assert(is_same::value, ""); static_assert(v7 == 15, ""); @@ -70,7 +70,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'l', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 0xfp0l; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}L{{$}} + // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v9 = 0xfp0L; static_assert(is_same::value, ""); static_assert(v9 == 0xfp0, ""); @@ -85,7 +85,7 @@ void floating_point_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'q', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v11 = 0xfp0q; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}Q{{$}} + // CHECK-MESSAGES-NEXT: Q{{$}} // CHECK-FIXES: static constexpr auto v11 = 0xfp0Q; static_assert(is_same::value, ""); static_assert(v11 == 0xfp0, ""); @@ -102,7 +102,7 @@ void floating_point_complex_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'i', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 0xfp0i; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}I{{$}} + // CHECK-MESSAGES-NEXT: I{{$}} // CHECK-FIXES: static constexpr auto v14 = 0xfp0I; static_assert(is_same::value, ""); static_assert(v14 == 0xfp0I, ""); @@ -117,7 +117,7 @@ void floating_point_complex_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'j', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v18 = 0xfp0j; // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}J{{$}} + // CHECK-MESSAGES-NEXT: J{{$}} // CHECK-FIXES: static constexpr auto v18 = 0xfp0J; static_assert(is_same::value, ""); static_assert(v18 == 0xfp0J, ""); @@ -133,7 +133,7 @@ void macros() { // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: floating point literal has suffix 'f', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto m0 = PASSTHROUGH(0x0p0f); // CHECK-MESSAGES-NEXT: ^ ~ - // CHECK-MESSAGES-NEXT: {{^ *}}F{{$}} + // CHECK-MESSAGES-NEXT: F{{$}} // CHECK-FIXES: static constexpr auto m0 = PASSTHROUGH(0x0p0F); static_assert(is_same::value, ""); static_assert(m0 == 0x0p0F, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp index c787cab1fc4a7..5ee09527999eb 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp @@ -22,7 +22,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1l; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}L{{$}} + // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v5 = 1L; static_assert(is_same::value, ""); static_assert(v5 == 1, ""); @@ -47,7 +47,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'ul', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1ul; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}uL{{$}} + // CHECK-MESSAGES-NEXT: uL{{$}} // CHECK-FIXES: static constexpr auto v9 = 1uL; static_assert(is_same::value, ""); static_assert(v9 == 1, ""); @@ -60,7 +60,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Ul', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v11 = 1Ul; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}uL{{$}} + // CHECK-MESSAGES-NEXT: uL{{$}} // CHECK-FIXES: static constexpr auto v11 = 1uL; static_assert(is_same::value, ""); static_assert(v11 == 1, ""); @@ -69,7 +69,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'UL', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v12 = 1UL; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}uL{{$}} + // CHECK-MESSAGES-NEXT: uL{{$}} // CHECK-FIXES: static constexpr auto v12 = 1uL; static_assert(is_same::value, ""); static_assert(v12 == 1, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp index fe3269f2c506d..7ac4a7502e7b7 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp @@ -21,7 +21,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'i32', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1i32; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}I32{{$}} + // CHECK-MESSAGES-NEXT: I32{{$}} // CHECK-FIXES: static constexpr auto v3 = 1I32; static_assert(is_same::value, ""); static_assert(v3 == 1I32, ""); @@ -36,7 +36,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'i64', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1i64; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}I64{{$}} + // CHECK-MESSAGES-NEXT: I64{{$}} // CHECK-FIXES: static constexpr auto v5 = 1I64; static_assert(is_same::value, ""); static_assert(v5 == 1I64, ""); @@ -51,7 +51,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'i16', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1i16; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}I16{{$}} + // CHECK-MESSAGES-NEXT: I16{{$}} // CHECK-FIXES: static constexpr auto v7 = 1I16; static_assert(is_same::value, ""); static_assert(v7 == 1I16, ""); @@ -66,7 +66,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'i8', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1i8; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}I8{{$}} + // CHECK-MESSAGES-NEXT: I8{{$}} // CHECK-FIXES: static constexpr auto v9 = 1I8; static_assert(is_same::value, ""); static_assert(v9 == 1I8, ""); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp index c03ccc23992fc..084d9f68e0b5e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp @@ -21,7 +21,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'u', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1u; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}U{{$}} + // CHECK-MESSAGES-NEXT: U{{$}} // CHECK-FIXES: static constexpr auto v3 = 1U; static_assert(is_same::value, ""); static_assert(v3 == 1, ""); @@ -36,7 +36,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1l; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}L{{$}} + // CHECK-MESSAGES-NEXT: L{{$}} // CHECK-FIXES: static constexpr auto v5 = 1L; static_assert(is_same::value, ""); static_assert(v5 == 1, ""); @@ -51,7 +51,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'll', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1ll; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LL{{$}} + // CHECK-MESSAGES-NEXT: LL{{$}} // CHECK-FIXES: static constexpr auto v7 = 1LL; static_assert(is_same::value, ""); static_assert(v7 == 1, ""); @@ -66,7 +66,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'ul', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1ul; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}UL{{$}} + // CHECK-MESSAGES-NEXT: UL{{$}} // CHECK-FIXES: static constexpr auto v9 = 1UL; static_assert(is_same::value, ""); static_assert(v9 == 1, ""); @@ -75,7 +75,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uL', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v10 = 1uL; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}UL{{$}} + // CHECK-MESSAGES-NEXT: UL{{$}} // CHECK-FIXES: static constexpr auto v10 = 1UL; static_assert(is_same::value, ""); static_assert(v10 == 1, ""); @@ -84,7 +84,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Ul', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v11 = 1Ul; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}UL{{$}} + // CHECK-MESSAGES-NEXT: UL{{$}} // CHECK-FIXES: static constexpr auto v11 = 1UL; static_assert(is_same::value, ""); static_assert(v11 == 1, ""); @@ -99,7 +99,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lu', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 1lu; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LU{{$}} + // CHECK-MESSAGES-NEXT: LU{{$}} // CHECK-FIXES: static constexpr auto v13 = 1LU; static_assert(is_same::value, ""); static_assert(v13 == 1, ""); @@ -108,7 +108,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Lu', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1Lu; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LU{{$}} + // CHECK-MESSAGES-NEXT: LU{{$}} // CHECK-FIXES: static constexpr auto v14 = 1LU; static_assert(is_same::value, ""); static_assert(v14 == 1, ""); @@ -117,7 +117,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lU', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1lU; // CHECK-MESSAGES-NEXT: ^~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LU{{$}} + // CHECK-MESSAGES-NEXT: LU{{$}} // CHECK-FIXES: static constexpr auto v15 = 1LU; static_assert(is_same::value, ""); static_assert(v15 == 1, ""); @@ -132,7 +132,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'ull', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v17 = 1ull; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}ULL{{$}} + // CHECK-MESSAGES-NEXT: ULL{{$}} // CHECK-FIXES: static constexpr auto v17 = 1ULL; static_assert(is_same::value, ""); static_assert(v17 == 1, ""); @@ -141,7 +141,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'uLL', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v18 = 1uLL; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}ULL{{$}} + // CHECK-MESSAGES-NEXT: ULL{{$}} // CHECK-FIXES: static constexpr auto v18 = 1ULL; static_assert(is_same::value, ""); static_assert(v18 == 1, ""); @@ -150,7 +150,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Ull', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v19 = 1Ull; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}ULL{{$}} + // CHECK-MESSAGES-NEXT: ULL{{$}} // CHECK-FIXES: static constexpr auto v19 = 1ULL; static_assert(is_same::value, ""); static_assert(v19 == 1, ""); @@ -165,7 +165,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llu', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v21 = 1llu; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LLU{{$}} + // CHECK-MESSAGES-NEXT: LLU{{$}} // CHECK-FIXES: static constexpr auto v21 = 1LLU; static_assert(is_same::value, ""); static_assert(v21 == 1, ""); @@ -174,7 +174,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'LLu', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v22 = 1LLu; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LLU{{$}} + // CHECK-MESSAGES-NEXT: LLU{{$}} // CHECK-FIXES: static constexpr auto v22 = 1LLU; static_assert(is_same::value, ""); static_assert(v22 == 1, ""); @@ -183,7 +183,7 @@ void integer_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llU', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v23 = 1llU; // CHECK-MESSAGES-NEXT: ^~~~ - // CHECK-MESSAGES-NEXT: {{^ *}}LLU{{$}} + // CHECK-MESSAGES-NEXT: LLU{{$}} // CHECK-FIXES: static constexpr auto v23 = 1LLU; static_assert(is_same::value, ""); static_assert(v23 == 1, ""); @@ -200,7 +200,7 @@ void integer_complex_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'i', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v25 = 1i; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}I{{$}} + // CHECK-MESSAGES-NEXT: I{{$}} // CHECK-FIXES: static constexpr auto v25 = 1I; static_assert(is_same::value, ""); static_assert(v25 == 1I, ""); @@ -215,7 +215,7 @@ void integer_complex_suffix() { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'j', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto v27 = 1j; // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}J{{$}} + // CHECK-MESSAGES-NEXT: J{{$}} // CHECK-FIXES: static constexpr auto v27 = 1J; static_assert(is_same::value, ""); static_assert(v27 == 1J, ""); @@ -231,7 +231,7 @@ void macros() { // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: integer literal has suffix 'u', which is not uppercase // CHECK-MESSAGES-NEXT: static constexpr auto m0 = PASSTHROUGH(1u); // CHECK-MESSAGES-NEXT: ^~ - // CHECK-MESSAGES-NEXT: {{^ *}}U{{$}} + // CHECK-MESSAGES-NEXT: U{{$}} // CHECK-FIXES: static constexpr auto m0 = PASSTHROUGH(1U); static_assert(is_same::value, ""); static_assert(m0 == 1, ""); diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 8a9dd04cda5bb..b5814350a5f11 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -314,6 +314,11 @@ Improvements to Clang's diagnostics is an incomplete type. (`#55175: `_, and fixes an incorrect mention of ``alignof`` in a diagnostic about ``alignas``). +- Clang will now show a margin with line numbers to the left of each line + of code it prints for diagnostics. This can be disabled using + ``-fno-diagnostics-show-line-numbers``. At the same time, the maximum + number of code lines it prints has been increased from 1 to 16. This + can be controlled using ``-fcaret-diagnostics-max-lines=``. Bug Fixes in This Version ------------------------- diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index cee037a7ea89d..6b597242e3f93 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -575,6 +575,38 @@ output format of the diagnostics that it generates. [...]>>> +.. option:: -fcaret-diagnostics-max-lines: + + Controls how many lines of code clang prints for diagnostics. By default, + clang prints a maximum of 16 lines of code. + + +.. option:: -fdiagnostics-show-line-numbers: + + Controls whether clang will print a margin containing the line number on + the left of each line of code it prints for diagnostics. + + Default: + + :: + + test.cpp:5:1: error: 'main' must return 'int' + 5 | void main() {} + | ^~~~ + | int + + + With -fno-diagnostics-show-line-numbers: + + :: + + test.cpp:5:1: error: 'main' must return 'int' + void main() {} + ^~~~ + int + + + .. _cl_diag_warning_groups: Individual Warning Groups diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def index 1d6d55a411e78..6d0c1b14acc12 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.def +++ b/clang/include/clang/Basic/DiagnosticOptions.def @@ -90,6 +90,8 @@ VALUE_DIAGOPT(ConstexprBacktraceLimit, 32, DefaultConstexprBacktraceLimit) VALUE_DIAGOPT(SpellCheckingLimit, 32, DefaultSpellCheckingLimit) /// Limit number of lines shown in a snippet. VALUE_DIAGOPT(SnippetLineLimit, 32, DefaultSnippetLineLimit) +/// Show line number column on the left of snippets. +VALUE_DIAGOPT(ShowLineNumbers, 1, DefaultShowLineNumbers) VALUE_DIAGOPT(TabStop, 32, DefaultTabStop) /// The distance between tab stops. /// Column limit for formatting message diagnostics, or 0 if unused. diff --git a/clang/include/clang/Basic/DiagnosticOptions.h b/clang/include/clang/Basic/DiagnosticOptions.h index 4b0d45a3ff7c7..7e218b9c71e69 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.h +++ b/clang/include/clang/Basic/DiagnosticOptions.h @@ -84,7 +84,8 @@ class DiagnosticOptions : public RefCountedBase{ DefaultTemplateBacktraceLimit = 10, DefaultConstexprBacktraceLimit = 10, DefaultSpellCheckingLimit = 50, - DefaultSnippetLineLimit = 1, + DefaultSnippetLineLimit = 16, + DefaultShowLineNumbers = 1, }; // Define simple diagnostic options (with no accessors). diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f6240f86447cb..41bd1c00eb229 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2566,6 +2566,10 @@ defm operator_names : BoolFOption<"operator-names", def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in diagnostics">, MarshallingInfoFlag>; +defm diagnostics_show_line_numbers : BoolFOption<"diagnostics-show-line-numbers", + DiagnosticOpts<"ShowLineNumbers">, DefaultTrue, + NegFlag, + PosFlag>; def fno_stack_protector : Flag<["-"], "fno-stack-protector">, Group, HelpText<"Disable the use of stack protectors">; def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group, diff --git a/clang/include/clang/Frontend/TextDiagnostic.h b/clang/include/clang/Frontend/TextDiagnostic.h index a2eec46beccd1..7eb0ab0cdc9bc 100644 --- a/clang/include/clang/Frontend/TextDiagnostic.h +++ b/clang/include/clang/Frontend/TextDiagnostic.h @@ -103,7 +103,8 @@ class TextDiagnostic : public DiagnosticRenderer { SmallVectorImpl &Ranges, ArrayRef Hints); - void emitSnippet(StringRef SourceLine); + void emitSnippet(StringRef SourceLine, unsigned MaxLineNoDisplayWidth, + unsigned LineNo); void emitParseableFixits(ArrayRef Hints, const SourceManager &SM); }; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index d5e8718641754..e22c2ce7f2ede 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4111,6 +4111,9 @@ static void RenderDiagnosticsOptions(const Driver &D, const ArgList &Args, Args.addOptOutFlag(CmdArgs, options::OPT_fshow_source_location, options::OPT_fno_show_source_location); + Args.addOptOutFlag(CmdArgs, options::OPT_fdiagnostics_show_line_numbers, + options::OPT_fno_diagnostics_show_line_numbers); + if (Args.hasArg(options::OPT_fdiagnostics_absolute_paths)) CmdArgs.push_back("-fdiagnostics-absolute-paths"); diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index 08f84d28bb852..baf9b017fc83e 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -471,9 +471,7 @@ static void selectInterestingSourceRegion(std::string &SourceLine, CaretEnd = map.byteToColumn(SourceEnd) + CaretColumnsOutsideSource; // [CaretStart, CaretEnd) is the slice we want. Update the various - // output lines to show only this slice, with two-space padding - // before the lines so that it looks nicer. - + // output lines to show only this slice. assert(CaretStart!=(unsigned)-1 && CaretEnd!=(unsigned)-1 && SourceStart!=(unsigned)-1 && SourceEnd!=(unsigned)-1); assert(SourceStart <= SourceEnd); @@ -1120,6 +1118,14 @@ static std::string buildFixItInsertionLine(FileID FID, return FixItInsertionLine; } +static unsigned getNumDisplayWidth(unsigned N) { + unsigned L = 1u, M = 10u; + while (M <= N && ++L != std::numeric_limits::digits10 + 1) + M *= 10u; + + return L; +} + /// Emit a code snippet and caret line. /// /// This routine emits a single line's code snippet and caret line.. @@ -1172,7 +1178,26 @@ void TextDiagnostic::emitSnippetAndCaret( Lines = maybeAddRange(Lines, *OptionalRange, MaxLines); } - for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; ++LineNo) { + // Our line numbers look like: + // " [number] | " + // Where [number] is MaxLineNoDisplayWidth columns + // and the full thing is therefore MaxLineNoDisplayWidth + 4 columns. + unsigned DisplayLineNo = Loc.getPresumedLoc().getLine(); + unsigned MaxLineNoDisplayWidth = + DiagOpts->ShowLineNumbers + ? std::max(4u, getNumDisplayWidth(DisplayLineNo + MaxLines)) + : 0; + auto indentForLineNumbers = [&] { + if (MaxLineNoDisplayWidth > 0) { + OS << ' '; + for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) + OS << ' '; + OS << " | "; + } + }; + + for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; + ++LineNo, ++DisplayLineNo) { const char *BufStart = BufData.data(); const char *BufEnd = BufStart + BufData.size(); @@ -1245,9 +1270,10 @@ void TextDiagnostic::emitSnippetAndCaret( CaretLine.erase(CaretLine.end() - 1); // Emit what we have computed. - emitSnippet(SourceLine); + emitSnippet(SourceLine, MaxLineNoDisplayWidth, DisplayLineNo); if (!CaretLine.empty()) { + indentForLineNumbers(); if (DiagOpts->ShowColors) OS.changeColor(caretColor, true); OS << CaretLine << '\n'; @@ -1256,6 +1282,7 @@ void TextDiagnostic::emitSnippetAndCaret( } if (!FixItInsertionLine.empty()) { + indentForLineNumbers(); if (DiagOpts->ShowColors) // Print fixit line in color OS.changeColor(fixitColor, false); @@ -1271,7 +1298,8 @@ void TextDiagnostic::emitSnippetAndCaret( emitParseableFixits(Hints, SM); } -void TextDiagnostic::emitSnippet(StringRef line) { +void TextDiagnostic::emitSnippet(StringRef line, unsigned MaxLineNoDisplayWidth, + unsigned LineNo) { if (line.empty()) return; @@ -1280,6 +1308,16 @@ void TextDiagnostic::emitSnippet(StringRef line) { std::string to_print; bool print_reversed = false; + // Emit line number. + if (MaxLineNoDisplayWidth > 0) { + unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); + OS << ' '; + for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) + OS << ' '; + OS << LineNo; + OS << " | "; + } + while (i,bool> res = printableTextForNextCharacter(line, &i, DiagOpts->TabStop); diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp index 85dd77f9a8774..30798793ceab1 100644 --- a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp +++ b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp @@ -5,14 +5,14 @@ void raw_ptr() { RefCountable* ref_countable = nullptr; auto foo1 = [ref_countable](){}; // CHECK: warning: Captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker] - // CHECK-NEXT:{{^}} auto foo1 = [ref_countable](){}; - // CHECK-NEXT:{{^}} ^ + // CHECK-NEXT:{{^ 6 | }} auto foo1 = [ref_countable](){}; + // CHECK-NEXT:{{^ | }} ^ auto foo2 = [&ref_countable](){}; // CHECK: warning: Captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker] auto foo3 = [&](){ ref_countable = nullptr; }; // CHECK: warning: Implicitly captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker] - // CHECK-NEXT:{{^}} auto foo3 = [&](){ ref_countable = nullptr; }; - // CHECK-NEXT:{{^}} ^ + // CHECK-NEXT:{{^ 12 | }} auto foo3 = [&](){ ref_countable = nullptr; }; + // CHECK-NEXT:{{^ | }} ^ auto foo4 = [=](){ (void) ref_countable; }; // CHECK: warning: Implicitly captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker] } diff --git a/clang/test/FixIt/fixit-function-call.cpp b/clang/test/FixIt/fixit-function-call.cpp index 88f636ea5859d..17c50adffc4a2 100644 --- a/clang/test/FixIt/fixit-function-call.cpp +++ b/clang/test/FixIt/fixit-function-call.cpp @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2> %t +// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 1 -x c++ %s 2> %t // RUN: FileCheck %s < %t // PR5941 // END. diff --git a/clang/test/FixIt/fixit-newline-style.c b/clang/test/FixIt/fixit-newline-style.c index 8c5f424c39873..091b79426bcdf 100644 --- a/clang/test/FixIt/fixit-newline-style.c +++ b/clang/test/FixIt/fixit-newline-style.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -pedantic -Wunused-label -x c %s 2>&1 | FileCheck %s -strict-whitespace +// RUN: %clang_cc1 -pedantic -Wunused-label -fno-diagnostics-show-line-numbers -x c %s 2>&1 | FileCheck %s -strict-whitespace // This file intentionally uses a CRLF newline style // diff --git a/clang/test/FixIt/fixit-unicode-with-utf8-output.c b/clang/test/FixIt/fixit-unicode-with-utf8-output.c index a1a7bb7338095..f5aec89939adf 100644 --- a/clang/test/FixIt/fixit-unicode-with-utf8-output.c +++ b/clang/test/FixIt/fixit-unicode-with-utf8-output.c @@ -1,7 +1,7 @@ // This test is an additional set of checks for the fixit-unicode.c test for // systems capable of outputting Unicode characters to the standard output in // the UTF-8 encoding. -// RUN: not %clang_cc1 -fsyntax-only %S/fixit-unicode.c 2>&1 | FileCheck -strict-whitespace %s +// RUN: not %clang_cc1 -fsyntax-only -fno-diagnostics-show-line-numbers %S/fixit-unicode.c 2>&1 | FileCheck -strict-whitespace %s // REQUIRES: utf8-capable-terminal // CHECK: warning: format specifies type 'int' but the argument has type 'long' diff --git a/clang/test/FixIt/fixit-unicode.c b/clang/test/FixIt/fixit-unicode.c index 70c9751a2bcd6..87819cdfbea17 100644 --- a/clang/test/FixIt/fixit-unicode.c +++ b/clang/test/FixIt/fixit-unicode.c @@ -2,8 +2,8 @@ // There's a set of additional checks for systems with proper support of UTF-8 // on the standard output in fixit-unicode-with-utf8-output.c. -// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s -// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s +// RUN: not %clang_cc1 -fsyntax-only -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -strict-whitespace %s +// RUN: not %clang_cc1 -fsyntax-only -fno-diagnostics-show-line-numbers -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s struct Foo { int bar; diff --git a/clang/test/Frontend/source-col-map.c b/clang/test/Frontend/source-col-map.c index b257261b8b2bc..20030a28f5c19 100644 --- a/clang/test/Frontend/source-col-map.c +++ b/clang/test/Frontend/source-col-map.c @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -fsyntax-only -fmessage-length=75 -o /dev/null -x c < %s 2>&1 | FileCheck %s -strict-whitespace +// RUN: not %clang_cc1 -fsyntax-only -fno-diagnostics-show-line-numbers -fmessage-length=75 -o /dev/null -x c < %s 2>&1 | FileCheck %s -strict-whitespace // REQUIRES: utf8-capable-terminal // Test case for the text diagnostics source column conversion crash. diff --git a/clang/test/Lexer/header.cpp b/clang/test/Lexer/header.cpp index f02b1e69db439..34ed2686b0e72 100644 --- a/clang/test/Lexer/header.cpp +++ b/clang/test/Lexer/header.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -Wno-header-guard %s -// RUN: %clang_cc1 -fsyntax-only -Wheader-guard %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -Wheader-guard -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s #include "Inputs/good-header-guard.h" #include "Inputs/no-define.h" diff --git a/clang/test/Lexer/string-literal-errors.cpp b/clang/test/Lexer/string-literal-errors.cpp index 223dca4b94f62..c819ba435dbd2 100644 --- a/clang/test/Lexer/string-literal-errors.cpp +++ b/clang/test/Lexer/string-literal-errors.cpp @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s +// RUN: not %clang_cc1 -fsyntax-only -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -strict-whitespace %s void foo() { (void)"\q \u123z \x \U \U123 \U12345 \u123 \xyzzy \777 \U" diff --git a/clang/test/Misc/caret-diags-macros.c b/clang/test/Misc/caret-diags-macros.c index e60ed389e656c..13b084b853acc 100644 --- a/clang/test/Misc/caret-diags-macros.c +++ b/clang/test/Misc/caret-diags-macros.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s -strict-whitespace +// RUN: %clang_cc1 -fsyntax-only -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s -strict-whitespace #define M1(x) x #define M2 1; diff --git a/clang/test/Misc/caret-diags-multiline.cpp b/clang/test/Misc/caret-diags-multiline.cpp index 90b50ff398ace..baf8e5a219be3 100644 --- a/clang/test/Misc/caret-diags-multiline.cpp +++ b/clang/test/Misc/caret-diags-multiline.cpp @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -std=c++11 -fcaret-diagnostics-max-lines 5 -Wsometimes-uninitialized %s 2>&1 | FileCheck %s --strict-whitespace +// RUN: not %clang_cc1 -std=c++11 -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 5 -Wsometimes-uninitialized %s 2>&1 | FileCheck %s --strict-whitespace void line(int); diff --git a/clang/test/Misc/diag-macro-backtrace.c b/clang/test/Misc/diag-macro-backtrace.c index 8d7d5726ad82d..0eb7bbb9f3355 100644 --- a/clang/test/Misc/diag-macro-backtrace.c +++ b/clang/test/Misc/diag-macro-backtrace.c @@ -1,4 +1,4 @@ -// RUN: not %clang -fsyntax-only -fmacro-backtrace-limit=0 %s 2>&1 | FileCheck %s +// RUN: not %clang -fsyntax-only -fno-diagnostics-show-line-numbers -fmacro-backtrace-limit=0 %s 2>&1 | FileCheck %s #define FOO 1+"hi" #define BAR FOO diff --git a/clang/test/Misc/message-length.c b/clang/test/Misc/message-length.c index 1e0b4edb7c032..4e2818121a132 100644 --- a/clang/test/Misc/message-length.c +++ b/clang/test/Misc/message-length.c @@ -28,7 +28,7 @@ void a_very_long_line(int *ip, float *FloatPointer) { #pragma STDC CX_LIMITED_RANGE // some long comment text and a brace, eh {} // CHECK: FILE:23:78 -// CHECK: {{^ ...// some long comment text and a brace, eh {}}} +// CHECK: {{^ 23 | ...// some long comment text and a brace, eh {}}} struct A { int x; }; void h(struct A *a) { diff --git a/clang/test/Misc/tabstop.c b/clang/test/Misc/tabstop.c index 500bf2a834a31..834d1839a3d8b 100644 --- a/clang/test/Misc/tabstop.c +++ b/clang/test/Misc/tabstop.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -ftabstop 3 -fsyntax-only -Wno-error=int-conversion %s 2>&1 | FileCheck -check-prefix=CHECK-3 -strict-whitespace %s -// RUN: %clang_cc1 -ftabstop 4 -fsyntax-only -Wno-error=int-conversion %s 2>&1 | FileCheck -check-prefix=CHECK-4 -strict-whitespace %s -// RUN: %clang_cc1 -ftabstop 5 -fsyntax-only -Wno-error=int-conversion %s 2>&1 | FileCheck -check-prefix=CHECK-5 -strict-whitespace %s -// RUN: %clang_cc1 -ftabstop 101 -fsyntax-only -Wno-error=int-conversion %s 2>&1 | FileCheck -check-prefix=CHECK-101 -strict-whitespace %s +// RUN: %clang_cc1 -ftabstop 3 -fsyntax-only -Wno-error=int-conversion -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -check-prefix=CHECK-3 -strict-whitespace %s +// RUN: %clang_cc1 -ftabstop 4 -fsyntax-only -Wno-error=int-conversion -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -check-prefix=CHECK-4 -strict-whitespace %s +// RUN: %clang_cc1 -ftabstop 5 -fsyntax-only -Wno-error=int-conversion -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -check-prefix=CHECK-5 -strict-whitespace %s +// RUN: %clang_cc1 -ftabstop 101 -fsyntax-only -Wno-error=int-conversion -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -check-prefix=CHECK-101 -strict-whitespace %s // tab void* a = 1; diff --git a/clang/test/Misc/unnecessary-elipses.cpp b/clang/test/Misc/unnecessary-elipses.cpp index c8c178c37f6c6..b9f7cb7d3e00e 100644 --- a/clang/test/Misc/unnecessary-elipses.cpp +++ b/clang/test/Misc/unnecessary-elipses.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fmessage-length=80 %s 2>&1 | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -fsyntax-only -fmessage-length=80 -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -strict-whitespace %s int main() { "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; diff --git a/clang/test/Misc/unprintable.c b/clang/test/Misc/unprintable.c index 30e4494566300..02402cdfa6693 100644 --- a/clang/test/Misc/unprintable.c +++ b/clang/test/Misc/unprintable.c @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 %s -fmessage-length=40 2>&1 | FileCheck -strict-whitespace %s +// RUN: not %clang_cc1 %s -fmessage-length=40 -fno-diagnostics-show-line-numbers 2>&1 | FileCheck -strict-whitespace %s int main() { int i; diff --git a/clang/test/Misc/wrong-encoding.c b/clang/test/Misc/wrong-encoding.c index 4d8aa94ffffb2..98c1ecb9b5a66 100644 --- a/clang/test/Misc/wrong-encoding.c +++ b/clang/test/Misc/wrong-encoding.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s // REQUIRES: asserts void foo(void) { diff --git a/clang/test/Parser/brackets.c b/clang/test/Parser/brackets.c index a651c35d073a8..1821747d13515 100644 --- a/clang/test/Parser/brackets.c +++ b/clang/test/Parser/brackets.c @@ -2,7 +2,7 @@ // RUN: cp %s %t // RUN: not %clang_cc1 -fixit %t -x c -DFIXIT // RUN: %clang_cc1 -fsyntax-only %t -x c -DFIXIT -// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -strict-whitespace +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s -strict-whitespace void test1(void) { int a[] = {0,1,1,2,3}; diff --git a/clang/test/Parser/brackets.cpp b/clang/test/Parser/brackets.cpp index 415cbdda83f5f..40b08c37a06a1 100644 --- a/clang/test/Parser/brackets.cpp +++ b/clang/test/Parser/brackets.cpp @@ -2,7 +2,7 @@ // RUN: cp %s %t // RUN: not %clang_cc1 -fixit %t -x c++ -DFIXIT // RUN: %clang_cc1 -fsyntax-only %t -x c++ -DFIXIT -// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -strict-whitespace +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s -strict-whitespace void test1() { int a[] = {0,1,1,2,3}; diff --git a/clang/test/Preprocessor/ucn-pp-identifier.c b/clang/test/Preprocessor/ucn-pp-identifier.c index e1bcdfdcaa364..0cdff6e9db568 100644 --- a/clang/test/Preprocessor/ucn-pp-identifier.c +++ b/clang/test/Preprocessor/ucn-pp-identifier.c @@ -112,9 +112,9 @@ C 1 #define capital_u_\U00FC // expected-warning@-1 {{incomplete universal character name}} expected-note@-1 {{did you mean to use '\u'?}} expected-warning@-1 {{whitespace}} // CHECK: note: did you mean to use '\u'? -// CHECK-NEXT: #define capital_u_\U00FC -// CHECK-NEXT: {{^ \^}} -// CHECK-NEXT: {{^ u}} +// CHECK-NEXT: {{^ 112 | #define capital_u_\U00FC}} +// CHECK-NEXT: {{^ | \^}} +// CHECK-NEXT: {{^ | u}} #define \u{} // expected-warning {{empty delimited universal character name; treating as '\' 'u' '{' '}'}} expected-error {{macro name must be an identifier}} #define \u1{123} // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{macro name must be an identifier}} diff --git a/clang/test/Sema/caret-diags-complex-init.cpp b/clang/test/Sema/caret-diags-complex-init.cpp index d8a1b7837a640..83aab5c4e0b7d 100644 --- a/clang/test/Sema/caret-diags-complex-init.cpp +++ b/clang/test/Sema/caret-diags-complex-init.cpp @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fcaret-diagnostics-max-lines 5 %s 2>&1 | FileCheck %s -strict-whitespace +// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 5 %s 2>&1 | FileCheck %s -strict-whitespace //CHECK: {{.*}}: error: excess elements in scalar initializer diff --git a/clang/test/SemaCXX/struct-class-redecl.cpp b/clang/test/SemaCXX/struct-class-redecl.cpp index 622d5a0b652a7..ab6488b237f55 100644 --- a/clang/test/SemaCXX/struct-class-redecl.cpp +++ b/clang/test/SemaCXX/struct-class-redecl.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags -verify %s -// RUN: not %clang_cc1 -fsyntax-only -Wmismatched-tags %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags -fno-diagnostics-show-line-numbers -verify %s +// RUN: not %clang_cc1 -fsyntax-only -Wmismatched-tags -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s class X; // expected-note 2{{here}} typedef struct X * X_t; // expected-warning{{previously declared}} union X { int x; float y; }; // expected-error{{use of 'X' with tag type that does not match previous declaration}} diff --git a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py index 72154ef4622e1..bf1fc8e4e0e0a 100644 --- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py +++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py @@ -30,20 +30,38 @@ def test_source_and_caret_printing(self): self.assertFalse(value.GetError().Success()) # We should get a nice diagnostic with a caret pointing at the start of # the identifier. - self.assertIn("\nunknown_identifier\n^\n", value.GetError().GetCString()) + self.assertIn( + """ + 1 | unknown_identifier + | ^ +""", + value.GetError().GetCString(), + ) self.assertIn(":1:1", value.GetError().GetCString()) # Same as above but with the identifier in the middle. - value = frame.EvaluateExpression("1 + unknown_identifier ") + value = frame.EvaluateExpression("1 + unknown_identifier") self.assertFalse(value.GetError().Success()) - self.assertIn("\n1 + unknown_identifier", value.GetError().GetCString()) - self.assertIn("\n ^\n", value.GetError().GetCString()) + self.assertIn( + """ + 1 | 1 + unknown_identifier + | ^ +""", + value.GetError().GetCString(), + ) # Multiline expressions. value = frame.EvaluateExpression("int a = 0;\nfoobar +=1;\na") self.assertFalse(value.GetError().Success()) # We should still get the right line information and caret position. - self.assertIn("\nfoobar +=1;\n^\n", value.GetError().GetCString()) + self.assertIn( + """ + 2 | foobar +=1; + | ^ +""", + value.GetError().GetCString(), + ) + # It's the second line of the user expression. self.assertIn(":2:1", value.GetError().GetCString()) @@ -54,8 +72,13 @@ def test_source_and_caret_printing(self): value = frame.EvaluateExpression("void foo(unknown_type x) {}", top_level_opts) self.assertFalse(value.GetError().Success()) self.assertIn( - "\nvoid foo(unknown_type x) {}\n ^\n", value.GetError().GetCString() + """ + 1 | void foo(unknown_type x) {} + | ^ +""", + value.GetError().GetCString(), ) + # Top-level expressions might use a different wrapper code, but the file name should still # be the same. self.assertIn(":1:10", value.GetError().GetCString()) @@ -63,7 +86,14 @@ def test_source_and_caret_printing(self): # Multiline top-level expressions. value = frame.EvaluateExpression("void x() {}\nvoid foo;", top_level_opts) self.assertFalse(value.GetError().Success()) - self.assertIn("\nvoid foo;\n ^", value.GetError().GetCString()) + self.assertIn( + """ + 2 | void foo; + | ^ +""", + value.GetError().GetCString(), + ) + self.assertIn(":2:6", value.GetError().GetCString()) # Test that we render Clang's 'notes' correctly. @@ -72,7 +102,14 @@ def test_source_and_caret_printing(self): ) self.assertFalse(value.GetError().Success()) self.assertIn( - ":1:8: previous definition is here\nstruct SFoo{}; struct SFoo { int x; };\n ^\n", + ":1:8: previous definition is here\n", + value.GetError().GetCString(), + ) + self.assertIn( + """ + 1 | struct SFoo{}; struct SFoo { int x; }; + | ^ +""", value.GetError().GetCString(), ) @@ -82,14 +119,29 @@ def test_source_and_caret_printing(self): value = frame.EvaluateExpression("struct FooBar { double x };", top_level_opts) self.assertFalse(value.GetError().Success()) self.assertIn( - "error: :1:8: redefinition of 'FooBar'\nstruct FooBar { double x };\n ^\n", + "error: :1:8: redefinition of 'FooBar'\n", + value.GetError().GetCString(), + ) + self.assertIn( + """ + 1 | struct FooBar { double x }; + | ^ +""", value.GetError().GetCString(), ) value = frame.EvaluateExpression("foo(1, 2)") self.assertFalse(value.GetError().Success()) self.assertIn( - "error: :1:1: no matching function for call to 'foo'\nfoo(1, 2)\n^~~\nnote: candidate function not viable: requires single argument 'x', but 2 arguments were provided\n\n", + "error: :1:1: no matching function for call to 'foo'\n", + value.GetError().GetCString(), + ) + self.assertIn( + """ + 1 | foo(1, 2) + | ^~~ +note: candidate function not viable: requires single argument 'x', but 2 arguments were provided +""", value.GetError().GetCString(), ) @@ -99,7 +151,14 @@ def test_source_and_caret_printing(self): value = frame.EvaluateExpression("struct Redef { float y; };", top_level_opts) self.assertFalse(value.GetError().Success()) self.assertIn( - "error: :1:8: redefinition of 'Redef'\nstruct Redef { float y; };\n ^\n:1:8: previous definition is here\nstruct Redef { double x; };\n ^", + """ +error: :1:8: redefinition of 'Redef' + 1 | struct Redef { float y; }; + | ^ +:1:8: previous definition is here + 1 | struct Redef { double x; }; + | ^ +""", value.GetError().GetCString(), )