Skip to content

AstAttributeMechanism::set

Insert an attribute.

Synopsis

Declared in <src/midend/astProcessing/AstAttributeMechanism.h>

void
set(
    std::string const& name,
    AstAttribute* value);

Description

Inserts the specified heap‐allocated value for the given attribute name, replacing any previous value stored for that same name.

If the new value uses the AstAttribute::CONTAINER_OWNERSHIP policy then ownership is immediately transferred/moved to this container, which becomes responsible for deleting the attribute as appropriate to prevent leasks. Otherwise, the attribute's designer is responsible for implementing an ownership policy that safely prevents leaks.

If the old value (if present) uses the AstAttribute::CONTAINER_OWNERSHIP policy then it is deleted. Otherwise the attribute's designer is responsible for implementing an ownership policy that safely prevents leaks, and the attribute must not be deleted until after this method returns.

New semantics: The old implementation didn't delete the previous attribute value. The old implementation allowed setting a null value, in which case the old exists returned true but the operator[] returned no attribute.

Parameters

Name

Description

value

Base class for all IR node attribute values.

Created with MrDocs