clang  8.0.0svn
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 
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.
66 public:
67  enum Kind {
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 
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 
122 public:
123  enum Kind {
124  InvalidSpecifier = 0,
125  // C99 conversion specifiers.
128  DArg, // Apple extension
130  IntArgBeg = dArg,
131  IntArgEnd = iArg,
132 
134  OArg, // Apple extension
136  UArg, // Apple extension
139  UIntArgBeg = oArg,
140  UIntArgEnd = XArg,
141 
150  DoubleArgBeg = fArg,
151  DoubleArgEnd = AArg,
152 
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.
164 
165  // ** Printf-specific **
166 
167  ZArg, // MS extension
168 
169  VArg, // OpenCL vectors
170 
171  // Objective-C specific specifiers.
172  ObjCObjArg, // '@'
173  ObjCBeg = ObjCObjArg,
174  ObjCEnd = ObjCObjArg,
175 
176  // FreeBSD kernel specific specifiers.
181 
182  // GlibC specific specifiers.
183  PrintErrno, // 'm'
184 
185  PrintfConvBeg = ObjCObjArg,
186  PrintfConvEnd = PrintErrno,
187 
188  // ** Scanf-specific **
189  ScanListArg, // '['
190  ScanfConvBeg = ScanListArg,
191  ScanfConvEnd = ScanListArg
192  };
193 
194  ConversionSpecifier(bool isPrintf = true)
195  : IsPrintf(isPrintf), Position(nullptr), EndScanList(nullptr),
196  kind(InvalidSpecifier) {}
197 
198  ConversionSpecifier(bool isPrintf, const char *pos, Kind k)
199  : IsPrintf(isPrintf), Position(pos), EndScanList(nullptr), kind(k) {}
200 
201  const char *getStart() const {
202  return Position;
203  }
204 
205  StringRef getCharacters() const {
206  return StringRef(getStart(), getLength());
207  }
208 
209  bool consumesDataArgument() const {
210  switch (kind) {
211  case PrintErrno:
212  assert(IsPrintf);
213  return false;
214  case PercentArg:
215  return false;
216  case InvalidSpecifier:
217  return false;
218  default:
219  return true;
220  }
221  }
222 
223  Kind getKind() const { return kind; }
224  void setKind(Kind k) { kind = k; }
225  unsigned getLength() const {
226  return EndScanList ? EndScanList - Position : 1;
227  }
228  void setEndScanList(const char *pos) { EndScanList = pos; }
229 
230  bool isIntArg() const { return (kind >= IntArgBeg && kind <= IntArgEnd) ||
231  kind == FreeBSDrArg || kind == FreeBSDyArg; }
232  bool isUIntArg() const { return kind >= UIntArgBeg && kind <= UIntArgEnd; }
233  bool isAnyIntArg() const { return kind >= IntArgBeg && kind <= UIntArgEnd; }
234  bool isDoubleArg() const {
235  return kind >= DoubleArgBeg && kind <= DoubleArgEnd;
236  }
237 
238  const char *toString() const;
239 
240  bool isPrintfKind() const { return IsPrintf; }
241 
242  Optional<ConversionSpecifier> getStandardSpecifier() const;
243 
244 protected:
245  bool IsPrintf;
246  const char *Position;
247  const char *EndScanList;
249 };
250 
251 class ArgType {
252 public:
253  enum Kind { UnknownTy, InvalidTy, SpecificTy, ObjCPointerTy, CPointerTy,
254  AnyCharTy, CStrTy, WCStrTy, WIntTy };
255 
256  enum MatchKind { NoMatch = 0, Match = 1, NoMatchPedantic };
257 
258 private:
259  const Kind K;
260  QualType T;
261  const char *Name = nullptr;
262  bool Ptr = false;
263 
264  /// The TypeKind identifies certain well-known types like size_t and
265  /// ptrdiff_t.
266  enum class TypeKind { DontCare, SizeT, PtrdiffT };
267  TypeKind TK = TypeKind::DontCare;
268 
269 public:
270  ArgType(Kind K = UnknownTy, const char *N = nullptr) : K(K), Name(N) {}
271  ArgType(QualType T, const char *N = nullptr) : K(SpecificTy), T(T), Name(N) {}
272  ArgType(CanQualType T) : K(SpecificTy), T(T) {}
273 
274  static ArgType Invalid() { return ArgType(InvalidTy); }
275  bool isValid() const { return K != InvalidTy; }
276 
277  bool isSizeT() const { return TK == TypeKind::SizeT; }
278 
279  bool isPtrdiffT() const { return TK == TypeKind::PtrdiffT; }
280 
281  /// Create an ArgType which corresponds to the type pointer to A.
282  static ArgType PtrTo(const ArgType& A) {
283  assert(A.K >= InvalidTy && "ArgType cannot be pointer to invalid/unknown");
284  ArgType Res = A;
285  Res.Ptr = true;
286  return Res;
287  }
288 
289  /// Create an ArgType which corresponds to the size_t/ssize_t type.
290  static ArgType makeSizeT(const ArgType &A) {
291  ArgType Res = A;
292  Res.TK = TypeKind::SizeT;
293  return Res;
294  }
295 
296  /// Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t
297  /// type.
298  static ArgType makePtrdiffT(const ArgType &A) {
299  ArgType Res = A;
300  Res.TK = TypeKind::PtrdiffT;
301  return Res;
302  }
303 
304  MatchKind matchesType(ASTContext &C, QualType argTy) const;
305 
306  QualType getRepresentativeType(ASTContext &C) const;
307 
308  std::string getRepresentativeTypeName(ASTContext &C) const;
309 };
310 
312 public:
313  enum HowSpecified { NotSpecified, Constant, Arg, Invalid };
314 
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  bool isInvalid() const {
328  return hs == Invalid;
329  }
330 
331  HowSpecified getHowSpecified() const { return hs; }
332  void setHowSpecified(HowSpecified h) { hs = h; }
333 
334  bool hasDataArgument() const { return hs == Arg; }
335 
336  unsigned getArgIndex() const {
337  assert(hasDataArgument());
338  return amt;
339  }
340 
341  unsigned getConstantAmount() const {
342  assert(hs == Constant);
343  return amt;
344  }
345 
346  const char *getStart() const {
347  // We include the . character if it is given.
348  return start - UsesDotPrefix;
349  }
350 
351  unsigned getConstantLength() const {
352  assert(hs == Constant);
353  return length + UsesDotPrefix;
354  }
355 
356  ArgType getArgType(ASTContext &Ctx) const;
357 
358  void toString(raw_ostream &os) const;
359 
360  bool usesPositionalArg() const { return (bool) UsesPositionalArg; }
361  unsigned getPositionalArgIndex() const {
362  assert(hasDataArgument());
363  return amt + 1;
364  }
365 
366  bool usesDotPrefix() const { return UsesDotPrefix; }
367  void setUsesDotPrefix() { UsesDotPrefix = true; }
368 
369 private:
370  const char *start;
371  unsigned length;
372  HowSpecified hs;
373  unsigned amt;
374  bool UsesPositionalArg : 1;
375  bool UsesDotPrefix;
376 };
377 
378 
380 protected:
384  /// Positional arguments, an IEEE extension:
385  /// IEEE Std 1003.1, 2004 Edition
386  /// http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
388  unsigned argIndex;
389 public:
390  FormatSpecifier(bool isPrintf)
391  : CS(isPrintf), UsesPositionalArg(false), argIndex(0) {}
392 
394  LM = lm;
395  }
396 
397  void setUsesPositionalArg() { UsesPositionalArg = true; }
398 
399  void setArgIndex(unsigned i) {
400  argIndex = i;
401  }
402 
403  unsigned getArgIndex() const {
404  return argIndex;
405  }
406 
407  unsigned getPositionalArgIndex() const {
408  return argIndex + 1;
409  }
410 
412  return LM;
413  }
414 
415  const OptionalAmount &getFieldWidth() const {
416  return FieldWidth;
417  }
418 
419  void setFieldWidth(const OptionalAmount &Amt) {
420  FieldWidth = Amt;
421  }
422 
423  bool usesPositionalArg() const { return UsesPositionalArg; }
424 
425  bool hasValidLengthModifier(const TargetInfo &Target) const;
426 
427  bool hasStandardLengthModifier() const;
428 
429  Optional<LengthModifier> getCorrectedLengthModifier() const;
430 
431  bool hasStandardConversionSpecifier(const LangOptions &LangOpt) const;
432 
433  bool hasStandardLengthConversionCombination() const;
434 
435  /// For a TypedefType QT, if it is a named integer type such as size_t,
436  /// assign the appropriate value to LM and return true.
437  static bool namedTypeToLengthModifier(QualType QT, LengthModifier &LM);
438 };
439 
440 } // end analyze_format_string namespace
441 
442 //===----------------------------------------------------------------------===//
443 /// Pieces specific to fprintf format strings.
444 
445 namespace analyze_printf {
446 
449 public:
451  : ConversionSpecifier(true, nullptr, InvalidSpecifier) {}
452 
453  PrintfConversionSpecifier(const char *pos, Kind k)
454  : ConversionSpecifier(true, pos, k) {}
455 
456  bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; }
457  bool isDoubleArg() const { return kind >= DoubleArgBeg &&
458  kind <= DoubleArgEnd; }
459 
461  return CS->isPrintfKind();
462  }
463 };
464 
469 
471  OptionalFlag HasThousandsGrouping; // ''', POSIX extension.
472  OptionalFlag IsLeftJustified; // '-'
473  OptionalFlag HasPlusPrefix; // '+'
474  OptionalFlag HasSpacePrefix; // ' '
475  OptionalFlag HasAlternativeForm; // '#'
476  OptionalFlag HasLeadingZeroes; // '0'
477  OptionalFlag HasObjCTechnicalTerm; // '[tt]'
478  OptionalFlag IsPrivate; // '{private}'
479  OptionalFlag IsPublic; // '{public}'
480  OptionalFlag IsSensitive; // '{sensitive}'
481  OptionalAmount Precision;
482  StringRef MaskType;
483 public:
485  : FormatSpecifier(/* isPrintf = */ true), HasThousandsGrouping("'"),
486  IsLeftJustified("-"), HasPlusPrefix("+"), HasSpacePrefix(" "),
487  HasAlternativeForm("#"), HasLeadingZeroes("0"),
488  HasObjCTechnicalTerm("tt"), IsPrivate("private"), IsPublic("public"),
489  IsSensitive("sensitive") {}
490 
491  static PrintfSpecifier Parse(const char *beg, const char *end);
492 
493  // Methods for incrementally constructing the PrintfSpecifier.
495  CS = cs;
496  }
497  void setHasThousandsGrouping(const char *position) {
498  HasThousandsGrouping.setPosition(position);
499  }
500  void setIsLeftJustified(const char *position) {
501  IsLeftJustified.setPosition(position);
502  }
503  void setHasPlusPrefix(const char *position) {
504  HasPlusPrefix.setPosition(position);
505  }
506  void setHasSpacePrefix(const char *position) {
507  HasSpacePrefix.setPosition(position);
508  }
509  void setHasAlternativeForm(const char *position) {
510  HasAlternativeForm.setPosition(position);
511  }
512  void setHasLeadingZeros(const char *position) {
513  HasLeadingZeroes.setPosition(position);
514  }
515  void setHasObjCTechnicalTerm(const char *position) {
516  HasObjCTechnicalTerm.setPosition(position);
517  }
518  void setIsPrivate(const char *position) { IsPrivate.setPosition(position); }
519  void setIsPublic(const char *position) { IsPublic.setPosition(position); }
520  void setIsSensitive(const char *position) {
521  IsSensitive.setPosition(position);
522  }
523  void setUsesPositionalArg() { UsesPositionalArg = true; }
524 
525  // Methods for querying the format specifier.
526 
528  return cast<PrintfConversionSpecifier>(CS);
529  }
530 
531  void setPrecision(const OptionalAmount &Amt) {
532  Precision = Amt;
533  Precision.setUsesDotPrefix();
534  }
535 
536  const OptionalAmount &getPrecision() const {
537  return Precision;
538  }
539 
540  bool consumesDataArgument() const {
541  return getConversionSpecifier().consumesDataArgument();
542  }
543 
544  /// Returns the builtin type that a data argument
545  /// paired with this format specifier should have. This method
546  /// will return null if the format specifier does not have
547  /// a matching data argument or the matching argument matches
548  /// more than one type.
549  ArgType getArgType(ASTContext &Ctx, bool IsObjCLiteral) const;
550 
552  return HasThousandsGrouping;
553  }
554  const OptionalFlag &isLeftJustified() const { return IsLeftJustified; }
555  const OptionalFlag &hasPlusPrefix() const { return HasPlusPrefix; }
556  const OptionalFlag &hasAlternativeForm() const { return HasAlternativeForm; }
557  const OptionalFlag &hasLeadingZeros() const { return HasLeadingZeroes; }
558  const OptionalFlag &hasSpacePrefix() const { return HasSpacePrefix; }
559  const OptionalFlag &hasObjCTechnicalTerm() const { return HasObjCTechnicalTerm; }
560  const OptionalFlag &isPrivate() const { return IsPrivate; }
561  const OptionalFlag &isPublic() const { return IsPublic; }
562  const OptionalFlag &isSensitive() const { return IsSensitive; }
563  bool usesPositionalArg() const { return UsesPositionalArg; }
564 
565  StringRef getMaskType() const { return MaskType; }
566  void setMaskType(StringRef S) { MaskType = S; }
567 
568  /// Changes the specifier and length according to a QualType, retaining any
569  /// flags or options. Returns true on success, or false when a conversion
570  /// was not successful.
571  bool fixType(QualType QT, const LangOptions &LangOpt, ASTContext &Ctx,
572  bool IsObjCLiteral);
573 
574  void toString(raw_ostream &os) const;
575 
576  // Validation methods - to check if any element results in undefined behavior
577  bool hasValidPlusPrefix() const;
578  bool hasValidAlternativeForm() const;
579  bool hasValidLeadingZeros() const;
580  bool hasValidSpacePrefix() const;
581  bool hasValidLeftJustified() const;
582  bool hasValidThousandsGroupingPrefix() const;
583 
584  bool hasValidPrecision() const;
585  bool hasValidFieldWidth() const;
586 };
587 } // end analyze_printf namespace
588 
589 //===----------------------------------------------------------------------===//
590 /// Pieces specific to fscanf format strings.
591 
592 namespace analyze_scanf {
593 
596 public:
598  : ConversionSpecifier(false, nullptr, InvalidSpecifier) {}
599 
600  ScanfConversionSpecifier(const char *pos, Kind k)
601  : ConversionSpecifier(false, pos, k) {}
602 
604  return !CS->isPrintfKind();
605  }
606 };
607 
612 
614  OptionalFlag SuppressAssignment; // '*'
615 public:
617  FormatSpecifier(/* isPrintf = */ false),
618  SuppressAssignment("*") {}
619 
620  void setSuppressAssignment(const char *position) {
621  SuppressAssignment.setPosition(position);
622  }
623 
625  return SuppressAssignment;
626  }
627 
629  CS = cs;
630  }
631 
633  return cast<ScanfConversionSpecifier>(CS);
634  }
635 
636  bool consumesDataArgument() const {
637  return CS.consumesDataArgument() && !SuppressAssignment;
638  }
639 
640  ArgType getArgType(ASTContext &Ctx) const;
641 
642  bool fixType(QualType QT, QualType RawQT, const LangOptions &LangOpt,
643  ASTContext &Ctx);
644 
645  void toString(raw_ostream &os) const;
646 
647  static ScanfSpecifier Parse(const char *beg, const char *end);
648 };
649 
650 } // end analyze_scanf namespace
651 
652 //===----------------------------------------------------------------------===//
653 // Parsing and processing of format strings (both fprintf and fscanf).
654 
655 namespace analyze_format_string {
656 
658 
660 public:
662  virtual ~FormatStringHandler();
663 
664  virtual void HandleNullChar(const char *nullCharacter) {}
665 
666  virtual void HandlePosition(const char *startPos, unsigned posLen) {}
667 
668  virtual void HandleInvalidPosition(const char *startPos, unsigned posLen,
669  PositionContext p) {}
670 
671  virtual void HandleZeroPosition(const char *startPos, unsigned posLen) {}
672 
673  virtual void HandleIncompleteSpecifier(const char *startSpecifier,
674  unsigned specifierLen) {}
675 
676  virtual void HandleEmptyObjCModifierFlag(const char *startFlags,
677  unsigned flagsLen) {}
678 
679  virtual void HandleInvalidObjCModifierFlag(const char *startFlag,
680  unsigned flagLen) {}
681 
682  virtual void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart,
683  const char *flagsEnd,
684  const char *conversionPosition) {}
685  // Printf-specific handlers.
686 
689  const char *startSpecifier,
690  unsigned specifierLen) {
691  return true;
692  }
693 
695  const char *startSpecifier,
696  unsigned specifierLen) {
697  return true;
698  }
699 
700  /// Handle mask types whose sizes are not between one and eight bytes.
701  virtual void handleInvalidMaskType(StringRef MaskType) {}
702 
703  // Scanf-specific handlers.
704 
707  const char *startSpecifier,
708  unsigned specifierLen) {
709  return true;
710  }
711 
713  const char *startSpecifier,
714  unsigned specifierLen) {
715  return true;
716  }
717 
718  virtual void HandleIncompleteScanList(const char *start, const char *end) {}
719 };
720 
722  const char *beg, const char *end, const LangOptions &LO,
723  const TargetInfo &Target, bool isFreeBSDKPrintf);
724 
725 bool ParseFormatStringHasSArg(const char *beg, const char *end,
726  const LangOptions &LO, const TargetInfo &Target);
727 
729  const char *beg, const char *end, const LangOptions &LO,
730  const TargetInfo &Target);
731 
732 } // end analyze_format_string namespace
733 } // end clang namespace
734 #endif
const OptionalFlag & hasAlternativeForm() const
Definition: FormatString.h:556
virtual void HandlePosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:666
static ArgType makePtrdiffT(const ArgType &A)
Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t type.
Definition: FormatString.h:298
virtual bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:712
A (possibly-)qualified type.
Definition: Type.h:642
const ScanfConversionSpecifier & getConversionSpecifier() const
Definition: FormatString.h:632
void setIsPublic(const char *position)
Definition: FormatString.h:519
const OptionalFlag & getSuppressAssignment() const
Definition: FormatString.h:624
virtual void HandleInvalidObjCModifierFlag(const char *startFlag, unsigned flagLen)
Definition: FormatString.h:679
virtual void HandleZeroPosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:671
OptionalFlag(const char *Representation)
Definition: FormatString.h:36
void setPosition(const char *position)
Definition: FormatString.h:41
ArgType(QualType T, const char *N=nullptr)
Definition: FormatString.h:271
void setHasLeadingZeros(const char *position)
Definition: FormatString.h:512
const OptionalFlag & hasThousandsGrouping() const
Definition: FormatString.h:551
PrintfConversionSpecifier(const char *pos, Kind k)
Definition: FormatString.h:453
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
Definition: FormatString.h:603
virtual void HandleEmptyObjCModifierFlag(const char *startFlags, unsigned flagsLen)
Definition: FormatString.h:676
void setPrecision(const OptionalAmount &Amt)
Definition: FormatString.h:531
static ArgType makeSizeT(const ArgType &A)
Create an ArgType which corresponds to the size_t/ssize_t type.
Definition: FormatString.h:290
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
bool ParseScanfString(FormatStringHandler &H, const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target)
void setHasSpacePrefix(const char *position)
Definition: FormatString.h:506
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
void setConversionSpecifier(const PrintfConversionSpecifier &cs)
Definition: FormatString.h:494
void setFieldWidth(const OptionalAmount &Amt)
Definition: FormatString.h:419
virtual bool HandleInvalidPrintfConversionSpecifier(const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:687
Represents the length modifier in a format string in scanf/printf.
Definition: FormatString.h:65
void setIsLeftJustified(const char *position)
Definition: FormatString.h:500
virtual void handleInvalidMaskType(StringRef MaskType)
Handle mask types whose sizes are not between one and eight bytes.
Definition: FormatString.h:701
static ArgType PtrTo(const ArgType &A)
Create an ArgType which corresponds to the type pointer to A.
Definition: FormatString.h:282
ScanfConversionSpecifier(const char *pos, Kind k)
Definition: FormatString.h:600
const OptionalFlag & hasLeadingZeros() const
Definition: FormatString.h:557
const OptionalFlag & hasPlusPrefix() const
Definition: FormatString.h:555
ArgType(Kind K=UnknownTy, const char *N=nullptr)
Definition: FormatString.h:270
Exposes information about the current target.
Definition: TargetInfo.h:54
const OptionalFlag & isLeftJustified() const
Definition: FormatString.h:554
#define bool
Definition: stdbool.h:31
const OptionalAmount & getFieldWidth() const
Definition: FormatString.h:415
virtual void HandleNullChar(const char *nullCharacter)
Definition: FormatString.h:664
const OptionalFlag & isSensitive() const
Definition: FormatString.h:562
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
const LengthModifier & getLengthModifier() const
Definition: FormatString.h:411
bool ParseFormatStringHasSArg(const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target)
virtual void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, const char *flagsEnd, const char *conversionPosition)
Definition: FormatString.h:682
#define false
Definition: stdbool.h:33
virtual void HandleInvalidPosition(const char *startPos, unsigned posLen, PositionContext p)
Definition: FormatString.h:668
void setIsPrivate(const char *position)
Definition: FormatString.h:518
Class representing optional flags with location and representation information.
Definition: FormatString.h:34
void setHasThousandsGrouping(const char *position)
Definition: FormatString.h:497
void setConversionSpecifier(const ScanfConversionSpecifier &cs)
Definition: FormatString.h:628
const PrintfConversionSpecifier & getConversionSpecifier() const
Definition: FormatString.h:527
virtual bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:694
const OptionalFlag & hasObjCTechnicalTerm() const
Definition: FormatString.h:559
Dataflow Directional Tag Classes.
void setSuppressAssignment(const char *position)
Definition: FormatString.h:620
OptionalFlag & operator=(const bool &rhs)
Definition: FormatString.h:54
const OptionalFlag & isPrivate() const
Definition: FormatString.h:560
OptionalAmount(HowSpecified howSpecified, unsigned amount, const char *amountStart, unsigned amountLength, bool usesPositionalArg)
Definition: FormatString.h:315
void setHasObjCTechnicalTerm(const char *position)
Definition: FormatString.h:515
const OptionalAmount & getPrecision() const
Definition: FormatString.h:536
void setHasPlusPrefix(const char *position)
Definition: FormatString.h:503
const OptionalFlag & isPublic() const
Definition: FormatString.h:561
const OptionalFlag & hasSpacePrefix() const
Definition: FormatString.h:558
virtual void HandleIncompleteSpecifier(const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:673
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:61
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:387
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
Definition: FormatString.h:460
ConversionSpecifier(bool isPrintf, const char *pos, Kind k)
Definition: FormatString.h:198
bool ParsePrintfString(FormatStringHandler &H, const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target, bool isFreeBSDKPrintf)
void setHasAlternativeForm(const char *position)
Definition: FormatString.h:509
#define true
Definition: stdbool.h:32
void setIsSensitive(const char *position)
Definition: FormatString.h:520
virtual void HandleIncompleteScanList(const char *start, const char *end)
Definition: FormatString.h:718
virtual bool HandleInvalidScanfConversionSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:705