r336716 - Revert r336590 "[libclang] evalute compound statement cursors before trying to evaluate"

Alex L via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 8 15:24:54 PST 2019


Looks like there was another leak I missed. I'm working on fixing it now.
Cheers,
Alex

On Tue, 8 Jan 2019 at 14:38, Alex L <arphaman at gmail.com> wrote:

> Thanks for reverting the commit! Unfortunately I missed the failure back
> then.
> I fixed the leak and recommitted the change in r350666.
>
> Cheers,
> Alex
>
> On Tue, 10 Jul 2018 at 12:53, Evgeniy Stepanov via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: eugenis
>> Date: Tue Jul 10 12:49:07 2018
>> New Revision: 336716
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=336716&view=rev
>> Log:
>> Revert r336590 "[libclang] evalute compound statement cursors before
>> trying to evaluate"
>>
>> New memory leaks in
>> LibclangParseTest_EvaluateChildExpression_Test::TestBody()
>>
>> Modified:
>>     cfe/trunk/tools/libclang/CIndex.cpp
>>     cfe/trunk/unittests/libclang/LibclangTest.cpp
>>
>> Modified: cfe/trunk/tools/libclang/CIndex.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=336716&r1=336715&r2=336716&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
>> +++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 10 12:49:07 2018
>> @@ -3890,19 +3890,6 @@ static const ExprEvalResult* evaluateExp
>>  }
>>
>>  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(CXCur
>>            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;
>>  }
>>
>>
>> Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=336716&r1=336715&r2=336716&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)
>> +++ cfe/trunk/unittests/libclang/LibclangTest.cpp Tue Jul 10 12:49:07 2018
>> @@ -461,47 +461,6 @@ TEST_F(LibclangParseTest, AllSkippedRang
>>    clang_disposeSourceRangeList(Ranges);
>>  }
>>
>> -TEST_F(LibclangParseTest, EvaluateChildExpression) {
>> -  std::string Main = "main.m";
>> -  WriteFile(Main, "#define kFOO @\"foo\"\n"
>> -                  "void foobar(void) {\n"
>> -                  " {kFOO;}\n"
>> -                  "}\n");
>> -  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0,
>> nullptr,
>> -                                       0, TUFlags);
>> -
>> -  CXCursor C = clang_getTranslationUnitCursor(ClangTU);
>> -  clang_visitChildren(
>> -      C,
>> -      [](CXCursor cursor, CXCursor parent,
>> -         CXClientData client_data) -> CXChildVisitResult {
>> -        if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
>> -          int numberedStmt = 0;
>> -          clang_visitChildren(
>> -              cursor,
>> -              [](CXCursor cursor, CXCursor parent,
>> -                 CXClientData client_data) -> CXChildVisitResult {
>> -                int &numberedStmt = *((int *)client_data);
>> -                if (clang_getCursorKind(cursor) ==
>> CXCursor_CompoundStmt) {
>> -                  if (numberedStmt) {
>> -                    CXEvalResult RE = clang_Cursor_Evaluate(cursor);
>> -                    EXPECT_NE(RE, nullptr);
>> -                    EXPECT_EQ(clang_EvalResult_getKind(RE),
>> -                              CXEval_ObjCStrLiteral);
>> -                    return CXChildVisit_Break;
>> -                  }
>> -                  numberedStmt++;
>> -                }
>> -                return CXChildVisit_Recurse;
>> -              },
>> -              &numberedStmt);
>> -          EXPECT_EQ(numberedStmt, 1);
>> -        }
>> -        return CXChildVisit_Continue;
>> -      },
>> -      nullptr);
>> -}
>> -
>>  class LibclangReparseTest : public LibclangParseTest {
>>  public:
>>    void DisplayDiagnostics() {
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190108/40fdb92f/attachment.html>


More information about the cfe-commits mailing list