clang 20.0.0git
Namespaces | Typedefs | Functions
Stencil.h File Reference

This file defines the Stencil abstraction: a code-generating object, parameterized by named references to (bound) AST nodes. More...

#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTTypeTraits.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Tooling/Transformer/MatchConsumer.h"
#include "clang/Tooling/Transformer/RangeSelector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include <string>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.
 
namespace  clang::transformer
 
namespace  clang::transformer::detail
 The following three functions are a low-level part of the RewriteRule API.
 

Typedefs

using clang::transformer::StencilInterface = MatchComputation< std::string >
 
using clang::transformer::Stencil = std::shared_ptr< StencilInterface >
 A sequence of code fragments, references to parameters and code-generation operations that together can be evaluated to (a fragment of) source code or a diagnostic message, given a match result.
 

Functions

Stencil clang::transformer::detail::makeStencil (llvm::StringRef Text)
 Convenience function to construct a Stencil.
 
Stencil clang::transformer::detail::makeStencil (RangeSelector Selector)
 
Stencil clang::transformer::detail::makeStencil (Stencil S)
 
Stencil clang::transformer::catVector (std::vector< Stencil > Parts)
 Constructs the string representing the concatenation of the given Parts.
 
template<typename... Ts>
Stencil clang::transformer::cat (Ts &&... Parts)
 Concatenates 0+ stencil pieces into a single stencil.
 
Stencil clang::transformer::expression (llvm::StringRef Id)
 Generates the source of the expression bound to Id, wrapping it in parentheses if it may parse differently depending on context.
 
Stencil clang::transformer::deref (llvm::StringRef ExprId)
 Constructs an idiomatic dereferencing of the expression bound to ExprId.
 
Stencil clang::transformer::maybeDeref (llvm::StringRef ExprId)
 If ExprId is of pointer type, constructs an idiomatic dereferencing of the expression bound to ExprId, including wrapping it in parentheses, if needed.
 
Stencil clang::transformer::addressOf (llvm::StringRef ExprId)
 Constructs an expression that idiomatically takes the address of the expression bound to ExprId.
 
Stencil clang::transformer::maybeAddressOf (llvm::StringRef ExprId)
 If ExprId is not a pointer type, constructs an expression that idiomatically takes the address of the expression bound to ExprId, including wrapping ExprId in parentheses, if needed.
 
Stencil clang::transformer::access (llvm::StringRef BaseId, Stencil Member)
 Constructs a MemberExpr that accesses the named member (Member) of the object bound to BaseId.
 
Stencil clang::transformer::access (llvm::StringRef BaseId, llvm::StringRef Member)
 
Stencil clang::transformer::ifBound (llvm::StringRef Id, Stencil TrueStencil, Stencil FalseStencil)
 Chooses between the two stencil parts, based on whether ID is bound in the match.
 
Stencil clang::transformer::ifBound (llvm::StringRef Id, llvm::StringRef TrueText, llvm::StringRef FalseText)
 Chooses between the two strings, based on whether ID is bound in the match.
 
Stencil clang::transformer::selectBound (std::vector< std::pair< std::string, Stencil > > CaseStencils, Stencil DefaultStencil=nullptr)
 Chooses between multiple stencils, based on the presence of bound nodes.
 
Stencil clang::transformer::run (MatchConsumer< std::string > C)
 Wraps a MatchConsumer in a Stencil, so that it can be used in a Stencil.
 
Stencil clang::transformer::describe (llvm::StringRef Id)
 Produces a human-readable rendering of the node bound to Id, suitable for diagnostics and debugging.
 
Stencil clang::transformer::dPrint (llvm::StringRef Id)
 For debug use only; semantics are not guaranteed.
 

Detailed Description

This file defines the Stencil abstraction: a code-generating object, parameterized by named references to (bound) AST nodes.

Given a match result, a stencil can be evaluated to a string of source code.

A stencil is similar in spirit to a format string: it is composed of a series of raw text strings, references to nodes (the parameters) and helper code-generation operations.

Definition in file Stencil.h.