Skip to content

AstAttributeMechanism::replace

Insert a new value if the attribute already exists.

Synopsis

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

bool
replace(
    std::string const& name,
    AstAttribute* value);

Description

Tests whether the specified attribute exists, and if so, invokes set. See set for details about ownership of the old and new attributes. Returns true if an attribute with the specified name already existed.

New semantics: The old implementation was ambiguous about who owned the object after this call. It didn't take ownership of an attribute that wasn't inserted, but it also didn't indicate whether it was inserted. The old implementation printed an error message on standard error if the attribute didn't exist and then returned to the caller without doing anything. Inserting a null value was allowed by the old implementation, in which case the old exists returned true but the old operator[] returned no attribute.

Parameters

Name

Description

value

Base class for all IR node attribute values.

Created with MrDocs