Skip to content

Commit

Permalink
core: Fix linkage attribute parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkorenc committed Mar 25, 2024
1 parent 7b6cd04 commit 7295d5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 1 addition & 3 deletions include/vast/Dialect/Core/Func.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ namespace vast::core {
Printer &printer, auto op,
Attribute /* funcion_type */, mlir::DictionaryAttr, Region &body
) {
if (op.getLinkage() != core::GlobalLinkageKind::ExternalLinkage) {
printer << stringifyGlobalLinkageKind(op.getLinkage()) << ' ';
}
printer << stringifyGlobalLinkageKind(op.getLinkage()) << ' ';

auto fty = op.getFunctionType();
mlir::function_interface_impl::printFunctionSignature(
Expand Down
24 changes: 13 additions & 11 deletions lib/vast/Dialect/Core/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ namespace vast::core
) {
using core::GlobalLinkageKind;

// Default to external linkage if no keyword is provided.
attr_dict.append(
getLinkageAttrNameString(),
core::GlobalLinkageKindAttr::get(
parser.getContext(),
parse_optional_vast_keyword< GlobalLinkageKind >(
parser, GlobalLinkageKind::ExternalLinkage
)
)
);

llvm::SmallVector< Parser::Argument, 8 > arguments;
llvm::SmallVector< mlir::DictionaryAttr, 1 > result_attrs;
llvm::SmallVector< Type, 8 > arg_types;
Expand Down Expand Up @@ -78,6 +67,19 @@ namespace vast::core
// builder, state, arguments, result_attrs
// );

// Default to external linkage if no keyword is provided.
if (!attr_dict.getNamed(getLinkageAttrNameString())) {
attr_dict.append(
getLinkageAttrNameString(),
core::GlobalLinkageKindAttr::get(
parser.getContext(),
parse_optional_vast_keyword< GlobalLinkageKind >(
parser, GlobalLinkageKind::ExternalLinkage
)
)
);
}

auto loc = parser.getCurrentLocation();
auto parse_result = parser.parseOptionalRegion(
body, arguments, /* enableNameShadowing */false
Expand Down

0 comments on commit 7295d5a

Please sign in to comment.