As an explanation for this patch my original mail to cfe-dev:

I'm using libclang to parse header files and generate code from them. I found that clang_getTypeSpelling() usually includes the namespace(s) a type was declared in. However with the exception being typedefs (and same for "using A = B"). Not sure if this is a bug or intended behavior, but it seems at least inconsistent. I also couldn't really find a good workaround for this. I'd have to manually figure out all typedefs (not just pure typedefs, they could also be nested template arguments or whatever) and then their originating namespaces. This is a bit cumbersome and not really straight forward. Getting the canonical type is also not really a solution as I would like to keep the typedefs.

Minimal example:

namespace foo {
class Bar {
};
typedef Bar BarDef;
}

clang_getTypeSpelling on "Bar" (kind "Record") gives: "foo::Bar"
clang_getTypeSpelling on "BarDef" (kind "Typedef") gives: "BarDef" (<== missing "foo::")

Thanks

Michael

On 02/14/2017 05:11 PM, Michael via Phabricator wrote:
redm123 created this revision.

Printing typedefs or type aliases using clang_getTypeSpelling() is missing the 
namespace they are defined in. This is in contrast to other types that always 
yield the full typename including namespaces.


https://reviews.llvm.org/D29944

Files:
  lib/AST/TypePrinter.cpp
  test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
  test/CXX/drs/dr2xx.cpp
  test/CXX/drs/dr5xx.cpp
  test/Index/annotate-nested-name-specifier.cpp
  test/Index/file-refs.cpp
  test/Index/print-type.cpp
  test/Index/recursive-cxx-member-calls.cpp
  test/Layout/ms-x86-basic-layout.cpp
  test/Misc/diag-template-diffing.cpp
  test/SemaCXX/attr-noreturn.cpp
  test/SemaCXX/calling-conv-compat.cpp
  test/SemaCXX/coroutines.cpp
  test/SemaCXX/cxx0x-initializer-aggregates.cpp
  test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp
  test/SemaCXX/enum-scoped.cpp
  test/SemaCXX/nested-name-spec.cpp
  test/SemaCXX/pseudo-destructors.cpp
  test/SemaObjCXX/arc-templates.mm
  test/SemaTemplate/member-access-ambig.cpp
  test/SemaTemplate/typename-specifier.cpp


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to