clang 8.0.0

FormatString.h
Go to the documentation of this file.
1 //= FormatString.h - Analysis of printf/fprintf format strings --*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines APIs for analyzing the format strings of printf, fscanf,
11 // and friends.
12 //
13 // The structure of format strings for fprintf are described in C99 7.19.6.1.
14 //
15 // The structure of format strings for fscanf are described in C99 7.19.6.2.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_FORMATSTRING_H
20 #define LLVM_CLANG_ANALYSIS_ANALYSES_FORMATSTRING_H
21
22 #include "clang/AST/CanonicalType.h"
23
24 namespace clang {
25
26 class TargetInfo;
27
28 //===----------------------------------------------------------------------===//
29 /// Common components of both fprintf and fscanf format strings.
30 namespace analyze_format_string {
31
32 /// Class representing optional flags with location and representation
33 /// information.
34 class OptionalFlag {
35 public:
36 OptionalFlag(const char *Representation)
37 : representation(Representation), flag(false) {}
38 bool isSet() const { return flag; }
39 void set() { flag = true; }
40 void clear() { flag = false; }
41 void setPosition(const char *position) {
42 assert(position);
43 flag = true;
44 this->position = position;
45 }
46 const char *getPosition() const {
47 assert(position);
48 return position;
49 }
50 const char *toString() const { return representation; }
51
52 // Overloaded operators for bool like qualities
53 explicit operator bool() const { return flag; }
54 OptionalFlag& operator=(const bool &rhs) {
55 flag = rhs;
56 return *this; // Return a reference to myself.
57 }
58 private:
59 const char *representation;
60 const char *position;
61 bool flag;
62 };
63
64 /// Represents the length modifier in a format string in scanf/printf.
65 class LengthModifier {
66 public:
67 enum Kind {
68 None,
69 AsChar, // 'hh'
70 AsShort, // 'h'
71 AsLong, // 'l'
72 AsLongLong, // 'll'
73 AsQuad, // 'q' (BSD, deprecated, for 64-bit integer types)
74 AsIntMax, // 'j'
75 AsSizeT, // 'z'
76 AsPtrDiff, // 't'
77 AsInt32, // 'I32' (MSVCRT, like __int32)
78 AsInt3264, // 'I' (MSVCRT, like __int3264 from MIDL)
79 AsInt64, // 'I64' (MSVCRT, like __int64)
80 AsLongDouble, // 'L'
81 AsAllocate, // for '%as', GNU extension to C90 scanf
82 AsMAllocate, // for '%ms', GNU extension to scanf
83 AsWide, // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
84 AsWideChar = AsLong // for '%ls', only makes sense for printf
85 };
86
87 LengthModifier()
88 : Position(nullptr), kind(None) {}
89 LengthModifier(const char *pos, Kind k)
90 : Position(pos), kind(k) {}
91
92 const char *getStart() const {
93 return Position;
94 }
95
96 unsigned getLength() const {
97 switch (kind) {
98 default:
99 return 1;
100 case AsLongLong:
101 case AsChar:
102 return 2;
103 case AsInt32:
104 case AsInt64:
105 return 3;
106 case None:
107 return 0;
108 }
109 }
110
111 Kind getKind() const { return kind; }
112 void setKind(Kind k) { kind = k; }
113
114 const char *toString() const;
115
116 private:
117 const char *Position;
118 Kind kind;
119 };
120
121 class ConversionSpecifier {
122 public:
123 enum Kind {
124 InvalidSpecifier = 0,
125 // C99 conversion specifiers.
126 cArg,
127 dArg,
128 DArg, // Apple extension
129 iArg,
130 IntArgBeg = dArg,
131 IntArgEnd = iArg,
132
133 oArg,
134 OArg, // Apple extension
135 uArg,
136 UArg, // Apple extension
137 xArg,
138 XArg,
139 UIntArgBeg = oArg,
140 UIntArgEnd = XArg,
141
142 fArg,
143 FArg,
144 eArg,
145 EArg,
146 gArg,
147 GArg,
148 aArg,
149 AArg,
150 DoubleArgBeg = fArg,
151 DoubleArgEnd = AArg,
152
153 sArg,
154 pArg,
155 nArg,
156 PercentArg,
157 CArg,
158 SArg,
159
160 // Apple extension: P specifies to os_log that the data being pointed to is
161 // to be copied by os_log. The precision indicates the number of bytes to
162 // copy.
163 PArg,
164
165 // ** Printf-specific **
166
167 ZArg, // MS extension
168
169 // Objective-C specific specifiers.
170 ObjCObjArg, // '@'
171 ObjCBeg = ObjCObjArg,
172 ObjCEnd = ObjCObjArg,
173
174 // FreeBSD kernel specific specifiers.
175 FreeBSDbArg,
176 FreeBSDDArg,
177 FreeBSDrArg,
178 FreeBSDyArg,
179
180 // GlibC specific specifiers.
181 PrintErrno, // 'm'
182
183 PrintfConvBeg = ObjCObjArg,
184 PrintfConvEnd = PrintErrno,
185
186 // ** Scanf-specific **
187 ScanListArg, // '['
188 ScanfConvBeg = ScanListArg,
189 ScanfConvEnd = ScanListArg
190 };
191
192 ConversionSpecifier(bool isPrintf = true)
193 : IsPrintf(isPrintf), Position(nullptr), EndScanList(nullptr),
194 kind(InvalidSpecifier) {}
195
196 ConversionSpecifier(bool isPrintf, const char *pos, Kind k)
197 : IsPrintf(isPrintf), Position(pos), EndScanList(nullptr), kind(k) {}
198
199 const char *getStart() const {
200 return Position;
201 }
202
203 StringRef getCharacters() const {
204 return StringRef(getStart(), getLength());
205 }
206
207 bool consumesDataArgument() const {
208 switch (kind) {
209 case PrintErrno:
210 assert(IsPrintf);
211 return false;
212 case PercentArg:
213 return false;
214 case InvalidSpecifier:
215 return false;
216 default:
217 return true;
218 }
219 }
220
221 Kind getKind() const { return kind; }
222 void setKind(Kind k) { kind = k; }
223 unsigned getLength() const {
224 return EndScanList ? EndScanList - Position : 1;
225 }
226 void setEndScanList(const char *pos) { EndScanList = pos; }
227
228 bool isIntArg() const { return (kind >= IntArgBeg && kind <= IntArgEnd) ||
229 kind == FreeBSDrArg || kind == FreeBSDyArg; }
230 bool isUIntArg() const { return kind >= UIntArgBeg && kind <= UIntArgEnd; }
231 bool isAnyIntArg() const { return kind >= IntArgBeg && kind <= UIntArgEnd; }
232 bool isDoubleArg() const {
233 return kind >= DoubleArgBeg && kind <= DoubleArgEnd;
234 }
235
236 const char *toString() const;
237
238 bool isPrintfKind() const { return IsPrintf; }
239
240 Optional<ConversionSpecifier> getStandardSpecifier() const;
241
242 protected:
243 bool IsPrintf;
244 const char *Position;
245 const char *EndScanList;
246 Kind kind;
247 };
248
249 class ArgType {
250 public:
251 enum Kind { UnknownTy, InvalidTy, SpecificTy, ObjCPointerTy, CPointerTy,
252 AnyCharTy, CStrTy, WCStrTy, WIntTy };
253
254 enum MatchKind { NoMatch = 0, Match = 1, NoMatchPedantic };
255
256 private:
257 const Kind K;
258 QualType T;
259 const char *Name = nullptr;
260 bool Ptr = false;
261
262 /// The TypeKind identifies certain well-known types like size_t and
263 /// ptrdiff_t.
264 enum class TypeKind { DontCare, SizeT, PtrdiffT };
265 TypeKind TK = TypeKind::DontCare;
266
267 public:
268 ArgType(Kind K = UnknownTy, const char *N = nullptr) : K(K), Name(N) {}
269 ArgType(QualType T, const char *N = nullptr) : K(SpecificTy), T(T), Name(N) {}
270 ArgType(CanQualType T) : K(SpecificTy), T(T) {}
271
272 static ArgType Invalid() { return ArgType(InvalidTy); }
273 bool isValid() const { return K != InvalidTy; }
274
275 bool isSizeT() const { return TK == TypeKind::SizeT; }
276
277 bool isPtrdiffT() const { return TK == TypeKind::PtrdiffT; }
278
279 /// Create an ArgType which corresponds to the type pointer to A.
280 static ArgType PtrTo(const ArgType& A) {
281 assert(A.K >= InvalidTy && "ArgType cannot be pointer to invalid/unknown");
282 ArgType Res = A;
283 Res.Ptr = true;
284 return Res;
285 }
286
287 /// Create an ArgType which corresponds to the size_t/ssize_t type.
288 static ArgType makeSizeT(const ArgType &A) {
289 ArgType Res = A;
290 Res.TK = TypeKind::SizeT;
291 return Res;
292 }
293
294 /// Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t
295 /// type.
296 static ArgType makePtrdiffT(const ArgType &A) {
297 ArgType Res = A;
298 Res.TK = TypeKind::PtrdiffT;
299 return Res;
300 }
301
302 MatchKind matchesType(ASTContext &C, QualType argTy) const;
303
304 QualType getRepresentativeType(ASTContext &C) const;
305
306 ArgType makeVectorType(ASTContext &C, unsigned NumElts) const;
307
308 std::string getRepresentativeTypeName(ASTContext &C) const;
309 };
310
311 class OptionalAmount {
312 public:
313 enum HowSpecified { NotSpecified, Constant, Arg, Invalid };
314
315 OptionalAmount(HowSpecified howSpecified,
316 unsigned amount,
317 const char *amountStart,
318 unsigned amountLength,
319 bool usesPositionalArg)
320 : start(amountStart), length(amountLength), hs(howSpecified), amt(amount),
321 UsesPositionalArg(usesPositionalArg), UsesDotPrefix(0) {}
322
323 OptionalAmount(bool valid = true)
324 : start(nullptr),length(0), hs(valid ? NotSpecified : Invalid), amt(0),
325 UsesPositionalArg(0), UsesDotPrefix(0) {}
326
327 explicit OptionalAmount(unsigned Amount)
328 : start(nullptr), length(0), hs(Constant), amt(Amount),
329 UsesPositionalArg(false), UsesDotPrefix(false) {}
330
331 bool isInvalid() const {
332 return hs == Invalid;
333 }
334
335 HowSpecified getHowSpecified() const { return hs; }
336 void setHowSpecified(HowSpecified h) { hs = h; }
337
338 bool hasDataArgument() const { return hs == Arg; }
339
340 unsigned getArgIndex() const {
341 assert(hasDataArgument());
342 return amt;
343 }
344
345 unsigned getConstantAmount() const {
346 assert(hs == Constant);
347 return amt;
348 }
349
350 const char *getStart() const {
351 // We include the . character if it is given.
352 return start - UsesDotPrefix;
353 }
354
355 unsigned getConstantLength() const {
356 assert(hs == Constant);
357 return length + UsesDotPrefix;
358 }
359
360 ArgType getArgType(ASTContext &Ctx) const;
361
362 void toString(raw_ostream &os) const;
363
364 bool usesPositionalArg() const { return (bool) UsesPositionalArg; }
365 unsigned getPositionalArgIndex() const {
366 assert(hasDataArgument());
367 return amt + 1;
368 }
369
370 bool usesDotPrefix() const { return UsesDotPrefix; }
371 void setUsesDotPrefix() { UsesDotPrefix = true; }
372
373 private:
374 const char *start;
375 unsigned length;
376 HowSpecified hs;
377 unsigned amt;
378 bool UsesPositionalArg : 1;
379 bool UsesDotPrefix;
380 };
381
382
383 class FormatSpecifier {
384 protected:
385 LengthModifier LM;
386 OptionalAmount FieldWidth;
387 ConversionSpecifier CS;
388 OptionalAmount VectorNumElts;
389
390 /// Positional arguments, an IEEE extension:
391 /// IEEE Std 1003.1, 2004 Edition
392 /// http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
393 bool UsesPositionalArg;
394 unsigned argIndex;
395 public:
396 FormatSpecifier(bool isPrintf)
397 : CS(isPrintf), VectorNumElts(false),
398 UsesPositionalArg(false), argIndex(0) {}
399
400 void setLengthModifier(LengthModifier lm) {
401 LM = lm;
402 }
403
404 void setUsesPositionalArg() { UsesPositionalArg = true; }
405
406 void setArgIndex(unsigned i) {
407 argIndex = i;
408 }
409
410 unsigned getArgIndex() const {
411 return argIndex;
412 }
413
414 unsigned getPositionalArgIndex() const {
415 return argIndex + 1;
416 }
417
418 const LengthModifier &getLengthModifier() const {
419 return LM;
420 }
421
422 const OptionalAmount &getFieldWidth() const {
423 return FieldWidth;
424 }
425
426 void setVectorNumElts(const OptionalAmount &Amt) {
427 VectorNumElts = Amt;
428 }
429
430 const OptionalAmount &getVectorNumElts() const {
431 return VectorNumElts;
432 }
433
434 void setFieldWidth(const OptionalAmount &Amt) {
435 FieldWidth = Amt;
436 }
437
438 bool usesPositionalArg() const { return UsesPositionalArg; }
439
440 bool hasValidLengthModifier(const TargetInfo &Target) const;
441
442 bool hasStandardLengthModifier() const;
443
444 Optional<LengthModifier> getCorrectedLengthModifier() const;
445
446 bool hasStandardConversionSpecifier(const LangOptions &LangOpt) const;
447
448 bool hasStandardLengthConversionCombination() const;
449
450 /// For a TypedefType QT, if it is a named integer type such as size_t,
451 /// assign the appropriate value to LM and return true.
452 static bool namedTypeToLengthModifier(QualType QT, LengthModifier &LM);
453 };
454
455 } // end analyze_format_string namespace
456
457 //===----------------------------------------------------------------------===//
458 /// Pieces specific to fprintf format strings.
459
460 namespace analyze_printf {
461
462 class PrintfConversionSpecifier :
463 public analyze_format_string::ConversionSpecifier {
464 public:
465 PrintfConversionSpecifier()
466 : ConversionSpecifier(true, nullptr, InvalidSpecifier) {}
467
468 PrintfConversionSpecifier(const char *pos, Kind k)
469 : ConversionSpecifier(true, pos, k) {}
470
471 bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; }
472 bool isDoubleArg() const { return kind >= DoubleArgBeg &&
473 kind <= DoubleArgEnd; }
474
475 static bool classof(const analyze_format_string::ConversionSpecifier *CS) {
476 return CS->isPrintfKind();
477 }
478 };
479
480 using analyze_format_string::ArgType;
481 using analyze_format_string::LengthModifier;
482 using analyze_format_string::OptionalAmount;
483 using analyze_format_string::OptionalFlag;
484
485 class PrintfSpecifier : public analyze_format_string::FormatSpecifier {
486 OptionalFlag HasThousandsGrouping; // ''', POSIX extension.
487 OptionalFlag IsLeftJustified; // '-'
488 OptionalFlag HasPlusPrefix; // '+'
489 OptionalFlag HasSpacePrefix; // ' '
490 OptionalFlag HasAlternativeForm; // '#'
491 OptionalFlag HasLeadingZeroes; // '0'
492 OptionalFlag HasObjCTechnicalTerm; // '[tt]'
493 OptionalFlag IsPrivate; // '{private}'
494 OptionalFlag IsPublic; // '{public}'
495 OptionalFlag IsSensitive; // '{sensitive}'
496 OptionalAmount Precision;
497 StringRef MaskType;
498
499 ArgType getScalarArgType(ASTContext &Ctx, bool IsObjCLiteral) const;
500
501 public:
502 PrintfSpecifier()
503 : FormatSpecifier(/* isPrintf = */ true), HasThousandsGrouping("'"),
504 IsLeftJustified("-"), HasPlusPrefix("+"), HasSpacePrefix(" "),
505 HasAlternativeForm("#"), HasLeadingZeroes("0"),
506 HasObjCTechnicalTerm("tt"), IsPrivate("private"), IsPublic("public"),
507 IsSensitive("sensitive") {}
508
509 static PrintfSpecifier Parse(const char *beg, const char *end);
510
511 // Methods for incrementally constructing the PrintfSpecifier.
512 void setConversionSpecifier(const PrintfConversionSpecifier &cs) {
513 CS = cs;
514 }
515 void setHasThousandsGrouping(const char *position) {
516 HasThousandsGrouping.setPosition(position);
517 }
518 void setIsLeftJustified(const char *position) {
519 IsLeftJustified.setPosition(position);
520 }
521 void setHasPlusPrefix(const char *position) {
522 HasPlusPrefix.setPosition(position);
523 }
524 void setHasSpacePrefix(const char *position) {
525 HasSpacePrefix.setPosition(position);
526 }
527 void setHasAlternativeForm(const char *position) {
528 HasAlternativeForm.setPosition(position);
529 }
530 void setHasLeadingZeros(const char *position) {
531 HasLeadingZeroes.setPosition(position);
532 }
533 void setHasObjCTechnicalTerm(const char *position) {
534 HasObjCTechnicalTerm.setPosition(position);
535 }
536 void setIsPrivate(const char *position) { IsPrivate.setPosition(position); }
537 void setIsPublic(const char *position) { IsPublic.setPosition(position); }
538 void setIsSensitive(const char *position) {
539 IsSensitive.setPosition(position);
540 }
541 void setUsesPositionalArg() { UsesPositionalArg = true; }
542
543 // Methods for querying the format specifier.
544
545 const PrintfConversionSpecifier &getConversionSpecifier() const {
546 return cast<PrintfConversionSpecifier>(CS);
547 }
548
549 void setPrecision(const OptionalAmount &Amt) {
550 Precision = Amt;
551 Precision.setUsesDotPrefix();
552 }
553
554 const OptionalAmount &getPrecision() const {
555 return Precision;
556 }
557
558 bool consumesDataArgument() const {
559 return getConversionSpecifier().consumesDataArgument();
560 }
561
562 /// Returns the builtin type that a data argument
563 /// paired with this format specifier should have. This method
564 /// will return null if the format specifier does not have
565 /// a matching data argument or the matching argument matches
566 /// more than one type.
567 ArgType getArgType(ASTContext &Ctx, bool IsObjCLiteral) const;
568
569 const OptionalFlag &hasThousandsGrouping() const {
570 return HasThousandsGrouping;
571 }
572 const OptionalFlag &isLeftJustified() const { return IsLeftJustified; }
573 const OptionalFlag &hasPlusPrefix() const { return HasPlusPrefix; }
574 const OptionalFlag &hasAlternativeForm() const { return HasAlternativeForm; }
575 const OptionalFlag &hasLeadingZeros() const { return HasLeadingZeroes; }
576 const OptionalFlag &hasSpacePrefix() const { return HasSpacePrefix; }
577 const OptionalFlag &hasObjCTechnicalTerm() const { return HasObjCTechnicalTerm; }
578 const OptionalFlag &isPrivate() const { return IsPrivate; }
579 const OptionalFlag &isPublic() const { return IsPublic; }
580 const OptionalFlag &isSensitive() const { return IsSensitive; }
581 bool usesPositionalArg() const { return UsesPositionalArg; }
582
583 StringRef getMaskType() const { return MaskType; }
584 void setMaskType(StringRef S) { MaskType = S; }
585
586 /// Changes the specifier and length according to a QualType, retaining any
587 /// flags or options. Returns true on success, or false when a conversion
588 /// was not successful.
589 bool fixType(QualType QT, const LangOptions &LangOpt, ASTContext &Ctx,
590 bool IsObjCLiteral);
591
592 void toString(raw_ostream &os) const;
593
594 // Validation methods - to check if any element results in undefined behavior
595 bool hasValidPlusPrefix() const;
596 bool hasValidAlternativeForm() const;
597 bool hasValidLeadingZeros() const;
598 bool hasValidSpacePrefix() const;
599 bool hasValidLeftJustified() const;
600 bool hasValidThousandsGroupingPrefix() const;
601
602 bool hasValidPrecision() const;
603 bool hasValidFieldWidth() const;
604 };
605 } // end analyze_printf namespace
606
607 //===----------------------------------------------------------------------===//
608 /// Pieces specific to fscanf format strings.
609
610 namespace analyze_scanf {
611
612 class ScanfConversionSpecifier :
613 public analyze_format_string::ConversionSpecifier {
614 public:
615 ScanfConversionSpecifier()
616 : ConversionSpecifier(false, nullptr, InvalidSpecifier) {}
617
618 ScanfConversionSpecifier(const char *pos, Kind k)
619 : ConversionSpecifier(false, pos, k) {}
620
621 static bool classof(const analyze_format_string::ConversionSpecifier *CS) {
622 return !CS->isPrintfKind();
623 }
624 };
625
626 using analyze_format_string::ArgType;
627 using analyze_format_string::LengthModifier;
628 using analyze_format_string::OptionalAmount;
629 using analyze_format_string::OptionalFlag;
630
631 class ScanfSpecifier : public analyze_format_string::FormatSpecifier {
632 OptionalFlag SuppressAssignment; // '*'
633 public:
634 ScanfSpecifier() :
635 FormatSpecifier(/* isPrintf = */ false),
636 SuppressAssignment("*") {}
637
638 void setSuppressAssignment(const char *position) {
639 SuppressAssignment.setPosition(position);
640 }
641
642 const OptionalFlag &getSuppressAssignment() const {
643 return SuppressAssignment;
644 }
645
646 void setConversionSpecifier(const ScanfConversionSpecifier &cs) {
647 CS = cs;
648 }
649
650 const ScanfConversionSpecifier &getConversionSpecifier() const {
651 return cast<ScanfConversionSpecifier>(CS);
652 }
653
654 bool consumesDataArgument() const {
655 return CS.consumesDataArgument() && !SuppressAssignment;
656 }
657
658 ArgType getArgType(ASTContext &Ctx) const;
659
660 bool fixType(QualType QT, QualType RawQT, const LangOptions &LangOpt,
661 ASTContext &Ctx);
662
663 void toString(raw_ostream &os) const;
664
665 static ScanfSpecifier Parse(const char *beg, const char *end);
666 };
667
668 } // end analyze_scanf namespace
669
670 //===----------------------------------------------------------------------===//
671 // Parsing and processing of format strings (both fprintf and fscanf).
672
673 namespace analyze_format_string {
674
675 enum PositionContext { FieldWidthPos = 0, PrecisionPos = 1 };
676
677 class FormatStringHandler {
678 public:
679 FormatStringHandler() {}
680 virtual ~FormatStringHandler();
681
682 virtual void HandleNullChar(const char *nullCharacter) {}
683
684 virtual void HandlePosition(const char *startPos, unsigned posLen) {}
685
686 virtual void HandleInvalidPosition(const char *startPos, unsigned posLen,
687 PositionContext p) {}
688
689 virtual void HandleZeroPosition(const char *startPos, unsigned posLen) {}
690
691 virtual void HandleIncompleteSpecifier(const char *startSpecifier,
692 unsigned specifierLen) {}
693
694 virtual void HandleEmptyObjCModifierFlag(const char *startFlags,
695 unsigned flagsLen) {}
696
697 virtual void HandleInvalidObjCModifierFlag(const char *startFlag,
698 unsigned flagLen) {}
699
700 virtual void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart,
701 const char *flagsEnd,
702 const char *conversionPosition) {}
703 // Printf-specific handlers.
704
705 virtual bool HandleInvalidPrintfConversionSpecifier(
706 const analyze_printf::PrintfSpecifier &FS,
707 const char *startSpecifier,
708 unsigned specifierLen) {
709 return true;
710 }
711
712 virtual bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier &FS,
713 const char *startSpecifier,
714 unsigned specifierLen) {
715 return true;
716 }
717
718 /// Handle mask types whose sizes are not between one and eight bytes.
719 virtual void handleInvalidMaskType(StringRef MaskType) {}
720
721 // Scanf-specific handlers.
722
723 virtual bool HandleInvalidScanfConversionSpecifier(
724 const analyze_scanf::ScanfSpecifier &FS,
725 const char *startSpecifier,
726 unsigned specifierLen) {
727 return true;
728 }
729
730 virtual bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS,
731 const char *startSpecifier,
732 unsigned specifierLen) {
733 return true;
734 }
735
736 virtual void HandleIncompleteScanList(const char *start, const char *end) {}
737 };
738
739 bool ParsePrintfString(FormatStringHandler &H,
740 const char *beg, const char *end, const LangOptions &LO,
741 const TargetInfo &Target, bool isFreeBSDKPrintf);
742
743 bool ParseFormatStringHasSArg(const char *beg, const char *end,
744 const LangOptions &LO, const TargetInfo &Target);
745
746 bool ParseScanfString(FormatStringHandler &H,
747 const char *beg, const char *end, const LangOptions &LO,
748 const TargetInfo &Target);
749
750 } // end analyze_format_string namespace
751 } // end clang namespace
752 #endif
clang::analyze_format_string::ArgType::isSizeT
bool isSizeT() const
Definition: FormatString.h:275
clang::analyze_format_string::ConversionSpecifier::FreeBSDyArg
Definition: FormatString.h:178
clang::analyze_format_string::OptionalFlag::isSet
bool isSet() const
Definition: FormatString.h:38
clang::analyze_printf::PrintfSpecifier::hasAlternativeForm
const OptionalFlag & hasAlternativeForm() const
Definition: FormatString.h:574
clang::analyze_format_string::FormatSpecifier::setUsesPositionalArg
void setUsesPositionalArg()
Definition: FormatString.h:404
clang::analyze_format_string::FormatStringHandler::HandlePosition
virtual void HandlePosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:684
clang::analyze_format_string::ArgType::makePtrdiffT
static ArgType makePtrdiffT(const ArgType &A)
Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t type.
Definition: FormatString.h:296
clang::analyze_format_string::FormatStringHandler::HandleScanfSpecifier
virtual bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:730
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:638
clang::analyze_format_string::ConversionSpecifier::XArg
Definition: FormatString.h:138
clang::analyze_format_string::ArgType::ArgType
ArgType(CanQualType T)
Definition: FormatString.h:270
clang::analyze_scanf::ScanfSpecifier::getConversionSpecifier
const ScanfConversionSpecifier & getConversionSpecifier() const
Definition: FormatString.h:650
clang::analyze_format_string::OptionalAmount::OptionalAmount
OptionalAmount(unsigned Amount)
Definition: FormatString.h:327
clang::analyze_printf::PrintfSpecifier::setIsPublic
void setIsPublic(const char *position)
Definition: FormatString.h:537
clang::analyze_scanf::ScanfSpecifier::getSuppressAssignment
const OptionalFlag & getSuppressAssignment() const
Definition: FormatString.h:642
clang::analyze_printf::PrintfSpecifier::consumesDataArgument
bool consumesDataArgument() const
Definition: FormatString.h:558
clang::analyze_format_string::ConversionSpecifier::isIntArg
bool isIntArg() const
Definition: FormatString.h:228
clang::analyze_format_string::ConversionSpecifier::ZArg
Definition: FormatString.h:167
clang::analyze_format_string::ConversionSpecifier::FreeBSDbArg
Definition: FormatString.h:175
clang::analyze_format_string::ConversionSpecifier::SArg
Definition: FormatString.h:158
clang::analyze_format_string::FormatStringHandler::HandleInvalidObjCModifierFlag
virtual void HandleInvalidObjCModifierFlag(const char *startFlag, unsigned flagLen)
Definition: FormatString.h:697
clang::analyze_format_string::FormatSpecifier::LM
LengthModifier LM
Definition: FormatString.h:385
clang::analyze_format_string::FormatSpecifier::FormatSpecifier
FormatSpecifier(bool isPrintf)
Definition: FormatString.h:396
clang::analyze_format_string::FormatStringHandler::HandleZeroPosition
virtual void HandleZeroPosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:689
clang::analyze_format_string::OptionalFlag::OptionalFlag
OptionalFlag(const char *Representation)
Definition: FormatString.h:36
clang::analyze_format_string::OptionalFlag::setPosition
void setPosition(const char *position)
Definition: FormatString.h:41
clang::analyze_format_string::OptionalAmount::OptionalAmount
OptionalAmount(bool valid=true)
Definition: FormatString.h:323
clang::analyze_format_string::OptionalAmount::usesDotPrefix
bool usesDotPrefix() const
Definition: FormatString.h:370
clang::analyze_format_string::ConversionSpecifier::DArg
Definition: FormatString.h:128
clang::analyze_format_string::ConversionSpecifier::ScanListArg
Definition: FormatString.h:187
clang::analyze_format_string::ConversionSpecifier::xArg
Definition: FormatString.h:137
clang::analyze_format_string::ArgType::ArgType
ArgType(QualType T, const char *N=nullptr)
Definition: FormatString.h:269
clang::analyze_printf::PrintfSpecifier::setHasLeadingZeros
void setHasLeadingZeros(const char *position)
Definition: FormatString.h:530
clang::analyze_printf::PrintfSpecifier::usesPositionalArg
bool usesPositionalArg() const
Definition: FormatString.h:581
clang::analyze_format_string::LengthModifier::AsInt64
Definition: FormatString.h:79
clang::analyze_format_string::OptionalAmount::getStart
const char * getStart() const
Definition: FormatString.h:350
CanonicalType.h
clang::analyze_printf::PrintfSpecifier::hasThousandsGrouping
const OptionalFlag & hasThousandsGrouping() const
Definition: FormatString.h:569
clang::analyze_scanf::ScanfConversionSpecifier
Definition: FormatString.h:612
clang::analyze_format_string::ConversionSpecifier::kind
Kind kind
Definition: FormatString.h:246
clang::analyze_printf::PrintfConversionSpecifier::PrintfConversionSpecifier
PrintfConversionSpecifier(const char *pos, Kind k)
Definition: FormatString.h:468
clang::analyze_format_string::ConversionSpecifier::consumesDataArgument
bool consumesDataArgument() const
Definition: FormatString.h:207
clang::analyze_printf::PrintfConversionSpecifier::isObjCArg
bool isObjCArg() const
Definition: FormatString.h:471
clang::MultiVersionKind::Target
clang::analyze_scanf::ScanfConversionSpecifier::classof
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
Definition: FormatString.h:621
clang::analyze_format_string::FormatStringHandler::HandleEmptyObjCModifierFlag
virtual void HandleEmptyObjCModifierFlag(const char *startFlags, unsigned flagsLen)
Definition: FormatString.h:694
clang::analyze_format_string::OptionalAmount::getConstantAmount
unsigned getConstantAmount() const
Definition: FormatString.h:345
clang::analyze_format_string::ArgType::MatchKind
MatchKind
Definition: FormatString.h:254
clang::analyze_format_string::FormatSpecifier::getArgIndex
unsigned getArgIndex() const
Definition: FormatString.h:410
clang::analyze_printf::PrintfSpecifier::setPrecision
void setPrecision(const OptionalAmount &Amt)
Definition: FormatString.h:549
clang::analyze_format_string::OptionalAmount::getPositionalArgIndex
unsigned getPositionalArgIndex() const
Definition: FormatString.h:365
clang::analyze_format_string::ArgType::makeSizeT
static ArgType makeSizeT(const ArgType &A)
Create an ArgType which corresponds to the size_t/ssize_t type.
Definition: FormatString.h:288
clang::analyze_format_string::LengthModifier::AsLong
Definition: FormatString.h:71
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:155
llvm::Optional
Definition: LLVM.h:38
clang::analyze_format_string::ArgType
Definition: FormatString.h:249
clang::analyze_format_string::LengthModifier::LengthModifier
LengthModifier()
Definition: FormatString.h:87
clang::analyze_format_string::ConversionSpecifier::EndScanList
const char * EndScanList
Definition: FormatString.h:245
clang::analyze_format_string::ParseScanfString
bool ParseScanfString(FormatStringHandler &H, const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target)
Definition: ScanfFormatString.cpp:537
clang::analyze_printf::PrintfSpecifier::PrintfSpecifier
PrintfSpecifier()
Definition: FormatString.h:502
clang::analyze_printf::PrintfSpecifier::setHasSpacePrefix
void setHasSpacePrefix(const char *position)
Definition: FormatString.h:524
clang::analyze_format_string::ConversionSpecifier
Definition: FormatString.h:121
clang::analyze_format_string::LengthModifier::AsLongDouble
Definition: FormatString.h:80
clang::analyze_format_string::LengthModifier::AsMAllocate
Definition: FormatString.h:82
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
clang::analyze_printf::PrintfSpecifier::setConversionSpecifier
void setConversionSpecifier(const PrintfConversionSpecifier &cs)
Definition: FormatString.h:512
clang::analyze_format_string::FormatSpecifier::FieldWidth
OptionalAmount FieldWidth
Definition: FormatString.h:386
clang::analyze_format_string::FormatSpecifier::setFieldWidth
void setFieldWidth(const OptionalAmount &Amt)
Definition: FormatString.h:434
clang::analyze_format_string::FormatStringHandler::HandleInvalidPrintfConversionSpecifier
virtual bool HandleInvalidPrintfConversionSpecifier(const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:705
clang::analyze_format_string::LengthModifier::AsWide
Definition: FormatString.h:83
clang::analyze_format_string::ConversionSpecifier::AArg
Definition: FormatString.h:149
clang::analyze_format_string::FormatSpecifier::getPositionalArgIndex
unsigned getPositionalArgIndex() const
Definition: FormatString.h:414
clang::analyze_format_string::ConversionSpecifier::CArg
Definition: FormatString.h:157
clang::analyze_format_string::LengthModifier::AsLongLong
Definition: FormatString.h:72
clang::analyze_format_string::PrecisionPos
Definition: FormatString.h:675
clang::analyze_format_string::LengthModifier
Represents the length modifier in a format string in scanf/printf.
Definition: FormatString.h:65
clang::analyze_format_string::ConversionSpecifier::getCharacters
StringRef getCharacters() const
Definition: FormatString.h:203
clang::analyze_format_string::OptionalFlag::getPosition
const char * getPosition() const
Definition: FormatString.h:46
clang::analyze_format_string::ConversionSpecifier::cArg
Definition: FormatString.h:126
clang::analyze_format_string::OptionalAmount::hasDataArgument
bool hasDataArgument() const
Definition: FormatString.h:338
clang::analyze_format_string::FieldWidthPos
Definition: FormatString.h:675
clang::analyze_format_string::LengthModifier::getKind
Kind getKind() const
Definition: FormatString.h:111
clang::analyze_format_string::LengthModifier::AsQuad
Definition: FormatString.h:73
clang::analyze_format_string::ConversionSpecifier::FArg
Definition: FormatString.h:143
clang::analyze_format_string::FormatSpecifier::CS
ConversionSpecifier CS
Definition: FormatString.h:387
clang::analyze_format_string::ConversionSpecifier::FreeBSDrArg
Definition: FormatString.h:177
clang::analyze_scanf::ScanfSpecifier::ScanfSpecifier
ScanfSpecifier()
Definition: FormatString.h:634
clang::analyze_format_string::LengthModifier::AsInt3264
Definition: FormatString.h:78
clang::analyze_format_string::FormatSpecifier::usesPositionalArg
bool usesPositionalArg() const
Definition: FormatString.h:438
clang::analyze_printf::PrintfSpecifier::setIsLeftJustified
void setIsLeftJustified(const char *position)
Definition: FormatString.h:518
clang::analyze_format_string::LengthModifier::AsInt32
Definition: FormatString.h:77
clang::analyze_printf::PrintfSpecifier::setUsesPositionalArg
void setUsesPositionalArg()
Definition: FormatString.h:541
clang::analyze_format_string::FormatStringHandler::handleInvalidMaskType
virtual void handleInvalidMaskType(StringRef MaskType)
Handle mask types whose sizes are not between one and eight bytes.
Definition: FormatString.h:719
clang::analyze_format_string::ArgType::PtrTo
static ArgType PtrTo(const ArgType &A)
Create an ArgType which corresponds to the type pointer to A.
Definition: FormatString.h:280
clang::analyze_scanf::ScanfConversionSpecifier::ScanfConversionSpecifier
ScanfConversionSpecifier(const char *pos, Kind k)
Definition: FormatString.h:618
clang::analyze_printf::PrintfSpecifier::hasLeadingZeros
const OptionalFlag & hasLeadingZeros() const
Definition: FormatString.h:575
clang::analyze_printf::PrintfSpecifier::hasPlusPrefix
const OptionalFlag & hasPlusPrefix() const
Definition: FormatString.h:573
clang::analyze_format_string::ConversionSpecifier::fArg
Definition: FormatString.h:142
clang::analyze_format_string::LengthModifier::AsSizeT
Definition: FormatString.h:75
clang::analyze_format_string::ConversionSpecifier::nArg
Definition: FormatString.h:155
clang::analyze_format_string::ConversionSpecifier::PrintErrno
Definition: FormatString.h:181
clang::analyze_format_string::LengthModifier::None
Definition: FormatString.h:68
clang::analyze_format_string::ConversionSpecifier::Kind
Kind
Definition: FormatString.h:123
clang::analyze_format_string::LengthModifier::Kind
Kind
Definition: FormatString.h:67
clang::analyze_format_string::ArgType::isPtrdiffT
bool isPtrdiffT() const
Definition: FormatString.h:277
clang::analyze_format_string::ArgType::ArgType
ArgType(Kind K=UnknownTy, const char *N=nullptr)
Definition: FormatString.h:268
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:54
clang::analyze_printf::PrintfSpecifier::isLeftJustified
const OptionalFlag & isLeftJustified() const
Definition: FormatString.h:572
clang::analyze_format_string::ConversionSpecifier::pArg
Definition: FormatString.h:154
clang::analyze_format_string::LengthModifier::getStart
const char * getStart() const
Definition: FormatString.h:92
clang::analyze_format_string::ConversionSpecifier::PArg
Definition: FormatString.h:163
clang::analyze_format_string::ConversionSpecifier::ObjCObjArg
Definition: FormatString.h:170
clang::analyze_format_string::OptionalFlag::toString
const char * toString() const
Definition: FormatString.h:50
bool
#define bool
Definition: stdbool.h:31
clang::analyze_format_string::ConversionSpecifier::getLength
unsigned getLength() const
Definition: FormatString.h:223
clang::analyze_format_string::ConversionSpecifier::EArg
Definition: FormatString.h:145
clang::analyze_format_string::FormatSpecifier::getFieldWidth
const OptionalAmount & getFieldWidth() const
Definition: FormatString.h:422
clang::analyze_format_string::ArgType::Invalid
static ArgType Invalid()
Definition: FormatString.h:272
clang::analyze_format_string::FormatStringHandler::HandleNullChar
virtual void HandleNullChar(const char *nullCharacter)
Definition: FormatString.h:682
clang::analyze_format_string::FormatStringHandler
Definition: FormatString.h:677
clang::analyze_printf::PrintfSpecifier::isSensitive
const OptionalFlag & isSensitive() const
Definition: FormatString.h:580
clang::analyze_printf::PrintfConversionSpecifier
Definition: FormatString.h:462
clang::analyze_format_string::OptionalAmount
Definition: FormatString.h:311
clang::analyze_format_string::FormatSpecifier::setVectorNumElts
void setVectorNumElts(const OptionalAmount &Amt)
Definition: FormatString.h:426
length
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
clang::analyze_format_string::ConversionSpecifier::sArg
Definition: FormatString.h:153
clang::analyze_format_string::ArgType::Kind
Kind
Definition: FormatString.h:251
clang::analyze_format_string::FormatSpecifier::getLengthModifier
const LengthModifier & getLengthModifier() const
Definition: FormatString.h:418
clang::analyze_format_string::ConversionSpecifier::OArg
Definition: FormatString.h:134
clang::analyze_printf::PrintfConversionSpecifier::isDoubleArg
bool isDoubleArg() const
Definition: FormatString.h:472
clang::analyze_format_string::OptionalAmount::setHowSpecified
void setHowSpecified(HowSpecified h)
Definition: FormatString.h:336
clang::analyze_printf::PrintfSpecifier::getMaskType
StringRef getMaskType() const
Definition: FormatString.h:583
clang::analyze_format_string::OptionalAmount::usesPositionalArg
bool usesPositionalArg() const
Definition: FormatString.h:364
clang::analyze_format_string::ConversionSpecifier::uArg
Definition: FormatString.h:135
clang::analyze_format_string::OptionalAmount::NotSpecified
Definition: FormatString.h:313
clang::analyze_format_string::ParseFormatStringHasSArg
bool ParseFormatStringHasSArg(const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target)
Definition: PrintfFormatString.cpp:434
clang::analyze_format_string::FormatStringHandler::HandleObjCFlagsWithNonObjCConversion
virtual void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, const char *flagsEnd, const char *conversionPosition)
Definition: FormatString.h:700
false
#define false
Definition: stdbool.h:33
clang::analyze_format_string::OptionalFlag::clear
void clear()
Definition: FormatString.h:40
clang::analyze_format_string::OptionalAmount::isInvalid
bool isInvalid() const
Definition: FormatString.h:331
clang::analyze_printf::PrintfSpecifier::setMaskType
void setMaskType(StringRef S)
Definition: FormatString.h:584
clang::analyze_format_string::ConversionSpecifier::getStart
const char * getStart() const
Definition: FormatString.h:199
clang::analyze_format_string::LengthModifier::AsAllocate
Definition: FormatString.h:81
clang::analyze_format_string::FormatStringHandler::HandleInvalidPosition
virtual void HandleInvalidPosition(const char *startPos, unsigned posLen, PositionContext p)
Definition: FormatString.h:686
clang::analyze_printf::PrintfSpecifier::setIsPrivate
void setIsPrivate(const char *position)
Definition: FormatString.h:536
clang::analyze_format_string::LengthModifier::AsChar
Definition: FormatString.h:69
clang::analyze_format_string::ConversionSpecifier::Position
const char * Position
Definition: FormatString.h:244
clang::CanQual< Type >
clang::analyze_format_string::OptionalFlag
Class representing optional flags with location and representation information.
Definition: FormatString.h:34
clang::analyze_printf::PrintfSpecifier::setHasThousandsGrouping
void setHasThousandsGrouping(const char *position)
Definition: FormatString.h:515
clang::analyze_format_string::ArgType::isValid
bool isValid() const
Definition: FormatString.h:273
clang::analyze_scanf::ScanfSpecifier
Definition: FormatString.h:631
clang::analyze_scanf::ScanfSpecifier::setConversionSpecifier
void setConversionSpecifier(const ScanfConversionSpecifier &cs)
Definition: FormatString.h:646
clang::analyze_format_string::ConversionSpecifier::oArg
Definition: FormatString.h:133
clang::analyze_format_string::ConversionSpecifier::GArg
Definition: FormatString.h:147
clang::analyze_format_string::LengthModifier::getLength
unsigned getLength() const
Definition: FormatString.h:96
clang::analyze_format_string::OptionalAmount::HowSpecified
HowSpecified
Definition: FormatString.h:313
clang::analyze_printf::PrintfSpecifier
Definition: FormatString.h:485
clang::analyze_printf::PrintfSpecifier::getConversionSpecifier
const PrintfConversionSpecifier & getConversionSpecifier() const
Definition: FormatString.h:545
clang::analyze_format_string::FormatStringHandler::HandlePrintfSpecifier
virtual bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:712
clang::analyze_printf::PrintfSpecifier::hasObjCTechnicalTerm
const OptionalFlag & hasObjCTechnicalTerm() const
Definition: FormatString.h:577
clang::analyze_format_string::ConversionSpecifier::aArg
Definition: FormatString.h:148
clang::analyze_format_string::ArgType::UnknownTy
Definition: FormatString.h:251
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::analyze_scanf::ScanfSpecifier::setSuppressAssignment
void setSuppressAssignment(const char *position)
Definition: FormatString.h:638
clang::analyze_format_string::FormatSpecifier::getVectorNumElts
const OptionalAmount & getVectorNumElts() const
Definition: FormatString.h:430
clang::analyze_printf::PrintfConversionSpecifier::PrintfConversionSpecifier
PrintfConversionSpecifier()
Definition: FormatString.h:465
clang::analyze_format_string::ConversionSpecifier::getKind
Kind getKind() const
Definition: FormatString.h:221
clang::analyze_format_string::ConversionSpecifier::iArg
Definition: FormatString.h:129
clang::analyze_format_string::ConversionSpecifier::IsPrintf
bool IsPrintf
Definition: FormatString.h:243
clang::analyze_format_string::ConversionSpecifier::FreeBSDDArg
Definition: FormatString.h:176
clang::analyze_format_string::LengthModifier::setKind
void setKind(Kind k)
Definition: FormatString.h:112
clang::analyze_format_string::ConversionSpecifier::PercentArg
Definition: FormatString.h:156
clang::analyze_format_string::OptionalFlag::operator=
OptionalFlag & operator=(const bool &rhs)
Definition: FormatString.h:54
clang::analyze_format_string::FormatSpecifier::setArgIndex
void setArgIndex(unsigned i)
Definition: FormatString.h:406
clang::analyze_printf::PrintfSpecifier::isPrivate
const OptionalFlag & isPrivate() const
Definition: FormatString.h:578
clang::analyze_format_string::LengthModifier::AsPtrDiff
Definition: FormatString.h:76
clang::analyze_format_string::FormatSpecifier::VectorNumElts
OptionalAmount VectorNumElts
Definition: FormatString.h:388
clang::analyze_format_string::FormatSpecifier::argIndex
unsigned argIndex
Definition: FormatString.h:394
clang::analyze_format_string::ConversionSpecifier::UArg
Definition: FormatString.h:136
clang::analyze_format_string::OptionalAmount::setUsesDotPrefix
void setUsesDotPrefix()
Definition: FormatString.h:371
clang::analyze_format_string::OptionalAmount::OptionalAmount
OptionalAmount(HowSpecified howSpecified, unsigned amount, const char *amountStart, unsigned amountLength, bool usesPositionalArg)
Definition: FormatString.h:315
clang::analyze_printf::PrintfSpecifier::setHasObjCTechnicalTerm
void setHasObjCTechnicalTerm(const char *position)
Definition: FormatString.h:533
clang::analyze_format_string::OptionalAmount::getHowSpecified
HowSpecified getHowSpecified() const
Definition: FormatString.h:335
clang::analyze_printf::PrintfSpecifier::getPrecision
const OptionalAmount & getPrecision() const
Definition: FormatString.h:554
clang::analyze_printf::PrintfSpecifier::setHasPlusPrefix
void setHasPlusPrefix(const char *position)
Definition: FormatString.h:521
clang::analyze_format_string::LengthModifier::AsShort
Definition: FormatString.h:70
clang::analyze_format_string::LengthModifier::AsIntMax
Definition: FormatString.h:74
clang::analyze_printf::PrintfSpecifier::isPublic
const OptionalFlag & isPublic() const
Definition: FormatString.h:579
clang::analyze_format_string::ConversionSpecifier::eArg
Definition: FormatString.h:144
clang::analyze_printf::PrintfSpecifier::hasSpacePrefix
const OptionalFlag & hasSpacePrefix() const
Definition: FormatString.h:576
clang::analyze_format_string::OptionalAmount::getConstantLength
unsigned getConstantLength() const
Definition: FormatString.h:355
clang::analyze_format_string::ConversionSpecifier::ConversionSpecifier
ConversionSpecifier(bool isPrintf=true)
Definition: FormatString.h:192
clang::analyze_format_string::FormatStringHandler::FormatStringHandler
FormatStringHandler()
Definition: FormatString.h:679
clang::analyze_scanf::ScanfConversionSpecifier::ScanfConversionSpecifier
ScanfConversionSpecifier()
Definition: FormatString.h:615
clang::analyze_format_string::ConversionSpecifier::gArg
Definition: FormatString.h:146
clang::analyze_format_string::PositionContext
PositionContext
Definition: FormatString.h:675
clang::analyze_scanf::ScanfSpecifier::consumesDataArgument
bool consumesDataArgument() const
Definition: FormatString.h:654
clang::analyze_format_string::FormatStringHandler::HandleIncompleteSpecifier
virtual void HandleIncompleteSpecifier(const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:691
clang::diag::kind
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:61
clang::analyze_format_string::FormatSpecifier::UsesPositionalArg
bool UsesPositionalArg
Positional arguments, an IEEE extension: IEEE Std 1003.1, 2004 Edition http://www.opengroup.org/onlinepubs/009695399/functions/printf.html.
Definition: FormatString.h:393
clang::analyze_format_string::ConversionSpecifier::setEndScanList
void setEndScanList(const char *pos)
Definition: FormatString.h:226
clang::analyze_printf::PrintfConversionSpecifier::classof
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
Definition: FormatString.h:475
clang::analyze_format_string::ConversionSpecifier::setKind
void setKind(Kind k)
Definition: FormatString.h:222
clang::analyze_format_string::ConversionSpecifier::dArg
Definition: FormatString.h:127
clang::analyze_format_string::ConversionSpecifier::ConversionSpecifier
ConversionSpecifier(bool isPrintf, const char *pos, Kind k)
Definition: FormatString.h:196
clang::analyze_format_string::ConversionSpecifier::isUIntArg
bool isUIntArg() const
Definition: FormatString.h:230
clang::analyze_format_string::ParsePrintfString
bool ParsePrintfString(FormatStringHandler &H, const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target, bool isFreeBSDKPrintf)
Definition: PrintfFormatString.cpp:403
clang::analyze_printf::PrintfSpecifier::setHasAlternativeForm
void setHasAlternativeForm(const char *position)
Definition: FormatString.h:527
clang::analyze_format_string::OptionalAmount::getArgIndex
unsigned getArgIndex() const
Definition: FormatString.h:340
clang::analyze_format_string::ConversionSpecifier::isPrintfKind
bool isPrintfKind() const
Definition: FormatString.h:238
true
#define true
Definition: stdbool.h:32
clang::analyze_printf::PrintfSpecifier::setIsSensitive
void setIsSensitive(const char *position)
Definition: FormatString.h:538
clang::analyze_format_string::FormatSpecifier::setLengthModifier
void setLengthModifier(LengthModifier lm)
Definition: FormatString.h:400
clang::analyze_format_string::LengthModifier::LengthModifier
LengthModifier(const char *pos, Kind k)
Definition: FormatString.h:89
clang::analyze_format_string::FormatStringHandler::HandleIncompleteScanList
virtual void HandleIncompleteScanList(const char *start, const char *end)
Definition: FormatString.h:736
clang::analyze_format_string::ConversionSpecifier::isDoubleArg
bool isDoubleArg() const
Definition: FormatString.h:232
clang::analyze_format_string::FormatStringHandler::HandleInvalidScanfConversionSpecifier
virtual bool HandleInvalidScanfConversionSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:723
clang::analyze_format_string::ConversionSpecifier::isAnyIntArg
bool isAnyIntArg() const
Definition: FormatString.h:231
clang::analyze_format_string::FormatSpecifier
Definition: FormatString.h:383