[PATCH] D53347: [clangd] Simplify auto hover

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 16 23:45:24 PDT 2018


hokein accepted this revision.
hokein added a comment.

looks good! didn't know this API before.



================
Comment at: clangd/XRefs.cpp:592
 
-    auto DeclT = UnwrapReferenceOrPointer(D->getType());
-    const AutoType *AT = dyn_cast<AutoType>(DeclT.getTypePtr());
-    if (AT && !AT->getDeducedType().isNull()) {
-      // For auto, use the underlying type because the const& would be
-      // represented twice: written in the code and in the hover.
-      // Example: "const auto I = 1", we only want "int" when hovering on auto,
-      // not "const int".
-      //
-      // For decltype(auto), take the type as is because it cannot be written
-      // with qualifiers or references but its decuded type can be const-ref.
-      DeducedType = AT->isDecltypeAuto() ? DeclT : DeclT.getUnqualifiedType();
-    }
+    auto AT = D->getType()->getContainedAutoType();
+    if (AT && !AT->getDeducedType().isNull())
----------------
Maybe just 

```
if (auto* DT = D->getType()->getContainedDeducedType())
   DeducedType = *DT;
```

? 


================
Comment at: clangd/XRefs.cpp:620
+      DeducedType = AT->getDeducedType();
     } else { // auto in a trailing return type just points to a DecltypeType.
+      const DecltypeType *DT = dyn_cast<DecltypeType>(D->getReturnType());
----------------
also expand this comment mentioning that `decltype` is not handled by the `getContainedAutoType` or `getContainedDeducedType`?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53347





More information about the cfe-commits mailing list