================
@@ -2703,11 +2705,37 @@ LambdaScopeInfo *Sema::getCurGenericLambda() {
return nullptr;
}
+bool Sema::shouldRetainCommentsFromLexer(SourceLocation Loc) const {
+ if (LangOpts.CommentOpts.ParseAllComments)
+ return true;
+
+ if (LangOpts.CommentOpts.RetainComments)
+ return true;
+
+ // When building a PCH the comments are serialized into the AST file
+ // so downstream consumers like clangd) can retrieve documentation, and the
+ // incremental/REPL front end may query them interactively.
+ if (TUKind != TU_Complete)
+ return true;
+
+ if (PP.isCodeCompletionEnabled())
+ return true;
+
+ // Keep the comment if -Wdocumentation is enabled at its location (checking
+ // the location handles warnings turned on by `#pragma clang diagnostic`).
+ if (!Diags.isIgnored(diag::warn_doc_param_not_found, Loc) ||
----------------
AaronBallman wrote:
This is somewhat fragile. `warn_doc_param_not_found` is enabled whenever
`-Wdocumentation` is enabled and `warn_unknown_comment_command_name` is enabled
whenever `-Wdocumentation-unknown-command` is enabled.
But what about `-Wdocumentation-pedantic`, `-Wdocumentation-html`, and
`-Wdocumentation-deprecated-sync`?
https://github.com/llvm/llvm-project/pull/206363
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits