diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2018-07-10 19:49:07 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2018-07-10 19:49:07 +0000 |
commit | 8430288c2717cbee07d3d5f8398ac127d3227b73 (patch) | |
tree | 3783ac04671287354f4972a0b8edaa9146fcb848 /tools | |
parent | d33a97ceed4c92d978cf4a760b79aa9f6745fb94 (diff) | |
download | clang-8430288c2717cbee07d3d5f8398ac127d3227b73.tar.gz |
Revert r336590 "[libclang] evalute compound statement cursors before trying to evaluate"
New memory leaks in
LibclangParseTest_EvaluateChildExpression_Test::TestBody()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336716 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libclang/CIndex.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index a4698830d9..b61dff3238 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3890,19 +3890,6 @@ static const ExprEvalResult* evaluateExpr(Expr *expr, CXCursor C) { } CXEvalResult clang_Cursor_Evaluate(CXCursor C) { - if (clang_getCursorKind(C) == CXCursor_CompoundStmt) { - const CompoundStmt *compoundStmt = cast<CompoundStmt>(getCursorStmt(C)); - Expr *expr = nullptr; - for (auto *bodyIterator : compoundStmt->body()) { - if ((expr = dyn_cast<Expr>(bodyIterator))) { - break; - } - } - if (expr) - return const_cast<CXEvalResult>( - reinterpret_cast<const void *>(evaluateExpr(expr, C))); - } - const Decl *D = getCursorDecl(C); if (D) { const Expr *expr = nullptr; @@ -3916,6 +3903,19 @@ CXEvalResult clang_Cursor_Evaluate(CXCursor C) { evaluateExpr(const_cast<Expr *>(expr), C))); return nullptr; } + + const CompoundStmt *compoundStmt = dyn_cast_or_null<CompoundStmt>(getCursorStmt(C)); + if (compoundStmt) { + Expr *expr = nullptr; + for (auto *bodyIterator : compoundStmt->body()) { + if ((expr = dyn_cast<Expr>(bodyIterator))) { + break; + } + } + if (expr) + return const_cast<CXEvalResult>( + reinterpret_cast<const void *>(evaluateExpr(expr, C))); + } return nullptr; } |