[clang] [clang-format] Annotate ctors/dtors as CtorDtorDeclName instead (PR #67955)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 3 13:23:40 PDT 2023
================
@@ -3447,9 +3447,13 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
Tok = Tok->Next) {
if (Tok->Previous->EndsCppAttributeGroup)
AfterLastAttribute = Tok;
- if (isFunctionDeclarationName(Style.isCpp(), *Tok, Line, ClosingParen)) {
- LineIsFunctionDeclaration = true;
- Tok->setFinalizedType(TT_FunctionDeclarationName);
+ if (const bool IsCtorOrDtor = Tok->is(TT_CtorDtorDeclName);
+ IsCtorOrDtor ||
+ isFunctionDeclarationName(Style.isCpp(), *Tok, Line, ClosingParen)) {
+ if (!IsCtorOrDtor) {
+ LineIsFunctionDeclaration = true;
----------------
owenca wrote:
The whole point of not annotating ctors/dtors as `FunctionDeclarationName` is to avoid the problems stated in the commit message above. That is, ctors/dtors are treated as non-functions in general. We can add options for (or fix existing behaviors of) ctors/dtors if we want them to be treated like functions wrt spacing, aligning wrapping, etc. in the future.
https://github.com/llvm/llvm-project/pull/67955
More information about the cfe-commits
mailing list