The ASan bot is failing with a LeakSanitizer failure that appears related to one of your libclang changes: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/6282/steps/check-clang%20asan/logs/stdio
Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x52c638 in operator new(unsigned long) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:106 #1 0x7fd236783b89 in make_unique<ExprEvalResult> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/ADT/STLExtras.h:1057:29 #2 0x7fd236783b89 in evaluateExpr /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3755 #3 0x7fd236783b89 in clang_Cursor_Evaluate /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3917 #4 0x54e743 in operator() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:487:39 #5 0x54e743 in LibclangParseTest_EvaluateChildExpression_Test::TestBody()::$_0::operator()(CXCursor, CXCursor, void*) const::'lambda'(CXCursor, CXCursor, void*)::__invoke(CXCursor, CXCursor, void*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:482 #6 0x7fd23677de00 in clang::cxcursor::CursorVisitor::RunVisitorWorkList(llvm::SmallVector<clang::cxcursor::VisitorJob, 10u>&) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3019:17 #7 0x7fd23675c3a8 in clang::cxcursor::CursorVisitor::Visit(clang::Stmt const*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3164:17 #8 0x7fd236755d2f in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp #9 0x7fd236754e5d in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:225:16 #10 0x7fd23676487c in clang::cxcursor::CursorVisitor::VisitFunctionDecl(clang::FunctionDecl*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:889:9 #11 0x7fd236759e24 in clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::cxcursor::CursorVisitor, bool>::Visit(clang::Decl*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/include/clang/AST/DeclVisitor.h #12 0x7fd236755c17 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:506:34 #13 0x7fd23678a558 in clang_visitChildren /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4352:20 #14 0x54e024 in operator() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:480:11 #15 0x54e024 in LibclangParseTest_EvaluateChildExpression_Test::TestBody()::$_0::__invoke(CXCursor, CXCursor, void*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:476 #16 0x7fd236754d49 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:217:11 #17 0x7fd23675cb87 in clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:674:7 #18 0x7fd23675cefe in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:635:30 #19 0x7fd236756399 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:540:20 #20 0x7fd23678a558 in clang_visitChildren /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4352:20 #21 0x537fa1 in LibclangParseTest_EvaluateChildExpression_Test::TestBody() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:474:3 #22 0x5cae31 in testing::Test::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc #23 0x5cd068 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 #24 0x5ce430 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 #25 0x5ec1d4 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 #26 0x5eb380 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc #27 0x5b3983 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 #28 0x5b3983 in main /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:51 #29 0x7fd232efd2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0) Indirect leak of 4 byte(s) in 1 object(s) allocated from: #0 0x52c808 in operator new[](unsigned long) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:109 #1 0x7fd2367844dd in evaluateExpr /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3825:34 #2 0x7fd2367844dd in clang_Cursor_Evaluate /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3917 #3 0x54e743 in operator() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:487:39 #4 0x54e743 in LibclangParseTest_EvaluateChildExpression_Test::TestBody()::$_0::operator()(CXCursor, CXCursor, void*) const::'lambda'(CXCursor, CXCursor, void*)::__invoke(CXCursor, CXCursor, void*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:482 #5 0x7fd23677de00 in clang::cxcursor::CursorVisitor::RunVisitorWorkList(llvm::SmallVector<clang::cxcursor::VisitorJob, 10u>&) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3019:17 #6 0x7fd23675c3a8 in clang::cxcursor::CursorVisitor::Visit(clang::Stmt const*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3164:17 #7 0x7fd236755d2f in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp #8 0x7fd236754e5d in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:225:16 #9 0x7fd23676487c in clang::cxcursor::CursorVisitor::VisitFunctionDecl(clang::FunctionDecl*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:889:9 #10 0x7fd236759e24 in clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::cxcursor::CursorVisitor, bool>::Visit(clang::Decl*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/include/clang/AST/DeclVisitor.h #11 0x7fd236755c17 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:506:34 #12 0x7fd23678a558 in clang_visitChildren /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4352:20 #13 0x54e024 in operator() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:480:11 #14 0x54e024 in LibclangParseTest_EvaluateChildExpression_Test::TestBody()::$_0::__invoke(CXCursor, CXCursor, void*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:476 #15 0x7fd236754d49 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:217:11 #16 0x7fd23675cb87 in clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:674:7 #17 0x7fd23675cefe in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:635:30 #18 0x7fd236756399 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:540:20 #19 0x7fd23678a558 in clang_visitChildren /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4352:20 #20 0x537fa1 in LibclangParseTest_EvaluateChildExpression_Test::TestBody() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:474:3 #21 0x5cae31 in testing::Test::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc #22 0x5cd068 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 #23 0x5ce430 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 #24 0x5ec1d4 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 #25 0x5eb380 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc #26 0x5b3983 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 #27 0x5b3983 in main /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:51 #28 0x7fd232efd2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0) On Mon, Jul 9, 2018 at 12:46 PM Alex Lorenz via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: arphaman > Date: Mon Jul 9 12:41:28 2018 > New Revision: 336590 > > URL: http://llvm.org/viewvc/llvm-project?rev=336590&view=rev > Log: > [libclang] evalute compound statement cursors before trying to evaluate > the cursor like a declaration > > This change fixes a bug in libclang in which it tries to evaluate a > statement > cursor as a declaration cursor, because that statement still has a pointer > to > the declaration parent. > > rdar://38888477 > > Differential Revision: https://reviews.llvm.org/D49051 > > 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=336590&r1=336589&r2=336590&view=diff > > ============================================================================== > --- cfe/trunk/tools/libclang/CIndex.cpp (original) > +++ cfe/trunk/tools/libclang/CIndex.cpp Mon Jul 9 12:41:28 2018 > @@ -3890,6 +3890,19 @@ 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; > @@ -3903,19 +3916,6 @@ 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=336590&r1=336589&r2=336590&view=diff > > ============================================================================== > --- cfe/trunk/unittests/libclang/LibclangTest.cpp (original) > +++ cfe/trunk/unittests/libclang/LibclangTest.cpp Mon Jul 9 12:41:28 2018 > @@ -461,6 +461,47 @@ 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@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits