diff options
author | Raphael Isemann <teemperor@gmail.com> | 2020-09-22 11:16:37 +0200 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-09-22 13:37:20 +0200 |
commit | b5e49e91cb90eda1f926139c8567e27f1b664cc1 (patch) | |
tree | d595ad799edda1c8fa65687ed794ff23248278e1 /lldb/source/Plugins/TypeSystem | |
parent | a15b42146c617777b364e3b63babf1de547b9f26 (diff) | |
download | llvm-b5e49e91cb90eda1f926139c8567e27f1b664cc1.zip llvm-b5e49e91cb90eda1f926139c8567e27f1b664cc1.tar.gz llvm-b5e49e91cb90eda1f926139c8567e27f1b664cc1.tar.bz2 |
[lldb] Ignore certain Clang type sugar when creating the type name
Clang has some type sugar that only serves as a way to preserve the way a user
has typed a certain type in the source code. These types are currently not
unwrapped when we query the type name for a Clang type, which means that this
type sugar actually influences what formatters are picked for a certain type.
Currently if a user decides to reference a type by doing `::GlobalDecl Var = 3;`,
the type formatter for `GlobalDecl` will not be used (as the type sugar
around the type gives it the name `::GlobalDecl`. The same goes for other ways
to spell out a type such as `auto` etc.
With this patch most of this type sugar gets stripped when the full type name is
calculated. Typedefs are not getting desugared as that seems counterproductive.
I also don't desugar atomic types as that's technically not type sugar.
Reviewed By: jarin
Differential Revision: https://reviews.llvm.org/D87481
Diffstat (limited to 'lldb/source/Plugins/TypeSystem')
-rw-r--r-- | lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index d80d075..ee6fc895 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -3639,6 +3639,16 @@ ConstString TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type) { clang::QualType qual_type(GetQualType(type)); + // Remove certain type sugar from the name. Sugar such as elaborated types + // or template types which only serve to improve diagnostics shouldn't + // act as their own types from the user's perspective (e.g., formatter + // shouldn't format a variable differently depending on how the ser has + // specified the type. '::Type' and 'Type' should behave the same). + // Typedefs and atomic derived types are not removed as they are actually + // useful for identifiying specific types. + qual_type = RemoveWrappingTypes(qual_type, + {clang::Type::Typedef, clang::Type::Atomic}); + // For a typedef just return the qualified name. if (const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) { const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl(); |