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