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/
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))
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to