[llvm-bugs] [Bug 39248] New: clang-format mishandles macroized "if constexpr"
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 10 18:34:42 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39248
Bug ID: 39248
Summary: clang-format mishandles macroized "if constexpr"
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: sfinae at hotmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
MSVC's STL partially macroizes "if constexpr" to work with compilers in pure
C++14 mode. clang-format handles this poorly:
C:\Temp>type bug.cpp
#include <stdio.h>
#include <type_traits>
#define CONSTEXPR_IF constexpr
template <typename T> void meow(T) {
if CONSTEXPR_IF (std::is_integral_v<T>) {
puts("integral");
} else {
puts("other");
}
}
int main() {
meow(1729);
meow(3.14);
}
C:\Temp>clang-format -style=LLVM bug.cpp
#include <stdio.h>
#include <type_traits>
#define CONSTEXPR_IF constexpr
template <typename T> void meow(T) {
if
CONSTEXPR_IF(std::is_integral_v<T>) { puts("integral"); }
else {
puts("other");
}
}
int main() {
meow(1729);
meow(3.14);
}
I believe it would be better if clang-format treated unrecognized identifiers
immediately after "if" the same way that it treats "if constexpr".
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181011/7b798c2b/attachment-0001.html>
More information about the llvm-bugs
mailing list