[PATCH] D36083: [utils] Add a script that runs clang in LLDB and stops it when a specified diagnostic is emitted

don hinton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 1 09:55:43 PDT 2017


hintonda added a comment.

This is a good example of how to script lldb, but it's predicated on knowing the diag name, which is great if you know the name.

However, this isn't my use case.  I don't have the diag name, just a diagnostic message.  In order to get the diag name associated with a specific diagnostic message, I have to grep the source, which was the original motivation behind https://reviews.llvm.org/D35175.

Here's how I currently do it:

1. select a partial substring from the diagnostic (omitting variable/class names and anything that might be part of a %select{}, e.g., (public|private|protected), etc...)
2. use grep to match a diagnostic definition in one of the diagnostic inc files generated by tblgen, i.e., tools/clang/include/clang/Basic/Diagnostic*.inc
3. if one or more matches found, select the correct one(s), otherwise, adjust substring and go back to 2
4. pass diag name(s) found in 3 to this tool

However, once the diag name is known, it would be just as easy to find/grep the source to find the file/line numbers and where the diag name is seen.  Then you could either look directly at the source, or use them to set breakpoints in lldb.  This avoids issues concerning late calls to report and PartialDiagnostic locations.

Alternatively, one could do what John suggested (paraphrasing here) and munge the strings found in tools/clang/include/clang/Basic/Diagnostic*.inc to create regular expressions and use flex to generate a lexer, or write one by hand, that could find a specific diag name that matched the diagnostic message.  (obviously there are a lot of ways to do this)


Repository:
  rL LLVM

https://reviews.llvm.org/D36083





More information about the cfe-commits mailing list