@@ -494,12 +494,28 @@ namespace Cpp {
494
494
return GetScope (name.substr (start, end), curr_scope);
495
495
}
496
496
497
+ static CXXRecordDecl *GetScopeFromType (QualType QT) {
498
+ if (auto *Type = QT.getTypePtrOrNull ()) {
499
+ Type = Type->getPointeeOrArrayElementType ();
500
+ Type = Type->getUnqualifiedDesugaredType ();
501
+ return Type->getAsCXXRecordDecl ();
502
+ }
503
+ return 0 ;
504
+ }
505
+
506
+ TCppScope_t GetScopeFromType (TCppType_t type) {
507
+ QualType QT = QualType::getFromOpaquePtr (type);
508
+ return (TCppScope_t)GetScopeFromType (QT);
509
+ }
510
+
497
511
TCppScope_t GetNamed (const std::string &name,
498
512
TCppScope_t parent /* = nullptr*/ )
499
513
{
500
514
clang::DeclContext *Within = 0 ;
501
515
if (parent) {
502
516
auto *D = (clang::Decl *)parent;
517
+ if (auto *TD = dyn_cast<TypedefNameDecl>(D))
518
+ D = GetScopeFromType (TD->getUnderlyingType ());
503
519
Within = llvm::dyn_cast<clang::DeclContext>(D);
504
520
}
505
521
@@ -527,22 +543,6 @@ namespace Cpp {
527
543
ParentDC)->getCanonicalDecl ();
528
544
}
529
545
530
- namespace {
531
- CXXRecordDecl *GetScopeFromType (QualType QT) {
532
- if (auto *Type = QT.getTypePtrOrNull ()) {
533
- Type = Type->getPointeeOrArrayElementType ();
534
- Type = Type->getUnqualifiedDesugaredType ();
535
- return Type->getAsCXXRecordDecl ();
536
- }
537
- return 0 ;
538
- }
539
- } // namespace
540
-
541
- TCppScope_t GetScopeFromType (TCppType_t type) {
542
- QualType QT = QualType::getFromOpaquePtr (type);
543
- return (TCppScope_t)GetScopeFromType (QT);
544
- }
545
-
546
546
TCppIndex_t GetNumBases (TCppScope_t klass)
547
547
{
548
548
auto *D = (Decl *) klass;
0 commit comments