Skip to content

AstAttributeMechanism::add

Insert a new value if the attribute doesn't already exist.

Synopsis

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

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

Description

Tests whether an attribute with the specified name exists and if not, invokes set. See set for details about ownership of the new attribute. Returns true if an attribute with the specified name did not 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 existed (even if only its name existed but it had no value) 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