Skip to content

Conversation

@PeterChou1
Copy link
Contributor

@PeterChou1 PeterChou1 commented Mar 12, 2025

Reapply #130732

Fixes errors which broke build bot that uses GCC as a compiler
https://lab.llvm.org/buildbot/#/builders/66/builds/11049

GCC threw an warning due to an issue std::move with a temporary object which prevents copy elision. Fixes the issue by removing the std::move

Adds Support for the Mustache Templating Language. See specs here: https://mustache.github.io/mustache.5.html
This patch implements support+tests for majority of the features of the language including:

  • Variables
  • Comments
  • Lambdas
  • Sections

This meant as a library to support places where we have to generate HTML, such as in clang-doc.

@PeterChou1 PeterChou1 merged commit 6bf0c46 into llvm:main Mar 12, 2025
12 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 12, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-fast running on sanitizer-buildbot4 while building llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/9343

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 89516 tests, 88 workers --
Testing: 
FAIL: LLVM-Unit :: Support/./SupportTests/24/95 (1 of 89516)
******************** TEST 'LLVM-Unit :: Support/./SupportTests/24/95' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/unittests/Support/./SupportTests-LLVM-Unit-1790731-24-95.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=95 GTEST_SHARD_INDEX=24 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/unittests/Support/./SupportTests
--


Note: This is test shard 25 of 95.
[==========] Running 16 tests from 16 test suites.
[----------] Global test environment set-up.
[----------] 1 test from AlignmentTest
[ RUN      ] AlignmentTest.AssumeAligned
[       OK ] AlignmentTest.AssumeAligned (0 ms)
[----------] 1 test from AlignmentTest (0 ms total)

[----------] 1 test from BranchProbabilityTest
[ RUN      ] BranchProbabilityTest.scaleByInverse
[       OK ] BranchProbabilityTest.scaleByInverse (0 ms)
[----------] 1 test from BranchProbabilityTest (0 ms total)

[----------] 1 test from CommandLineTest
[ RUN      ] CommandLineTest.PositionalEatArgsError
[       OK ] CommandLineTest.PositionalEatArgsError (0 ms)
[----------] 1 test from CommandLineTest (0 ms total)

[----------] 1 test from EndianStream
[ RUN      ] EndianStream.WriteArrayLE
[       OK ] EndianStream.WriteArrayLE (0 ms)
[----------] 1 test from EndianStream (0 ms total)

[----------] 1 test from FormatVariadicTest
[ RUN      ] FormatVariadicTest.IntegralNumberFormatting
[       OK ] FormatVariadicTest.IntegralNumberFormatting (0 ms)
[----------] 1 test from FormatVariadicTest (0 ms total)

[----------] 1 test from HashBuilderTest/4, where TypeParam = <type>
[ RUN      ] HashBuilderTest/4.HashStringRef
[       OK ] HashBuilderTest/4.HashStringRef (0 ms)
Step 10 (stage2/asan_ubsan check) failure: stage2/asan_ubsan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 89516 tests, 88 workers --
Testing: 
FAIL: LLVM-Unit :: Support/./SupportTests/24/95 (1 of 89516)
******************** TEST 'LLVM-Unit :: Support/./SupportTests/24/95' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/unittests/Support/./SupportTests-LLVM-Unit-1790731-24-95.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=95 GTEST_SHARD_INDEX=24 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/unittests/Support/./SupportTests
--


Note: This is test shard 25 of 95.
[==========] Running 16 tests from 16 test suites.
[----------] Global test environment set-up.
[----------] 1 test from AlignmentTest
[ RUN      ] AlignmentTest.AssumeAligned
[       OK ] AlignmentTest.AssumeAligned (0 ms)
[----------] 1 test from AlignmentTest (0 ms total)

[----------] 1 test from BranchProbabilityTest
[ RUN      ] BranchProbabilityTest.scaleByInverse
[       OK ] BranchProbabilityTest.scaleByInverse (0 ms)
[----------] 1 test from BranchProbabilityTest (0 ms total)

[----------] 1 test from CommandLineTest
[ RUN      ] CommandLineTest.PositionalEatArgsError
[       OK ] CommandLineTest.PositionalEatArgsError (0 ms)
[----------] 1 test from CommandLineTest (0 ms total)

[----------] 1 test from EndianStream
[ RUN      ] EndianStream.WriteArrayLE
[       OK ] EndianStream.WriteArrayLE (0 ms)
[----------] 1 test from EndianStream (0 ms total)

[----------] 1 test from FormatVariadicTest
[ RUN      ] FormatVariadicTest.IntegralNumberFormatting
[       OK ] FormatVariadicTest.IntegralNumberFormatting (0 ms)
[----------] 1 test from FormatVariadicTest (0 ms total)

[----------] 1 test from HashBuilderTest/4, where TypeParam = <type>
[ RUN      ] HashBuilderTest/4.HashStringRef
[       OK ] HashBuilderTest/4.HashStringRef (0 ms)

@vitalybuka
Copy link
Collaborator

New memory leaks

https://lab.llvm.org/buildbot/#/builders/24/builds/6240/steps/12/logs/stdio

=================================================================
==SupportTests==1788193==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0xaeb5d6d96354 in operator new(unsigned long) /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:86:3
    #1 0xaeb5d78112fc in __libcpp_operator_new<unsigned long> /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1/__new/allocate.h:37:10
    #2 0xaeb5d78112fc in __libcpp_allocate<llvm::mustache::ASTNode *> /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1/__new/allocate.h:64:28
    #3 0xaeb5d78112fc in allocate /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1/__memory/allocator.h:105:14
    #4 0xaeb5d78112fc in __allocate_at_least<std::__1::allocator<llvm::mustache::ASTNode *> > /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1/__memory/allocate_at_least.h:41:19
    #5 0xaeb5d78112fc in __split_buffer /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1/__split_buffer:325:25
    #6 0xaeb5d78112fc in llvm::mustache::ASTNode** std::__1::vector<llvm::mustache::ASTNode*, std::__1::allocator<llvm::mustache::ASTNode*>>::__emplace_back_slow_path<llvm::mustache::ASTNode*&>(llvm::mustache::ASTNode*&) /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1/__vector/vector.h:1136:47
    #7 0xaeb5d780c8d0 in emplace_back<llvm::mustache::ASTNode *&> /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1/__vector/vector.h:1158:13
    #8 0xaeb5d780c8d0 in addChild /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Mustache.cpp:153:44
    #9 0xaeb5d780c8d0 in llvm::mustache::Parser::parseMustache(llvm::mustache::ASTNode*, llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>&, llvm::StringMap<llvm::mustache::ASTNode*, llvm::MallocAllocator>&, llvm::StringMap<std::__1::function<llvm::json::Value ()>, llvm::MallocAllocator>&, llvm::StringMap<std::__1::function<llvm::json::Value (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>)>, llvm::MallocAllocator>&, llvm::DenseMap<char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, llvm::DenseMapInfo<char, void>, llvm::detail::DenseMapPair<char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&) /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Mustache.cpp:494:15
    #10 0xaeb5d780b6ec in llvm::mustache::Parser::parse(llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>&, llvm::StringMap<llvm::mustache::ASTNode*, llvm::MallocAllocator>&, llvm::StringMap<std::__1::function<llvm::json::Value ()>, llvm::MallocAllocator>&, llvm::StringMap<std::__1::function<llvm::json::Value (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>)>, llvm::MallocAllocator>&, llvm::DenseMap<char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, llvm::DenseMapInfo<char, void>, llvm::detail::DenseMapPair<char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&) /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Mustache.cpp:471:3
    #11 0xaeb5d7810a98 in llvm::mustache::Template::Template(llvm::StringRef) /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Mustache.cpp:761:12
    #12 0xaeb5d73007f0 in MustacheInterpolation_ImplicitIteratorsInteger_Test::TestBody() /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/unittests/Support/MustacheTest.cpp:265:12
    #13 0xaeb5d794ee5c in HandleExceptionsInMethodIfSupported<testing::Test, void> /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #14 0xaeb5d794ee5c in testing::Test::Run() /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:2687:5
    #15 0xaeb5d7950ecc in testing::TestInfo::Run() /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:2836:11
    #16 0xaeb5d79522f8 in testing::TestSuite::Run() /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:3015:30
    #17 0xaeb5d7972d7c in testing::internal::UnitTestImpl::RunAllTests() /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:5920:44
    #18 0xaeb5d7971758 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #19 0xaeb5d7971758 in testing::UnitTest::Run() /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:5484:10
    #20 0xaeb5d792d790 in RUN_ALL_TESTS /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:2317:73
    #21 0xaeb5d792d790 in main /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp:55:10
    #22 0xf4b08a0284c0  (/lib/aarch64-linux-gnu/libc.so.6+0x284c0) (BuildId: 1d7249a4f207d07166ff4be43acdc68a01faaa04)
    #23 0xf4b08a028594 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28594) (BuildId: 1d7249a4f207d07166ff4be43acdc68a01faaa04)
    #24 0xaeb5d6cbebec in _start (/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/unittests/Support/SupportTests+0x65ebec)

cc @pcc

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 13, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-win running on as-worker-93 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2476

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests.exe/91/94' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-16464-91-94.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=94 GTEST_SHARD_INDEX=91 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied




********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 13, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64-aix running on aix-ppc64 while building llvm at step 3 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/64/builds/2486

Here is the relevant piece of the build log for the reference
Step 3 (clean-build-dir) failure: Delete failed. (failure) (timed out)
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests/22/94' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/unittests/Support/./SupportTests-LLVM-Unit-7471710-22-94.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=94 GTEST_SHARD_INDEX=22 /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/unittests/Support/./SupportTests
--

Script:
--
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/unittests/Support/./SupportTests --gtest_filter=ProgramEnvTest.TestExecuteNoWaitTimeoutPolling
--
Note: Google Test filter = ProgramEnvTest.TestExecuteNoWaitTimeoutPolling
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ProgramEnvTest
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Support/ProgramTest.cpp:413: Failure
Expected: (LoopCount) > (1u), actual: 1 vs 1
LoopCount should be >1


/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/unittests/Support/ProgramTest.cpp:413
Expected: (LoopCount) > (1u), actual: 1 vs 1
LoopCount should be >1



********************


@DanielCChen
Copy link
Contributor

@PeterChou1
This change caused the clang-ppc64-aix buildbot failure. Could you please take a look?
Affected test case:

Failed Tests (1):
  LLVM-Unit :: Support/./SupportTests/ProgramEnvTest/TestExecuteNoWaitTimeoutPolling

PeterChou1 added a commit to PeterChou1/llvm-project that referenced this pull request Mar 13, 2025
std::string Body;
ASTNode *Parent;
// TODO: switch implementation to SmallVector<T>
std::vector<ASTNode *> Children;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're getting leaks reported w/ this vector because the ASTNodes are allocated via BumpPtrAllocator, and thus never have their destructors called. Things allocated via BumpPtrAllocator can't have owned heap allocations like this. The two std::strings above are also problematic for the same reason.

When this used StringRef originally, it wasn't an issue for the strings. For the vector, you probably need to either rethink the overall strategy, or pass it in via reference. Maybe DenseMap<ASTNode*, vector<ASTNode*>> is workable using the same patterns/lifetimes as the StringMaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants