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",
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",
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits