Skip to content

clang-format deletes whitespace inside of a noexcept specifier #44543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
llvmbot opened this issue Mar 13, 2020 · 6 comments
Closed

clang-format deletes whitespace inside of a noexcept specifier #44543

llvmbot opened this issue Mar 13, 2020 · 6 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla clang-format confirmed Verified by a second party

Comments

@llvmbot
Copy link
Member

llvmbot commented Mar 13, 2020

Bugzilla Link 45198
Version unspecified
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @mydeveloperday

Extended Description

The following:

    template<
        typename T,
        enable_if_t<is_move_assignable<T>::value> = true,
        enable_if_t<is_move_constructible<T>::value> = true>
    constexpr void
    swap(T &lhs, T &rhs) noexcept(
        is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value)

Results in this:

    template<
        typename T,
        enable_if_t<is_move_assignable<T>::value> = true,
        enable_if_t<is_move_constructible<T>::value> = true>
    constexpr void
    swap(T &lhs, T &rhs) noexcept(
        is_nothrow_move_constructible<T>::value &&is_nothrow_move_assignable<T>::value)

With this:

AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType
AlwaysBreakAfterReturnType: AllDefinitions
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
    AfterClass: true
    AfterControlStatement: false
    AfterEnum: true
    AfterFunction: true
    AfterNamespace: true
    # AfterObjCDeclaration
    AfterStruct: true
    AfterUnion: true
    AfterExternBlock: true
    BeforeCatch: true
    BeforeElse: true
    IndentBraces: false
    SplitEmptyFunction: false
    SplitEmptyRecord: false
    SplitEmptyNamespace: false
# BreakAfterJavaFieldAnnotations
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 100
# CommentPragmas
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
# DisableFormat
# ExperimentalAutoDetectBinPacking
FixNamespaceComments: false
# ForEachMacros
# IncludeBlocks
# IncludeCategories
# IncludeIsMainRegex
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
# JavaImportGroups
# JavaScriptQuotes
# JavaScriptWrapImports
KeepEmptyLinesAtTheStartOfBlocks: true
Language: Cpp
# MacroBlockBegin
# MacroBlockEnd
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
# ObjCBinPackProtocolList
# ObjCBlockIndentWidth
# ObjCSpaceAfterProperty
# ObjCSpaceBeforeProtocolList
# PenaltyBreakAssignment
# PenaltyBreakBeforeFirstCallParameter
# PenaltyBreakComment
# PenaltyBreakFirstLessLess
# PenaltyBreakString
# PenaltyBreakTemplateDeclaration
# PenaltyExcessCharacter
# PenaltyReturnTypeOnItsOwnLine
PointerAlignment: Right
# RawStringFormats
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 4
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
# StatementMacros
# TabWidth
UseTab: Never
@mydeveloperday
Copy link
Contributor

The && is seen as a TT_PointerOrReference

M=0 C=0 T=TemplateCloser S=0 B=0 BK=0 P=290 Name=greater L=277 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='>'
M=0 C=0 T=Unknown S=0 B=0 BK=0 P=50 Name=coloncolon L=279 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='::'
M=0 C=1 T=Unknown S=0 B=0 BK=0 P=540 Name=identifier L=284 PPK=2 FakeLParens= FakeRParens=0 II=0x27c0b171258 Text='value'
M=0 C=1 T=PointerOrReference S=1 B=0 BK=0 P=230 Name=ampamp L=287 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='&&'
M=0 C=1 T=StartOfName S=0 B=0 BK=0 P=240 Name=identifier L=313 PPK=2 FakeLParens= FakeRParens=0 II=0x27c0b1713b8 Text='is_nothrow_move_assignable'
M=0 C=0 T=TemplateOpener S=0 B=0 BK=0 P=50 Name=less L=314 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='<'
M=0 C=1 T=Unknown S=0 B=0 BK=0 P=380 Name=identifier L=315 PPK=2 FakeLParens= FakeRParens=0 II=0x27c0b1711b0 Text='T'

and not as a TT_BinaryOperator

@mydeveloperday
Copy link
Contributor

mydeveloperday commented May 15, 2020

This break on even a simple style

---
Language: Cpp
BasedOnStyle: LLVM
template <typename T, enable_if_t<is_move_assignable<T>::value> = true,
          enable_if_t<is_move_constructible<T>::value> = true>
constexpr void swap(T &lhs,
                    T &rhs) noexcept(is_nothrow_move_constructible<T>::value
                                         &&is_nothrow_move_assignable<T>::value)

@mydeveloperday
Copy link
Contributor

mydeveloperday commented May 15, 2020

and pretty sure its still wrong here

template <typename T> void swap() noexcept(Bar<T> && Foo<T>)

to

template <typename T> void swap() noexcept(Bar<T> &&Foo<T>)

@mydeveloperday
Copy link
Contributor

possible fix https://reviews.llvm.org/D80041

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
@cjdb
Copy link
Contributor

cjdb commented Oct 6, 2022

This also happens in explicit-specifiers, but not inside parenthesised expressions inside either specifier.

@rymiel
Copy link
Member

rymiel commented Mar 17, 2023

Patch: https://reviews.llvm.org/D146284

@rymiel rymiel added the awaiting-review Has pending Phabricator review label Mar 17, 2023
@rymiel rymiel self-assigned this Mar 17, 2023
@rymiel rymiel closed this as completed in ead9644 Mar 22, 2023
@github-actions github-actions bot removed the awaiting-review Has pending Phabricator review label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-format confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

4 participants