clang  11.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>
Include dependency graph for Stencil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 clang
 Dataflow Directional Tag Classes.
 
 clang::transformer
 
 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. More...
 

Functions

Stencil clang::transformer::detail::makeStencil (llvm::StringRef Text)
 Convenience function to construct a Stencil. More...
 
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. More...
 
template<typename... Ts>
Stencil clang::transformer::cat (Ts &&... Parts)
 Concatenates 0+ stencil pieces into a single stencil. More...
 
Stencil clang::transformer::text (llvm::StringRef Text)
 DEPRECATED: Use cat instead. More...
 
Stencil clang::transformer::selection (RangeSelector Selector)
 DEPRECATED: Use cat instead. More...
 
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. More...
 
Stencil clang::transformer::deref (llvm::StringRef ExprId)
 Constructs an idiomatic dereferencing of the expression bound to ExprId. More...
 
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. More...
 
Stencil clang::transformer::addressOf (llvm::StringRef ExprId)
 Constructs an expression that idiomatically takes the address of the expression bound to ExprId. More...
 
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. More...
 
Stencil clang::transformer::access (llvm::StringRef BaseId, Stencil Member)
 Constructs a MemberExpr that accesses the named member (Member) of the object bound to BaseId. More...
 
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. More...
 
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. More...
 
Stencil clang::transformer::run (MatchConsumer< std::string > C)
 Wraps a MatchConsumer in a Stencil, so that it can be used in a Stencil. More...
 
Stencil clang::transformer::dPrint (llvm::StringRef Id)
 For debug use only; semantics are not guaranteed. More...
 

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.