This fixes PR35677: "int128_t or uint128_t as non-type template parameter causes crash when considering invalid constructor".
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/AST/StmtPrinter.cpp | ||
---|---|---|
1177 | i128 and Ui128 are not valid integer literal suffix. The output of StmtPrinter is intended to be valid C++. Unfortunately here I think that your only choice is to print the high and low parts separately. |
clang/lib/AST/StmtPrinter.cpp | ||
---|---|---|
1177 | I'm confused. i8, Ui8, i16, and Ui16 are also not valid C++ suffixes, but just a few lines up we use those. What am I missing here? |
clang/lib/AST/StmtPrinter.cpp | ||
---|---|---|
1177 | The literal suffixes [u]i8, [u]i16, [u]i32, and [u]i64 are an MSVC extension (see NumericLiteralParser::NumericLiteralParser in Lex/LiteralSupport.cpp). This does not explain why they are used even in non-ms compatibility mode However I don't think that MSVC supports 128-bits integers (?), and clang certainly @aaron.ballman Do you know why are these suffixes used outside of ms-compatibility mode? |
clang/lib/AST/StmtPrinter.cpp | ||
---|---|---|
1177 |
Our pretty printing is *supposed* to generate valid code, but we get it wrong fairly often and I don't think we've ever promised (let alone tested) that you can use this output to compile code (and get the same results). I think that's more of a stretch goal. That said, the pretty printer should probably be looking at the language options to decide whether it wants to output those suffixes or not. As for historical context, I think the thread starting here is relevant: http://lists.llvm.org/pipermail/cfe-dev/2012-September/024423.html |
clang/lib/AST/StmtPrinter.cpp | ||
---|---|---|
1177 | So what is the next step for this patch? |
clang/lib/AST/StmtPrinter.cpp | ||
---|---|---|
1177 |
I don't think we should print any suffix for these, similar to how we handle int. There is no 128-bit suffix we support. |
In addition to Aaron's suggestion, can you also change the diff's title to something a little bit more informative. Suggestion: "[clang] Handle 128-bits IntegerLiterals in StmtPrinter", and say in the description that this addresses PR35677.
Do you need me to commit on your behalf? If so, which email address would you like me to use for attribution?
I've committed on your behalf in 4b5baa5b8244778b0e7253cdb98924c3dab611b7, thank you for the patch!
i128 and Ui128 are not valid integer literal suffix. The output of StmtPrinter is intended to be valid C++. Unfortunately here I think that your only choice is to print the high and low parts separately.