ΒΆclang::transformer::Stencil selectBound(
    std::vector<std::pair<std::string, Stencil>>
        CaseStencils,
    clang::transformer::Stencil DefaultStencil =
        nullptr)

Description

Chooses between multiple stencils, based on the presence of bound nodes. \p CaseStencils takes a vector of (ID, \c Stencil) pairs and checks each ID in order to see if it's bound to a node. If so, the associated \c Stencil is run and all other cases are ignored. An optional \p DefaultStencil can be provided to be run if all cases are exhausted beacause none of the provided IDs are bound. If no default case is provided and all cases are exhausted, the stencil will fail with error `llvm::errc::result_out_of_range`. For example, say one matches a statement's type with: anyOf( qualType(isInteger()).bind("int"), qualType(realFloatingPointType()).bind("float"), qualType(isAnyCharacter()).bind("char"), booleanType().bind("bool")) Then, one can decide in a stencil how to construct a literal. cat("a = ", selectBound( {{"int", cat("0")}, {"float", cat("0.0")}, {"char", cat("'\\0'")}, {"bool", cat("false")}})) In addition, one could supply a default case for all other types: selectBound( {{"int", cat("0")}, ... {"bool", cat("false")}}, cat("{}"))

Declared at: clang/include/clang/Tooling/Transformer/Stencil.h:149

Parameters

std::vector<std::pair<std::string, Stencil>> CaseStencils
clang::transformer::Stencil DefaultStencil = nullptr