From 9fcbde902596b8c33634f3647bfe64a0dba5c4f3 Mon Sep 17 00:00:00 2001 From: Josh Varga Date: Wed, 3 Jul 2024 18:44:06 -0700 Subject: [PATCH] [XLScc] Template argument list is not required if it can be inferred. Bumping llvm-raw dependency to a version that supports the missing-template-arg-list-after-template-kw clang flag PiperOrigin-RevId: 649257456 --- dependency_support/llvm/workspace.bzl | 4 +-- xls/contrib/xlscc/cc_parser.cc | 1 + .../xlscc/unit_tests/cc_parser_test.cc | 25 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/dependency_support/llvm/workspace.bzl b/dependency_support/llvm/workspace.bzl index 31a934431b..7378f388b8 100644 --- a/dependency_support/llvm/workspace.bzl +++ b/dependency_support/llvm/workspace.bzl @@ -21,8 +21,8 @@ def repo(): """Initialize the llvm-project repository.""" # Updated 2023/11/10 to match internal version. - LLVM_COMMIT = "87b00ef35a0060e29fbc771e8557600e396f966c" - LLVM_SHA256 = "5d25d5a85241bf6584227844b4912b1f0f13c61918deb3163756f169a8879ce8" + LLVM_COMMIT = "94471e6d238acab291b5b652fc18f17c4815cc7d" + LLVM_SHA256 = "7a622168e7ab3a94e348407b544e639695c3a628cf0c8b925867bbfba4c3b2af" maybe( http_archive, diff --git a/xls/contrib/xlscc/cc_parser.cc b/xls/contrib/xlscc/cc_parser.cc index 992ae187e8..87e7f9c5b4 100644 --- a/xls/contrib/xlscc/cc_parser.cc +++ b/xls/contrib/xlscc/cc_parser.cc @@ -689,6 +689,7 @@ void LibToolThread::Run() { argv.emplace_back("-Wno-unused-but-set-variable"); argv.emplace_back("-Wno-c++11-narrowing"); argv.emplace_back("-Wno-conversion"); + argv.emplace_back("-Wno-missing-template-arg-list-after-template-kw"); llvm::IntrusiveRefCntPtr libtool_files; diff --git a/xls/contrib/xlscc/unit_tests/cc_parser_test.cc b/xls/contrib/xlscc/unit_tests/cc_parser_test.cc index 7244cbbea0..247a99fe53 100644 --- a/xls/contrib/xlscc/unit_tests/cc_parser_test.cc +++ b/xls/contrib/xlscc/unit_tests/cc_parser_test.cc @@ -940,4 +940,29 @@ TEST_F(CCParserTest, PragmaUnrollParametersMustBeNumberIfNotYesOrNo) { testing::HasSubstr("Must be 'yes', 'no', or an integer."))); } +TEST_F(CCParserTest, TemplateArgsCanBeInferred) { + xlscc::CCParser parser; + + const std::string cpp_src = R"( + class x { + public: + template + T foo(T a) { + return a; + } + }; + template + T bar(T a) { + x x_inst; + return x_inst.template foo(a); + } + int top(int a) { + return bar(a); + } + )"; + + XLS_EXPECT_OK( + ScanTempFileWithContent(cpp_src, {}, &parser, /*top_name=*/"top")); +} + } // namespace