30class OSLogFormatStringHandler
34 const Expr *E =
nullptr;
35 std::optional<OSLogBufferItem::Kind> Kind;
36 std::optional<unsigned> Size;
37 std::optional<const Expr *> Count;
38 std::optional<const Expr *> Precision;
39 std::optional<const Expr *> FieldWidth;
40 unsigned char Flags = 0;
43 SmallVector<ArgData, 4> ArgsData;
44 ArrayRef<const Expr *> Args;
66 OSLogFormatStringHandler(ArrayRef<const Expr *> Args) : Args(Args) {
67 ArgsData.reserve(Args.size());
70 bool HandlePrintfSpecifier(
const analyze_printf::PrintfSpecifier &FS,
71 const char *StartSpecifier,
unsigned SpecifierLen,
72 const TargetInfo &)
override {
78 ArgsData.emplace_back();
80 if (ArgIndex < Args.size())
81 ArgsData.back().E = Args[ArgIndex];
96 switch (precision.getHowSpecified()) {
100 ArgsData.back().Size = precision.getConstantAmount();
103 ArgsData.back().Count = Args[precision.getArgIndex()];
112 switch (precision.getHowSpecified()) {
116 ArgsData.back().Size = precision.getConstantAmount();
119 ArgsData.back().Count = Args[precision.getArgIndex()];
147 void computeLayout(ASTContext &Ctx, OSLogBufferLayout &Layout)
const {
148 Layout.
Items.clear();
149 for (
auto &
Data : ArgsData) {
150 if (!
Data.MaskType.empty()) {
156 if (
Data.FieldWidth) {
161 if (
Data.Precision) {
196 const Expr *StringArg;
199 case Builtin::BI__builtin_os_log_format_buffer_size:
201 "__builtin_os_log_format_buffer_size takes at least 1 argument");
203 VarArgs = Args.slice(1);
205 case Builtin::BI__builtin_os_log_format:
207 "__builtin_os_log_format takes at least 2 arguments");
209 VarArgs = Args.slice(2);
212 llvm_unreachable(
"non-os_log builtin passed to computeOSLogBufferLayout");
218 OSLogFormatStringHandler H(VarArgs);
222 H.computeLayout(Ctx, Layout);
Defines enum values for all the target-independent builtin functions.
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
const TargetInfo & getTargetInfo() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Expr ** getArgs()
Retrieve the call arguments.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
StringLiteral - This represents a string literal expression, e.g.
StringRef getString() const
An OSLogBufferItem represents a single item in the data written by a call to os_log() or os_trace().
SmallVector< OSLogBufferItem, 4 > Items
const OptionalFlag & isPrivate() const
const OptionalAmount & getPrecision() const
StringRef getMaskType() const
const OptionalFlag & isSensitive() const
const PrintfConversionSpecifier & getConversionSpecifier() const
const OptionalFlag & isPublic() const
bool consumesDataArgument() const
bool computeOSLogBufferLayout(clang::ASTContext &Ctx, const clang::CallExpr *E, OSLogBufferLayout &layout)
The JSON file list parser is used to communicate input to InstallAPI.
U cast(CodeGen::Address addr)