https://bugs.llvm.org/show_bug.cgi?id=48653
Bug ID: 48653
Summary: clang-format IndentPPDirectives shouldn't always
indent pp directives
Product: clang
Version: 11.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
The motivation for having IndentPPDirectives is to be able to take code like:
#if this
#if that
#define other
#endif
#endif
And layer it in a way that's actually readable (space before or after hash
based on user preference):
#if this
# if that
# define other
# endif
#endif
But it doesn't really seem to apply as much to use of preprocessor directives
that aren't all contiguous like that. For instance, we have the following
example (which gets indented as shown):
#ifdef __cpp_deduction_guides
template <typename R, typename... Args>
function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;
# ifdef __cpp_noexcept_function_type
template <typename R, typename... Args>
function_ref(R (*)(Args...) noexcept) -> function_ref<R(Args...)>;
# endif
#endif
This is a weird intermediate layer of formatting. It seems like either nothing
should be indented here (i.e. don't indent preprocessor directives if they
follow code):
#ifdef __cpp_deduction_guides
template <typename R, typename... Args>
function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;
#ifdef __cpp_noexcept_function_type
template <typename R, typename... Args>
function_ref(R (*)(Args...) noexcept) -> function_ref<R(Args...)>;
#endif
#endif
Or everything should be indented (i.e. a preprocessor #if is just as much
indent-worthy as a language if):
#ifdef __cpp_deduction_guides
template <typename R, typename... Args>
function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;
# ifdef __cpp_noexcept_function_type
template <typename R, typename... Args>
function_ref(R (*)(Args...) noexcept) -> function_ref<R(Args...)>;
# endif
#endif
I can't say which is better, but either seems better than status quo
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs