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  // Objective-C specific specifiers.
170  ObjCObjArg, // '@'
171  ObjCBeg = ObjCObjArg,
172  ObjCEnd = ObjCObjArg,
173 
174  // FreeBSD kernel specific specifiers.
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;
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  std::string getRepresentativeTypeName(ASTContext &C) const;
307 };
308 
310 public:
311  enum HowSpecified { NotSpecified, Constant, Arg, Invalid };
312 
314  unsigned amount,
315  const char *amountStart,
316  unsigned amountLength,
317  bool usesPositionalArg)
318  : start(amountStart), length(amountLength), hs(howSpecified), amt(amount),
319  UsesPositionalArg(usesPositionalArg), UsesDotPrefix(0) {}
320 
321  OptionalAmount(bool valid = true)
322  : start(nullptr),length(0), hs(valid ? NotSpecified : Invalid), amt(0),
323  UsesPositionalArg(0), UsesDotPrefix(0) {}
324 
325  bool isInvalid() const {
326  return hs == Invalid;
327  }
328 
329  HowSpecified getHowSpecified() const { return hs; }
330  void setHowSpecified(HowSpecified h) { hs = h; }
331 
332  bool hasDataArgument() const { return hs == Arg; }
333 
334  unsigned getArgIndex() const {
335  assert(hasDataArgument());
336  return amt;
337  }
338 
339  unsigned getConstantAmount() const {
340  assert(hs == Constant);
341  return amt;
342  }
343 
344  const char *getStart() const {
345  // We include the . character if it is given.
346  return start - UsesDotPrefix;
347  }
348 
349  unsigned getConstantLength() const {
350  assert(hs == Constant);
351  return length + UsesDotPrefix;
352  }
353 
354  ArgType getArgType(ASTContext &Ctx) const;
355 
356  void toString(raw_ostream &os) const;
357 
358  bool usesPositionalArg() const { return (bool) UsesPositionalArg; }
359  unsigned getPositionalArgIndex() const {
360  assert(hasDataArgument());
361  return amt + 1;
362  }
363 
364  bool usesDotPrefix() const { return UsesDotPrefix; }
365  void setUsesDotPrefix() { UsesDotPrefix = true; }
366 
367 private:
368  const char *start;
369  unsigned length;
370  HowSpecified hs;
371  unsigned amt;
372  bool UsesPositionalArg : 1;
373  bool UsesDotPrefix;
374 };
375 
376 
378 protected:
382  /// Positional arguments, an IEEE extension:
383  /// IEEE Std 1003.1, 2004 Edition
384  /// http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
386  unsigned argIndex;
387 public:
388  FormatSpecifier(bool isPrintf)
389  : CS(isPrintf), UsesPositionalArg(false), argIndex(0) {}
390 
392  LM = lm;
393  }
394 
395  void setUsesPositionalArg() { UsesPositionalArg = true; }
396 
397  void setArgIndex(unsigned i) {
398  argIndex = i;
399  }
400 
401  unsigned getArgIndex() const {
402  return argIndex;
403  }
404 
405  unsigned getPositionalArgIndex() const {
406  return argIndex + 1;
407  }
408 
410  return LM;
411  }
412 
413  const OptionalAmount &getFieldWidth() const {
414  return FieldWidth;
415  }
416 
417  void setFieldWidth(const OptionalAmount &Amt) {
418  FieldWidth = Amt;
419  }
420 
421  bool usesPositionalArg() const { return UsesPositionalArg; }
422 
423  bool hasValidLengthModifier(const TargetInfo &Target) const;
424 
425  bool hasStandardLengthModifier() const;
426 
427  Optional<LengthModifier> getCorrectedLengthModifier() const;
428 
429  bool hasStandardConversionSpecifier(const LangOptions &LangOpt) const;
430 
431  bool hasStandardLengthConversionCombination() const;
432 
433  /// For a TypedefType QT, if it is a named integer type such as size_t,
434  /// assign the appropriate value to LM and return true.
435  static bool namedTypeToLengthModifier(QualType QT, LengthModifier &LM);
436 };
437 
438 } // end analyze_format_string namespace
439 
440 //===----------------------------------------------------------------------===//
441 /// Pieces specific to fprintf format strings.
442 
443 namespace analyze_printf {
444 
447 public:
449  : ConversionSpecifier(true, nullptr, InvalidSpecifier) {}
450 
451  PrintfConversionSpecifier(const char *pos, Kind k)
452  : ConversionSpecifier(true, pos, k) {}
453 
454  bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; }
455  bool isDoubleArg() const { return kind >= DoubleArgBeg &&
456  kind <= DoubleArgEnd; }
457 
459  return CS->isPrintfKind();
460  }
461 };
462 
467 
469  OptionalFlag HasThousandsGrouping; // ''', POSIX extension.
470  OptionalFlag IsLeftJustified; // '-'
471  OptionalFlag HasPlusPrefix; // '+'
472  OptionalFlag HasSpacePrefix; // ' '
473  OptionalFlag HasAlternativeForm; // '#'
474  OptionalFlag HasLeadingZeroes; // '0'
475  OptionalFlag HasObjCTechnicalTerm; // '[tt]'
476  OptionalFlag IsPrivate; // '{private}'
477  OptionalFlag IsPublic; // '{public}'
478  OptionalAmount Precision;
479 public:
481  : FormatSpecifier(/* isPrintf = */ true), HasThousandsGrouping("'"),
482  IsLeftJustified("-"), HasPlusPrefix("+"), HasSpacePrefix(" "),
483  HasAlternativeForm("#"), HasLeadingZeroes("0"),
484  HasObjCTechnicalTerm("tt"), IsPrivate("private"), IsPublic("public") {}
485 
486  static PrintfSpecifier Parse(const char *beg, const char *end);
487 
488  // Methods for incrementally constructing the PrintfSpecifier.
490  CS = cs;
491  }
492  void setHasThousandsGrouping(const char *position) {
493  HasThousandsGrouping.setPosition(position);
494  }
495  void setIsLeftJustified(const char *position) {
496  IsLeftJustified.setPosition(position);
497  }
498  void setHasPlusPrefix(const char *position) {
499  HasPlusPrefix.setPosition(position);
500  }
501  void setHasSpacePrefix(const char *position) {
502  HasSpacePrefix.setPosition(position);
503  }
504  void setHasAlternativeForm(const char *position) {
505  HasAlternativeForm.setPosition(position);
506  }
507  void setHasLeadingZeros(const char *position) {
508  HasLeadingZeroes.setPosition(position);
509  }
510  void setHasObjCTechnicalTerm(const char *position) {
511  HasObjCTechnicalTerm.setPosition(position);
512  }
513  void setIsPrivate(const char *position) { IsPrivate.setPosition(position); }
514  void setIsPublic(const char *position) { IsPublic.setPosition(position); }
515  void setUsesPositionalArg() { UsesPositionalArg = true; }
516 
517  // Methods for querying the format specifier.
518 
520  return cast<PrintfConversionSpecifier>(CS);
521  }
522 
523  void setPrecision(const OptionalAmount &Amt) {
524  Precision = Amt;
525  Precision.setUsesDotPrefix();
526  }
527 
528  const OptionalAmount &getPrecision() const {
529  return Precision;
530  }
531 
532  bool consumesDataArgument() const {
533  return getConversionSpecifier().consumesDataArgument();
534  }
535 
536  /// Returns the builtin type that a data argument
537  /// paired with this format specifier should have. This method
538  /// will return null if the format specifier does not have
539  /// a matching data argument or the matching argument matches
540  /// more than one type.
541  ArgType getArgType(ASTContext &Ctx, bool IsObjCLiteral) const;
542 
544  return HasThousandsGrouping;
545  }
546  const OptionalFlag &isLeftJustified() const { return IsLeftJustified; }
547  const OptionalFlag &hasPlusPrefix() const { return HasPlusPrefix; }
548  const OptionalFlag &hasAlternativeForm() const { return HasAlternativeForm; }
549  const OptionalFlag &hasLeadingZeros() const { return HasLeadingZeroes; }
550  const OptionalFlag &hasSpacePrefix() const { return HasSpacePrefix; }
551  const OptionalFlag &hasObjCTechnicalTerm() const { return HasObjCTechnicalTerm; }
552  const OptionalFlag &isPrivate() const { return IsPrivate; }
553  const OptionalFlag &isPublic() const { return IsPublic; }
554  bool usesPositionalArg() const { return UsesPositionalArg; }
555 
556  /// Changes the specifier and length according to a QualType, retaining any
557  /// flags or options. Returns true on success, or false when a conversion
558  /// was not successful.
559  bool fixType(QualType QT, const LangOptions &LangOpt, ASTContext &Ctx,
560  bool IsObjCLiteral);
561 
562  void toString(raw_ostream &os) const;
563 
564  // Validation methods - to check if any element results in undefined behavior
565  bool hasValidPlusPrefix() const;
566  bool hasValidAlternativeForm() const;
567  bool hasValidLeadingZeros() const;
568  bool hasValidSpacePrefix() const;
569  bool hasValidLeftJustified() const;
570  bool hasValidThousandsGroupingPrefix() const;
571 
572  bool hasValidPrecision() const;
573  bool hasValidFieldWidth() const;
574 };
575 } // end analyze_printf namespace
576 
577 //===----------------------------------------------------------------------===//
578 /// Pieces specific to fscanf format strings.
579 
580 namespace analyze_scanf {
581 
584 public:
586  : ConversionSpecifier(false, nullptr, InvalidSpecifier) {}
587 
588  ScanfConversionSpecifier(const char *pos, Kind k)
589  : ConversionSpecifier(false, pos, k) {}
590 
592  return !CS->isPrintfKind();
593  }
594 };
595 
600 
602  OptionalFlag SuppressAssignment; // '*'
603 public:
605  FormatSpecifier(/* isPrintf = */ false),
606  SuppressAssignment("*") {}
607 
608  void setSuppressAssignment(const char *position) {
609  SuppressAssignment.setPosition(position);
610  }
611 
613  return SuppressAssignment;
614  }
615 
617  CS = cs;
618  }
619 
621  return cast<ScanfConversionSpecifier>(CS);
622  }
623 
624  bool consumesDataArgument() const {
625  return CS.consumesDataArgument() && !SuppressAssignment;
626  }
627 
628  ArgType getArgType(ASTContext &Ctx) const;
629 
630  bool fixType(QualType QT, QualType RawQT, const LangOptions &LangOpt,
631  ASTContext &Ctx);
632 
633  void toString(raw_ostream &os) const;
634 
635  static ScanfSpecifier Parse(const char *beg, const char *end);
636 };
637 
638 } // end analyze_scanf namespace
639 
640 //===----------------------------------------------------------------------===//
641 // Parsing and processing of format strings (both fprintf and fscanf).
642 
643 namespace analyze_format_string {
644 
646 
648 public:
650  virtual ~FormatStringHandler();
651 
652  virtual void HandleNullChar(const char *nullCharacter) {}
653 
654  virtual void HandlePosition(const char *startPos, unsigned posLen) {}
655 
656  virtual void HandleInvalidPosition(const char *startPos, unsigned posLen,
657  PositionContext p) {}
658 
659  virtual void HandleZeroPosition(const char *startPos, unsigned posLen) {}
660 
661  virtual void HandleIncompleteSpecifier(const char *startSpecifier,
662  unsigned specifierLen) {}
663 
664  virtual void HandleEmptyObjCModifierFlag(const char *startFlags,
665  unsigned flagsLen) {}
666 
667  virtual void HandleInvalidObjCModifierFlag(const char *startFlag,
668  unsigned flagLen) {}
669 
670  virtual void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart,
671  const char *flagsEnd,
672  const char *conversionPosition) {}
673  // Printf-specific handlers.
674 
677  const char *startSpecifier,
678  unsigned specifierLen) {
679  return true;
680  }
681 
683  const char *startSpecifier,
684  unsigned specifierLen) {
685  return true;
686  }
687 
688  // Scanf-specific handlers.
689 
692  const char *startSpecifier,
693  unsigned specifierLen) {
694  return true;
695  }
696 
698  const char *startSpecifier,
699  unsigned specifierLen) {
700  return true;
701  }
702 
703  virtual void HandleIncompleteScanList(const char *start, const char *end) {}
704 };
705 
707  const char *beg, const char *end, const LangOptions &LO,
708  const TargetInfo &Target, bool isFreeBSDKPrintf);
709 
710 bool ParseFormatStringHasSArg(const char *beg, const char *end,
711  const LangOptions &LO, const TargetInfo &Target);
712 
714  const char *beg, const char *end, const LangOptions &LO,
715  const TargetInfo &Target);
716 
717 } // end analyze_format_string namespace
718 } // end clang namespace
719 #endif
const OptionalFlag & hasAlternativeForm() const
Definition: FormatString.h:548
virtual void HandlePosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:654
static ArgType makePtrdiffT(const ArgType &A)
Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t type.
Definition: FormatString.h:296
virtual bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:697
A (possibly-)qualified type.
Definition: Type.h:642
const ScanfConversionSpecifier & getConversionSpecifier() const
Definition: FormatString.h:620
void setIsPublic(const char *position)
Definition: FormatString.h:514
const OptionalFlag & getSuppressAssignment() const
Definition: FormatString.h:612
virtual void HandleInvalidObjCModifierFlag(const char *startFlag, unsigned flagLen)
Definition: FormatString.h:667
virtual void HandleZeroPosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:659
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:269
void setHasLeadingZeros(const char *position)
Definition: FormatString.h:507
const OptionalFlag & hasThousandsGrouping() const
Definition: FormatString.h:543
PrintfConversionSpecifier(const char *pos, Kind k)
Definition: FormatString.h:451
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
Definition: FormatString.h:591
virtual void HandleEmptyObjCModifierFlag(const char *startFlags, unsigned flagsLen)
Definition: FormatString.h:664
void setPrecision(const OptionalAmount &Amt)
Definition: FormatString.h:523
static ArgType makeSizeT(const ArgType &A)
Create an ArgType which corresponds to the size_t/ssize_t type.
Definition: FormatString.h:288
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:501
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:489
void setFieldWidth(const OptionalAmount &Amt)
Definition: FormatString.h:417
virtual bool HandleInvalidPrintfConversionSpecifier(const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:675
Represents the length modifier in a format string in scanf/printf.
Definition: FormatString.h:65
void setIsLeftJustified(const char *position)
Definition: FormatString.h:495
static ArgType PtrTo(const ArgType &A)
Create an ArgType which corresponds to the type pointer to A.
Definition: FormatString.h:280
ScanfConversionSpecifier(const char *pos, Kind k)
Definition: FormatString.h:588
const OptionalFlag & hasLeadingZeros() const
Definition: FormatString.h:549
const OptionalFlag & hasPlusPrefix() const
Definition: FormatString.h:547
ArgType(Kind K=UnknownTy, const char *N=nullptr)
Definition: FormatString.h:268
Exposes information about the current target.
Definition: TargetInfo.h:54
const OptionalFlag & isLeftJustified() const
Definition: FormatString.h:546
#define bool
Definition: stdbool.h:31
const OptionalAmount & getFieldWidth() const
Definition: FormatString.h:413
virtual void HandleNullChar(const char *nullCharacter)
Definition: FormatString.h:652
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:409
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:670
#define false
Definition: stdbool.h:33
virtual void HandleInvalidPosition(const char *startPos, unsigned posLen, PositionContext p)
Definition: FormatString.h:656
void setIsPrivate(const char *position)
Definition: FormatString.h:513
Class representing optional flags with location and representation information.
Definition: FormatString.h:34
void setHasThousandsGrouping(const char *position)
Definition: FormatString.h:492
void setConversionSpecifier(const ScanfConversionSpecifier &cs)
Definition: FormatString.h:616
const PrintfConversionSpecifier & getConversionSpecifier() const
Definition: FormatString.h:519
virtual bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:682
const OptionalFlag & hasObjCTechnicalTerm() const
Definition: FormatString.h:551
Dataflow Directional Tag Classes.
void setSuppressAssignment(const char *position)
Definition: FormatString.h:608
OptionalFlag & operator=(const bool &rhs)
Definition: FormatString.h:54
const OptionalFlag & isPrivate() const
Definition: FormatString.h:552
OptionalAmount(HowSpecified howSpecified, unsigned amount, const char *amountStart, unsigned amountLength, bool usesPositionalArg)
Definition: FormatString.h:313
void setHasObjCTechnicalTerm(const char *position)
Definition: FormatString.h:510
const OptionalAmount & getPrecision() const
Definition: FormatString.h:528
void setHasPlusPrefix(const char *position)
Definition: FormatString.h:498
const OptionalFlag & isPublic() const
Definition: FormatString.h:553
const OptionalFlag & hasSpacePrefix() const
Definition: FormatString.h:550
virtual void HandleIncompleteSpecifier(const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:661
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:385
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
Definition: FormatString.h:458
ConversionSpecifier(bool isPrintf, const char *pos, Kind k)
Definition: FormatString.h:196
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:504
#define true
Definition: stdbool.h:32
virtual void HandleIncompleteScanList(const char *start, const char *end)
Definition: FormatString.h:703
virtual bool HandleInvalidScanfConversionSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:690