This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix crash caused by line splicing in doc comment
ClosedPublic

Authored by cor3ntin on Apr 11 2023, 9:55 AM.

Details

Summary

Because the comment parser does not support slices,
we emit a warning for comments that do contain
a splice within their delimiter, and do not add them as
documentation comment.

Fixes #62054

Diff Detail

Event Timeline

cor3ntin created this revision.Apr 11 2023, 9:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 9:55 AM
cor3ntin requested review of this revision.Apr 11 2023, 9:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 9:55 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cor3ntin updated this revision to Diff 512505.Apr 11 2023, 9:59 AM

Add release note

Do we have a test that covers valid doxygen comments? I was looking and I don't see an obvious one.

shafik added inline comments.Apr 11 2023, 11:10 AM
clang/lib/Sema/Sema.cpp
2404

I don't get why we don't have to handle the other RawComment cases here.

Do we have a test that covers valid doxygen comments? I was looking and I don't see an obvious one.

AFAICT, some in CommentTextTest.cpp - not that many though.

clang/lib/Sema/Sema.cpp
2404

Because they can't be isAlmostTrailingComment - which checks whether you forgot an additional * or /

aaron.ballman added inline comments.Apr 11 2023, 12:20 PM
clang/include/clang/AST/RawCommentList.h
122

Just to double-check, we don't have to worry about there being leading whitespace in Text do we?

cor3ntin added inline comments.Apr 11 2023, 12:26 PM
clang/include/clang/AST/RawCommentList.h
122

Afaict, we always have a valid comment, starting with / (and ending with / for a multi line comment). We might not have a comment valid for documentation purposes.

aaron.ballman accepted this revision.Apr 11 2023, 12:36 PM

The changes seem reasonable to me.

clang/include/clang/AST/RawCommentList.h
122

Excellent -- I was poking around and it seemed like we do trim the text before forming the comment object, so yay.

This revision is now accepted and ready to land.Apr 11 2023, 12:36 PM
shafik accepted this revision.Apr 11 2023, 4:09 PM

LGTM

This revision was landed with ongoing or failed builds.Apr 12 2023, 1:08 AM
This revision was automatically updated to reflect the committed changes.