================
@@ -74,8 +74,12 @@ Parser::Parser(Preprocessor &pp, Sema &actions, bool 
skipFunctionBodies)
   // destructor.
   initializePragmaHandlers();
 
-  CommentSemaHandler.reset(new ActionCommentHandler(actions));
-  PP.addCommentHandler(CommentSemaHandler.get());
+  // Only install the comment handler when some consumer may read documentation
+  // comments back.
+  if (actions.shouldRetainCommentsFromLexer(SourceLocation())) {
----------------
snprajwal wrote:

I don't think the lexer would've run at this stage. If `-Wdocumentation` is not 
passed via the command line, the handler is not installed even if the check may 
be present through pragmas. We can omit this and unconditionally install the 
handler here, since we also perform a per-comment check in 
[`Sema::ActOnComment`](https://github.com/AnonMiraj/llvm-project/blob/b8f65be707737d731896d5ca7f34e73a8df55406/clang/lib/Sema/Sema.cpp#L2737-L2738)

https://github.com/llvm/llvm-project/pull/206363
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to