Skip to content

Commit

Permalink
[XLScc] Template argument list is not required if it can be inferred.
Browse files Browse the repository at this point in the history
Bumping llvm-raw dependency to a version that supports the missing-template-arg-list-after-template-kw clang flag

PiperOrigin-RevId: 649257456
  • Loading branch information
JoshVarga authored and copybara-github committed Jul 4, 2024
1 parent 30f7e73 commit 9fcbde9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dependency_support/llvm/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions xls/contrib/xlscc/cc_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<clang::FileManager> libtool_files;

Expand Down
25 changes: 25 additions & 0 deletions xls/contrib/xlscc/unit_tests/cc_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
T foo(T a) {
return a;
}
};
template <typename T>
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

0 comments on commit 9fcbde9

Please sign in to comment.