Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

createNestedNameSpecifierForScopeOf does not work for Dependent name types #39610

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR40639
Status NEW
Importance P normal
Reported by Max Sagebaum (max.sagebaum@scicomp.uni-kl.de)
Reported on 2019-02-07 00:35:46 -0800
Last modified on 2021-03-30 09:25:28 -0700
Version unspecified
Hardware PC Linux
CC klimek@google.com
Fixed by commit(s)
Attachments fullNameBug.tar (71680 bytes, application/x-tar)
Blocks
Blocked by
See also
Created attachment 21441
Tooling implementation that shows the bug, with patch compile script and
example.

A function call to getFullyQualifiedType with a dependent name type is not
resolved correctly.

For the definition of:
namespace name {
  template<typename T>
  struct AB {
    struct Test {
      using Type = T;
    };
    AB() {}

    void func(Test a, typename Test::Type b) {}
  };
}

The arguments of func are resolved to:
Parameter: a
  Full qual type: name::AB<T>::Test
Parameter: b
  Full qual type: typename Test::Type

I tried to find the error and could get a partial patch:
--- a/QualTypeNames.cpp 2019-02-06 14:50:37.169581290 +0100
+++ b/QualTypeNames.cpp 2019-02-06 14:53:08.114611002 +0100
@@ -326,6 +326,8 @@
     Decl = TagDeclType->getDecl();
   } else if (const auto *TST = dyn_cast<TemplateSpecializationType>(TypePtr)) {
     Decl = TST->getTemplateName().getAsTemplateDecl();
+  } else if (const auto *DNT = dyn_cast<DependentNameType>(TypePtr)) {
+    Decl = DNT->getQualifier()->getAsRecordDecl();
   } else {
     Decl = TypePtr->getAsCXXRecordDecl();
   }

With this Patch the result is now:
Parameter: a
  Full qual type: name::AB<T>::Test
Parameter: b
  Full qual type: name::AB<T>::typename Test::Type

I could not get how to convert the DependentNameType to a regular type.

The expected result would be:
Parameter: a
  Full qual type: name::AB<T>::Test
Parameter: b
  Full qual type: typename name::AB<T>::Test::Type

Find attached the compile script, the example file, the patch and the tooling
implementation which shows the bug.
Quuxplusone commented 5 years ago

Attached fullNameBug.tar (71680 bytes, application/x-tar): Tooling implementation that shows the bug, with patch compile script and example.

Quuxplusone commented 3 years ago

ping