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;
50 return OSLogBufferItem::StringKind;
52 return OSLogBufferItem::WideStringKind;
54 return OSLogBufferItem::PointerKind;
56 return OSLogBufferItem::ObjCObjKind;
58 return OSLogBufferItem::ErrnoKind;
60 return OSLogBufferItem::ScalarKind;
67 ArgsData.reserve(Args.size());
71 const char *StartSpecifier,
unsigned SpecifierLen,
73 if (!FS.consumesDataArgument() &&
74 FS.getConversionSpecifier().getKind() !=
78 ArgsData.emplace_back();
79 unsigned ArgIndex = FS.getArgIndex();
80 if (ArgIndex < Args.size())
81 ArgsData.back().E = Args[ArgIndex];
84 ArgsData.back().Kind =
getKind(FS.getConversionSpecifier().getKind());
85 if (ArgsData.back().Kind != OSLogBufferItem::ErrnoKind &&
92 switch (FS.getConversionSpecifier().getKind()) {
95 auto &precision = FS.getPrecision();
96 switch (precision.getHowSpecified()) {
100 ArgsData.back().Size = precision.getConstantAmount();
103 ArgsData.back().Count = Args[precision.getArgIndex()];
111 auto &precision = FS.getPrecision();
112 switch (precision.getHowSpecified()) {
116 ArgsData.back().Size = precision.getConstantAmount();
119 ArgsData.back().Count = Args[precision.getArgIndex()];
127 if (FS.getPrecision().hasDataArgument()) {
128 ArgsData.back().Precision = Args[FS.getPrecision().getArgIndex()];
132 if (FS.getFieldWidth().hasDataArgument()) {
133 ArgsData.back().FieldWidth = Args[FS.getFieldWidth().getArgIndex()];
136 if (FS.isSensitive())
137 ArgsData.back().Flags |= OSLogBufferItem::IsSensitive;
138 else if (FS.isPrivate())
139 ArgsData.back().Flags |= OSLogBufferItem::IsPrivate;
140 else if (FS.isPublic())
141 ArgsData.back().Flags |= OSLogBufferItem::IsPublic;
143 ArgsData.back().MaskType = FS.getMaskType();
148 Layout.
Items.clear();
149 for (
auto &
Data : ArgsData) {
150 if (!
Data.MaskType.empty()) {
152 Layout.
Items.emplace_back(OSLogBufferItem::MaskKind,
nullptr, Size, 0,
156 if (
Data.FieldWidth) {
158 Layout.
Items.emplace_back(OSLogBufferItem::ScalarKind, *
Data.FieldWidth,
161 if (
Data.Precision) {
163 Layout.
Items.emplace_back(OSLogBufferItem::ScalarKind, *
Data.Precision,
169 Layout.
Items.emplace_back(OSLogBufferItem::CountKind, *
Data.Count, Size,
177 if (*
Data.Kind == OSLogBufferItem::ErrnoKind)
184 Layout.
Items.emplace_back(OSLogBufferItem::ScalarKind,
Data.E, Size,
196 const Expr *StringArg;
198 switch (
E->getBuiltinCallee()) {
199 case Builtin::BI__builtin_os_log_format_buffer_size:
200 assert(
E->getNumArgs() >= 1 &&
201 "__builtin_os_log_format_buffer_size takes at least 1 argument");
202 StringArg =
E->getArg(0);
203 VarArgs = Args.slice(1);
205 case Builtin::BI__builtin_os_log_format:
206 assert(
E->getNumArgs() >= 2 &&
207 "__builtin_os_log_format takes at least 2 arguments");
208 StringArg =
E->getArg(1);
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]).
CharUnits - This is an opaque type for sizes expressed in character units.
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
Exposes information about the current target.
An OSLogBufferItem represents a single item in the data written by a call to os_log() or os_trace().
SmallVector< OSLogBufferItem, 4 > Items
bool computeOSLogBufferLayout(clang::ASTContext &Ctx, const clang::CallExpr *E, OSLogBufferLayout &layout)
The JSON file list parser is used to communicate input to InstallAPI.