[PATCH] D96760: [clang-format] Suppress diagnostics on second parse

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 17 11:08:00 PST 2021


HazardyKnusperkeks added a comment.

In D96760#2565171 <https://reviews.llvm.org/D96760#2565171>, @njames93 wrote:

> I did have another plan for a different way to go about this, not sure if its really any better though.
> It involved building a vector of the edits the config would apply to its parent. Then after the parent is parsed just applying those edits.
> It results in only 1 pass over the config file however it's a little more involved to get it to work.

But then I need to rewrite the complete parsing process? Because in a normal style I can not parse, because it is not apparent which entries are changed because of the config, or do I oversee something?

In D93844#2536354 <https://reviews.llvm.org/D93844#2536354>, @njames93 wrote:

> As a follow up it may be wise to pass a diag handler to parseConfiguration as when we parse it a second time, we probably want to disregard any warnings (like unknown key) detected as they will have been printed on the first pass.

And this is what you proposed. :)



================
Comment at: clang/include/clang/Format/Format.h:3339
+                   bool AllowUnknownOptions = false,
+                   llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr);
 
----------------
njames93 wrote:
> I know this is sufficient for the purpose of this patch, however it doesn't make sense to accept take the handler parameter without also taking a void* for its context.
Will do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96760



More information about the cfe-commits mailing list