[Lldb-commits] [PATCH] Correctly detect sign-ness of wchar_t

Tamas Berghammer tberghammer at google.com
Tue Mar 31 08:27:14 PDT 2015


Hi clayborg,

Correctly detect sign-ness of wchar_t

The underlying type of wchar_t is not defined by the standard. This CL
add logic to correctly use the type specified for the current target
based on TargetInfo.

http://reviews.llvm.org/D8722

Files:
  source/Symbol/ClangASTContext.cpp

Index: source/Symbol/ClangASTContext.cpp
===================================================================
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -904,7 +904,8 @@
                 if (type_name)
                 {
                     if (streq(type_name, "wchar_t") &&
-                        QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
+                        QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy) &&
+                        TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))
                         return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
                     if (streq(type_name, "void") &&
                         QualTypeMatchesBitSize (bit_size, ast, ast->VoidTy))
@@ -961,6 +962,14 @@
             case DW_ATE_unsigned:
                 if (type_name)
                 {
+                    if (streq(type_name, "wchar_t"))
+                    {
+                        if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
+                        {
+                            if (!TargetInfo::isTypeSigned (getTargetInfo()->getWCharType()))
+                                return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
+                        }
+                    }
                     if (strstr(type_name, "long long"))
                     {
                         if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8722.22962.patch
Type: text/x-patch
Size: 1474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150331/8ad7f4bc/attachment.bin>


More information about the lldb-commits mailing list