<div dir="ltr"><div dir="ltr">Fixed in r350680.</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 8 Jan 2019 at 15:24, Alex L <<a href="mailto:arphaman@gmail.com">arphaman@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Looks like there was another leak I missed. I'm working on fixing it now.<div>Cheers,</div><div>Alex</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 8 Jan 2019 at 14:38, Alex L <<a href="mailto:arphaman@gmail.com" target="_blank">arphaman@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Thanks for reverting the commit! Unfortunately I missed the failure back then.<div>I fixed the leak and recommitted the change in r350666.</div><div><br></div><div>Cheers,</div><div>Alex</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 10 Jul 2018 at 12:53, Evgeniy Stepanov via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Author: eugenis<br>
Date: Tue Jul 10 12:49:07 2018<br>
New Revision: 336716<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=336716&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=336716&view=rev</a><br>
Log:<br>
Revert r336590 "[libclang] evalute compound statement cursors before trying to evaluate"<br>
<br>
New memory leaks in<br>
LibclangParseTest_EvaluateChildExpression_Test::TestBody()<br>
<br>
Modified:<br>
cfe/trunk/tools/libclang/CIndex.cpp<br>
cfe/trunk/unittests/libclang/LibclangTest.cpp<br>
<br>
Modified: cfe/trunk/tools/libclang/CIndex.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=336716&r1=336715&r2=336716&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=336716&r1=336715&r2=336716&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/tools/libclang/CIndex.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 10 12:49:07 2018<br>
@@ -3890,19 +3890,6 @@ static const ExprEvalResult* evaluateExp<br>
}<br>
<br>
CXEvalResult clang_Cursor_Evaluate(CXCursor C) {<br>
- if (clang_getCursorKind(C) == CXCursor_CompoundStmt) {<br>
- const CompoundStmt *compoundStmt = cast<CompoundStmt>(getCursorStmt(C));<br>
- Expr *expr = nullptr;<br>
- for (auto *bodyIterator : compoundStmt->body()) {<br>
- if ((expr = dyn_cast<Expr>(bodyIterator))) {<br>
- break;<br>
- }<br>
- }<br>
- if (expr)<br>
- return const_cast<CXEvalResult>(<br>
- reinterpret_cast<const void *>(evaluateExpr(expr, C)));<br>
- }<br>
-<br>
const Decl *D = getCursorDecl(C);<br>
if (D) {<br>
const Expr *expr = nullptr;<br>
@@ -3916,6 +3903,19 @@ CXEvalResult clang_Cursor_Evaluate(CXCur<br>
evaluateExpr(const_cast<Expr *>(expr), C)));<br>
return nullptr;<br>
}<br>
+<br>
+ const CompoundStmt *compoundStmt = dyn_cast_or_null<CompoundStmt>(getCursorStmt(C));<br>
+ if (compoundStmt) {<br>
+ Expr *expr = nullptr;<br>
+ for (auto *bodyIterator : compoundStmt->body()) {<br>
+ if ((expr = dyn_cast<Expr>(bodyIterator))) {<br>
+ break;<br>
+ }<br>
+ }<br>
+ if (expr)<br>
+ return const_cast<CXEvalResult>(<br>
+ reinterpret_cast<const void *>(evaluateExpr(expr, C)));<br>
+ }<br>
return nullptr;<br>
}<br>
<br>
<br>
Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=336716&r1=336715&r2=336716&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=336716&r1=336715&r2=336716&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)<br>
+++ cfe/trunk/unittests/libclang/LibclangTest.cpp Tue Jul 10 12:49:07 2018<br>
@@ -461,47 +461,6 @@ TEST_F(LibclangParseTest, AllSkippedRang<br>
clang_disposeSourceRangeList(Ranges);<br>
}<br>
<br>
-TEST_F(LibclangParseTest, EvaluateChildExpression) {<br>
- std::string Main = "main.m";<br>
- WriteFile(Main, "#define kFOO @\"foo\"\n"<br>
- "void foobar(void) {\n"<br>
- " {kFOO;}\n"<br>
- "}\n");<br>
- ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,<br>
- 0, TUFlags);<br>
-<br>
- CXCursor C = clang_getTranslationUnitCursor(ClangTU);<br>
- clang_visitChildren(<br>
- C,<br>
- [](CXCursor cursor, CXCursor parent,<br>
- CXClientData client_data) -> CXChildVisitResult {<br>
- if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {<br>
- int numberedStmt = 0;<br>
- clang_visitChildren(<br>
- cursor,<br>
- [](CXCursor cursor, CXCursor parent,<br>
- CXClientData client_data) -> CXChildVisitResult {<br>
- int &numberedStmt = *((int *)client_data);<br>
- if (clang_getCursorKind(cursor) == CXCursor_CompoundStmt) {<br>
- if (numberedStmt) {<br>
- CXEvalResult RE = clang_Cursor_Evaluate(cursor);<br>
- EXPECT_NE(RE, nullptr);<br>
- EXPECT_EQ(clang_EvalResult_getKind(RE),<br>
- CXEval_ObjCStrLiteral);<br>
- return CXChildVisit_Break;<br>
- }<br>
- numberedStmt++;<br>
- }<br>
- return CXChildVisit_Recurse;<br>
- },<br>
- &numberedStmt);<br>
- EXPECT_EQ(numberedStmt, 1);<br>
- }<br>
- return CXChildVisit_Continue;<br>
- },<br>
- nullptr);<br>
-}<br>
-<br>
class LibclangReparseTest : public LibclangParseTest {<br>
public:<br>
void DisplayDiagnostics() {<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>