[PATCH] D158985: [AST] Fix crash in evaluation of OpaqueExpr in Clangd
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 28 08:11:47 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd703dcdfb08d: [AST] Fix crash in evaluation of OpaqueExpr in Clangd (authored by ilya-biryukov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158985/new/
https://reviews.llvm.org/D158985
Files:
clang-tools-extra/clangd/unittests/HoverTests.cpp
clang/lib/AST/ExprConstant.cpp
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -7653,7 +7653,8 @@
}
bool VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
- if (APValue *Value = Info.CurrentCall->getCurrentTemporary(E))
+ if (APValue *Value = Info.CurrentCall->getCurrentTemporary(E);
+ Value && !Value->isAbsent())
return DerivedSuccess(*Value, E);
const Expr *Source = E->getSourceExpr();
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2967,6 +2967,32 @@
HI.NamespaceScope = "";
HI.Value = "0";
}},
+ // Should not crash.
+ {R"objc(
+ typedef struct MyRect {} MyRect;
+
+ @interface IFace
+ @property(nonatomic) MyRect frame;
+ @end
+
+ MyRect foobar() {
+ MyRect mr;
+ return mr;
+ }
+ void test() {
+ IFace *v;
+ v.frame = [[foo^bar]]();
+ }
+ )objc",
+ [](HoverInfo &HI) {
+ HI.Name = "foobar";
+ HI.Kind = index::SymbolKind::Function;
+ HI.NamespaceScope = "";
+ HI.Definition = "MyRect foobar()";
+ HI.Type = {"MyRect ()", "MyRect ()"};
+ HI.ReturnType = {"MyRect", "MyRect"};
+ HI.Parameters.emplace();
+ }},
{R"cpp(
void foo(int * __attribute__(([[non^null]], noescape)) );
)cpp",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158985.553947.patch
Type: text/x-patch
Size: 1646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230828/48507445/attachment.bin>
More information about the cfe-commits
mailing list