[PATCH] D54553: [clangd] Fix crash hovering on non-decltype trailing return
Marc-Andre Laperle via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 14 15:56:14 PST 2018
malaperle updated this revision to Diff 174117.
malaperle added a comment.
Fix comment in test
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D54553
Files:
clangd/XRefs.cpp
unittests/clangd/XRefsTests.cpp
Index: unittests/clangd/XRefsTests.cpp
===================================================================
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -835,6 +835,14 @@
)cpp",
"",
},
+ {
+ R"cpp(// simple trailing return type
+ ^auto main() -> int {
+ return 0;
+ }
+ )cpp",
+ "int",
+ },
{
R"cpp(// auto function return with trailing type
struct Bar {};
Index: clangd/XRefs.cpp
===================================================================
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -605,6 +605,7 @@
// Handle auto return types:
//- auto foo() {}
//- auto& foo() {}
+ //- auto foo() -> int {}
//- auto foo() -> decltype(1+1) {}
//- operator auto() const { return 10; }
bool VisitFunctionDecl(FunctionDecl *D) {
@@ -624,12 +625,13 @@
const AutoType *AT = D->getReturnType()->getContainedAutoType();
if (AT && !AT->getDeducedType().isNull()) {
DeducedType = AT->getDeducedType();
- } else {
+ } else if (const DecltypeType *DT = dyn_cast<DecltypeType>(D->getReturnType())) {
// auto in a trailing return type just points to a DecltypeType and
// getContainedAutoType does not unwrap it.
- const DecltypeType *DT = dyn_cast<DecltypeType>(D->getReturnType());
if (!DT->getUnderlyingType().isNull())
DeducedType = DT->getUnderlyingType();
+ } else if (!D->getReturnType().isNull()) {
+ DeducedType = D->getReturnType();
}
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54553.174117.patch
Type: text/x-patch
Size: 1602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181114/3544e2b6/attachment-0001.bin>
More information about the cfe-commits
mailing list