[PATCH] D126908: [VerifyDiagnosticConsumer] Fix last line being discarded when parsing newline

Vang Thao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 17 19:24:08 PDT 2022


vangthao added inline comments.


================
Comment at: clang/test/SemaCXX/references.cpp:93
 
-struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due to ambiguity:\n    struct C -> struct B -> struct A\nstruct C -> struct A}}
+struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due to ambiguity:\n    struct C -> struct B -> struct A\n    struct C -> struct A}}
 
----------------
jkorous wrote:
> Can you please explain in detail what bug are you fixing?
> In my understanding if we stop parsing after the last newline then the existing test would have failed. The difference seems to be only the white-space.
> Am I missing something?
>In my understanding if we stop parsing after the last newline then the existing test would have failed.
The reason it does not fail is because we do not perform an exact match. We only do a partial match since `contains()` is used here when matching https://github.com/llvm/llvm-project/blob/main/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp#L102.

We parsed the following from the expected-warning check:
  direct base 'A' is inaccessible due to ambiguity:
      struct C -> B -> A

and the actual output from clang is:
  direct base 'A' is inaccessible due to ambiguity:
      struct C -> B -> A
      struct C -> A

The output from clang does contain the expected warning that we parsed but not all of it since we discarded the last line of `\nstruct C -> struct A` from the check. You can verify that by adding anything on this line. It will not fail the test because we are not checking for it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126908/new/

https://reviews.llvm.org/D126908



More information about the cfe-commits mailing list