Skip to content

Commit

Permalink
[PDB] Handle char as a builtin type
Browse files Browse the repository at this point in the history
Summary:
`char`, `signed char` and `unsigned char` are three different types,
and they are mangled differently:

```
void __declspec(dllexport) /* ?foo@@Yaxd@Z */ foo(char c) { }
void __declspec(dllexport) /* ?foo@@YaXe@Z */ foo(unsigned char c) { }
void __declspec(dllexport) /* ?foo@@yaxc@Z */ foo(signed char c) { }
```

This commit separates `char` from `signed char` and `unsigned char`.

Reviewers: asmith, zturner, labath

Reviewed By: asmith, zturner

Subscribers: teemperor, lldb-commits, stella.stamenova

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D52468

llvm-svn: 343298
  • Loading branch information
Aleksandr Urakov committed Sep 28, 2018
1 parent 69bfa40 commit ec97b52
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lldb/lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
Expand Up @@ -35,6 +35,9 @@ EnumClass EnumClassVar;
enum struct EnumStruct { red, blue, black };
EnumStruct EnumStructVar;

typedef signed char SCharTypedef;
SCharTypedef SCVar;

typedef char16_t WChar16Typedef;
WChar16Typedef WC16Var;

Expand Down
2 changes: 1 addition & 1 deletion lldb/lit/SymbolFile/PDB/ast-restore.test
Expand Up @@ -58,7 +58,7 @@ INNER: namespace N0 {
INNER: namespace N1 {
INNER: class Class : public N0::N1::Base {
INNER: struct Inner {
INNER: signed char x;
INNER: char x;
INNER: short y;
INNER: int z;
INNER: };
Expand Down
2 changes: 1 addition & 1 deletion lldb/lit/SymbolFile/PDB/func-symbols.test
Expand Up @@ -14,7 +14,7 @@ CHECK-ONE-DAG: [[TY0:.*]]: Type{[[UID0:.*]]} , name = "Func_arg_array", decl =
CHECK-ONE-DAG: [[TY1:.*]]: Type{[[UID1:.*]]} , name = "Func_arg_void", decl = FuncSymbolsTestMain.cpp:4, compiler_type = {{.*}} void (void)
CHECK-ONE-DAG: [[TY2:.*]]: Type{[[UID2:.*]]} , name = "Func_arg_none", decl = FuncSymbolsTestMain.cpp:5, compiler_type = {{.*}} void (void)
CHECK-ONE-DAG: [[TY3:.*]]: Type{[[UID3:.*]]} , name = "Func_varargs", decl = FuncSymbolsTestMain.cpp:6, compiler_type = {{.*}} void (...)
CHECK-ONE-DAG: [[TY4:.*]]: Type{[[UID4:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (signed char, int)
CHECK-ONE-DAG: [[TY4:.*]]: Type{[[UID4:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (char, int)
CHECK-ONE-DAG: [[TY5:.*]]: Type{[[UID5:.*]]} , name = "main", decl = FuncSymbolsTestMain.cpp:44, compiler_type = {{.*}} int (void)
CHECK-ONE-DAG: [[TY6:.*]]: Type{[[UID6:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:24, compiler_type = {{.*}} void (int, const long, volatile _Bool, ...)
CHECK-ONE-DAG: [[TY7:.*]]: Type{[[UID7:.*]]} , name = "StaticFunction", decl = FuncSymbolsTestMain.cpp:35, compiler_type = {{.*}} long (int)
Expand Down
5 changes: 3 additions & 2 deletions lldb/lit/SymbolFile/PDB/typedefs.test
Expand Up @@ -46,9 +46,10 @@ CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} void *
CHECK-DAG: Type{{.*}} , name = "long", size = 4, compiler_type = {{.*}} long
CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = {{.*}} unsigned short
CHECK-DAG: Type{{.*}} , name = "unsigned int", size = 4, compiler_type = {{.*}} unsigned int
CHECK-DAG: Type{{.*}} , name = "char", size = 1, compiler_type = {{.*}} char
CHECK-DAG: Type{{.*}} , name = "signed char", size = 1, compiler_type = {{.*}} signed char
CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} signed char (void *, long, unsigned short, unsigned int, ...)
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} signed char (*)(void *, long, unsigned short, unsigned int, ...)
CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} char (void *, long, unsigned short, unsigned int, ...)
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} char (*)(void *, long, unsigned short, unsigned int, ...)
CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedef", compiler_type = {{.*}} typedef VarArgsFuncTypedef

CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = {{.*}} float
Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
Expand Up @@ -113,6 +113,8 @@ GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast,
return CompilerType();
case PDB_BuiltinType::Void:
return clang_ast.GetBasicType(eBasicTypeVoid);
case PDB_BuiltinType::Char:
return clang_ast.GetBasicType(eBasicTypeChar);
case PDB_BuiltinType::Bool:
return clang_ast.GetBasicType(eBasicTypeBool);
case PDB_BuiltinType::Long:
Expand Down

0 comments on commit ec97b52

Please sign in to comment.