[cfe-dev] Uncompilable integer suffixes in StmtPrinter

Andrey Tarasevich via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 4 02:58:49 PST 2015


Hi all,

I’m wondering what is a motivation for changes in this commit http://reviews.llvm.org/rL211426 <http://reviews.llvm.org/rL211426> for StmtPrinter.cpp, since this bug report https://llvm.org/bugs/show_bug.cgi?id=20008 <https://llvm.org/bugs/show_bug.cgi?id=20008> doesn’t provide much of a help, besides starting, that this is needed by MSVC, but doesn’t say why these suffixes are generated for all targets and not only for MSVC

--- cfe/trunk/lib/AST/StmtPrinter.cpp	2014/06/21 12:39:25	211434
+++ cfe/trunk/lib/AST/StmtPrinter.cpp	2014/06/21 18:46:07	211441
@@ -944,11 +944,10 @@
   // Emit suffixes.  Integer literals are always a builtin integer type.
   switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
   default: llvm_unreachable("Unexpected type for integer literal!");
-  // FIXME: The Short and UShort cases are to handle cases where a short
-  // integeral literal is formed during template instantiation.  They should
-  // be removed when template instantiation no longer needs integer literals.
-  case BuiltinType::Short:
-  case BuiltinType::UShort:
+  case BuiltinType::SChar:     OS << "i8"; break;
+  case BuiltinType::UChar:     OS << "Ui8"; break;
+  case BuiltinType::Short:     OS << "i16"; break;
+  case BuiltinType::UShort:    OS << "Ui16"; break;
   case BuiltinType::Int:       break; // no suffix.
   case BuiltinType::UInt:      OS << 'U'; break;
   case BuiltinType::Long:      OS << 'L'; break;

Adding these suffixes breaks compilation of the code, which was generated via PrettyPrinting AST. I’m aware, that printing AST back to C code doesn’t guarantee, that code will be compilable, but changing Clang source code each time I need a fresh checkout of LLVM and Clang bugs me. 

Besides I can’t find anywhere definition of suffixes i8, Ui8, i16, Ui16, i128 and Ui128. Only i64 is defined, as pointed out in the bug report.

Thanks,
Andrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151104/3b8fb523/attachment.html>


More information about the cfe-dev mailing list