clang  16.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_AST_FORMATSTRING_H
19 #define LLVM_CLANG_AST_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
130  // C23 conversion specifiers.
133 
136 
138  OArg, // Apple extension
140  UArg, // Apple extension
145 
156 
163 
164  // Apple extension: P specifies to os_log that the data being pointed to is
165  // to be copied by os_log. The precision indicates the number of bytes to
166  // copy.
168 
169  // ** Printf-specific **
170 
171  ZArg, // MS extension
172 
173  // Objective-C specific specifiers.
174  ObjCObjArg, // '@'
177 
178  // FreeBSD kernel specific specifiers.
183 
184  // GlibC specific specifiers.
185  PrintErrno, // 'm'
186 
189 
190  // ** Scanf-specific **
191  ScanListArg, // '['
194  };
195 
196  ConversionSpecifier(bool isPrintf = true)
197  : IsPrintf(isPrintf), Position(nullptr), EndScanList(nullptr),
199 
200  ConversionSpecifier(bool isPrintf, const char *pos, Kind k)
201  : IsPrintf(isPrintf), Position(pos), EndScanList(nullptr), kind(k) {}
202 
203  const char *getStart() const {
204  return Position;
205  }
206 
207  StringRef getCharacters() const {
208  return StringRef(getStart(), getLength());
209  }
210 
211  bool consumesDataArgument() const {
212  switch (kind) {
213  case PrintErrno:
214  assert(IsPrintf);
215  return false;
216  case PercentArg:
217  return false;
218  case InvalidSpecifier:
219  return false;
220  default:
221  return true;
222  }
223  }
224 
225  Kind getKind() const { return kind; }
226  void setKind(Kind k) { kind = k; }
227  unsigned getLength() const {
228  return EndScanList ? EndScanList - Position : 1;
229  }
230  void setEndScanList(const char *pos) { EndScanList = pos; }
231 
232  bool isIntArg() const { return (kind >= IntArgBeg && kind <= IntArgEnd) ||
233  kind == FreeBSDrArg || kind == FreeBSDyArg; }
234  bool isUIntArg() const { return kind >= UIntArgBeg && kind <= UIntArgEnd; }
235  bool isAnyIntArg() const { return kind >= IntArgBeg && kind <= UIntArgEnd; }
236  bool isDoubleArg() const {
237  return kind >= DoubleArgBeg && kind <= DoubleArgEnd;
238  }
239 
240  const char *toString() const;
241 
242  bool isPrintfKind() const { return IsPrintf; }
243 
245 
246 protected:
247  bool IsPrintf;
248  const char *Position;
249  const char *EndScanList;
251 };
252 
253 class ArgType {
254 public:
257 
258  /// How well a given conversion specifier matches its argument.
259  enum MatchKind {
260  /// The conversion specifier and the argument types are incompatible. For
261  /// instance, "%d" and float.
262  NoMatch = 0,
263  /// The conversion specifier and the argument type are compatible. For
264  /// instance, "%d" and int.
265  Match = 1,
266  /// The conversion specifier and the argument type are compatible because of
267  /// default argument promotions. For instance, "%hhd" and int.
269  /// The conversion specifier and the argument type are compatible but still
270  /// seems likely to be an error. For instanace, "%hhd" and short.
272  /// The conversion specifier and the argument type are disallowed by the C
273  /// standard, but are in practice harmless. For instance, "%p" and int*.
275  /// The conversion specifier and the argument type are compatible, but still
276  /// seems likely to be an error. For instance, "%hd" and _Bool.
278  };
279 
280 private:
281  const Kind K;
282  QualType T;
283  const char *Name = nullptr;
284  bool Ptr = false;
285 
286  /// The TypeKind identifies certain well-known types like size_t and
287  /// ptrdiff_t.
288  enum class TypeKind { DontCare, SizeT, PtrdiffT };
289  TypeKind TK = TypeKind::DontCare;
290 
291 public:
292  ArgType(Kind K = UnknownTy, const char *N = nullptr) : K(K), Name(N) {}
293  ArgType(QualType T, const char *N = nullptr) : K(SpecificTy), T(T), Name(N) {}
294  ArgType(CanQualType T) : K(SpecificTy), T(T) {}
295 
296  static ArgType Invalid() { return ArgType(InvalidTy); }
297  bool isValid() const { return K != InvalidTy; }
298 
299  bool isSizeT() const { return TK == TypeKind::SizeT; }
300 
301  bool isPtrdiffT() const { return TK == TypeKind::PtrdiffT; }
302 
303  /// Create an ArgType which corresponds to the type pointer to A.
304  static ArgType PtrTo(const ArgType& A) {
305  assert(A.K >= InvalidTy && "ArgType cannot be pointer to invalid/unknown");
306  ArgType Res = A;
307  Res.Ptr = true;
308  return Res;
309  }
310 
311  /// Create an ArgType which corresponds to the size_t/ssize_t type.
312  static ArgType makeSizeT(const ArgType &A) {
313  ArgType Res = A;
314  Res.TK = TypeKind::SizeT;
315  return Res;
316  }
317 
318  /// Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t
319  /// type.
320  static ArgType makePtrdiffT(const ArgType &A) {
321  ArgType Res = A;
322  Res.TK = TypeKind::PtrdiffT;
323  return Res;
324  }
325 
326  MatchKind matchesType(ASTContext &C, QualType argTy) const;
327 
329 
330  ArgType makeVectorType(ASTContext &C, unsigned NumElts) const;
331 
333 };
334 
336 public:
338 
340  unsigned amount,
341  const char *amountStart,
342  unsigned amountLength,
343  bool usesPositionalArg)
344  : start(amountStart), length(amountLength), hs(howSpecified), amt(amount),
345  UsesPositionalArg(usesPositionalArg), UsesDotPrefix(false) {}
346 
347  OptionalAmount(bool valid = true)
348  : start(nullptr),length(0), hs(valid ? NotSpecified : Invalid), amt(0),
349  UsesPositionalArg(false), UsesDotPrefix(false) {}
350 
351  explicit OptionalAmount(unsigned Amount)
352  : start(nullptr), length(0), hs(Constant), amt(Amount),
353  UsesPositionalArg(false), UsesDotPrefix(false) {}
354 
355  bool isInvalid() const {
356  return hs == Invalid;
357  }
358 
359  HowSpecified getHowSpecified() const { return hs; }
360  void setHowSpecified(HowSpecified h) { hs = h; }
361 
362  bool hasDataArgument() const { return hs == Arg; }
363 
364  unsigned getArgIndex() const {
365  assert(hasDataArgument());
366  return amt;
367  }
368 
369  unsigned getConstantAmount() const {
370  assert(hs == Constant);
371  return amt;
372  }
373 
374  const char *getStart() const {
375  // We include the . character if it is given.
376  return start - UsesDotPrefix;
377  }
378 
379  unsigned getConstantLength() const {
380  assert(hs == Constant);
381  return length + UsesDotPrefix;
382  }
383 
384  ArgType getArgType(ASTContext &Ctx) const;
385 
386  void toString(raw_ostream &os) const;
387 
388  bool usesPositionalArg() const { return (bool) UsesPositionalArg; }
389  unsigned getPositionalArgIndex() const {
390  assert(hasDataArgument());
391  return amt + 1;
392  }
393 
394  bool usesDotPrefix() const { return UsesDotPrefix; }
395  void setUsesDotPrefix() { UsesDotPrefix = true; }
396 
397 private:
398  const char *start;
399  unsigned length;
400  HowSpecified hs;
401  unsigned amt;
402  bool UsesPositionalArg : 1;
403  bool UsesDotPrefix;
404 };
405 
406 
408 protected:
413 
414  /// Positional arguments, an IEEE extension:
415  /// IEEE Std 1003.1, 2004 Edition
416  /// http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
418  unsigned argIndex;
419 public:
420  FormatSpecifier(bool isPrintf)
421  : CS(isPrintf), VectorNumElts(false),
423 
425  LM = lm;
426  }
427 
429 
430  void setArgIndex(unsigned i) {
431  argIndex = i;
432  }
433 
434  unsigned getArgIndex() const {
435  return argIndex;
436  }
437 
438  unsigned getPositionalArgIndex() const {
439  return argIndex + 1;
440  }
441 
443  return LM;
444  }
445 
446  const OptionalAmount &getFieldWidth() const {
447  return FieldWidth;
448  }
449 
450  void setVectorNumElts(const OptionalAmount &Amt) {
451  VectorNumElts = Amt;
452  }
453 
455  return VectorNumElts;
456  }
457 
458  void setFieldWidth(const OptionalAmount &Amt) {
459  FieldWidth = Amt;
460  }
461 
462  bool usesPositionalArg() const { return UsesPositionalArg; }
463 
464  bool hasValidLengthModifier(const TargetInfo &Target,
465  const LangOptions &LO) const;
466 
467  bool hasStandardLengthModifier() const;
468 
470 
471  bool hasStandardConversionSpecifier(const LangOptions &LangOpt) const;
472 
474 
475  /// For a TypedefType QT, if it is a named integer type such as size_t,
476  /// assign the appropriate value to LM and return true.
478 };
479 
480 } // end analyze_format_string namespace
481 
482 //===----------------------------------------------------------------------===//
483 /// Pieces specific to fprintf format strings.
484 
485 namespace analyze_printf {
486 
489 public:
492 
493  PrintfConversionSpecifier(const char *pos, Kind k)
494  : ConversionSpecifier(true, pos, k) {}
495 
496  bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; }
497  bool isDoubleArg() const { return kind >= DoubleArgBeg &&
498  kind <= DoubleArgEnd; }
499 
501  return CS->isPrintfKind();
502  }
503 };
504 
509 
511  OptionalFlag HasThousandsGrouping; // ''', POSIX extension.
512  OptionalFlag IsLeftJustified; // '-'
513  OptionalFlag HasPlusPrefix; // '+'
514  OptionalFlag HasSpacePrefix; // ' '
515  OptionalFlag HasAlternativeForm; // '#'
516  OptionalFlag HasLeadingZeroes; // '0'
517  OptionalFlag HasObjCTechnicalTerm; // '[tt]'
518  OptionalFlag IsPrivate; // '{private}'
519  OptionalFlag IsPublic; // '{public}'
520  OptionalFlag IsSensitive; // '{sensitive}'
521  OptionalAmount Precision;
522  StringRef MaskType;
523 
524  ArgType getScalarArgType(ASTContext &Ctx, bool IsObjCLiteral) const;
525 
526 public:
528  : FormatSpecifier(/* isPrintf = */ true), HasThousandsGrouping("'"),
529  IsLeftJustified("-"), HasPlusPrefix("+"), HasSpacePrefix(" "),
530  HasAlternativeForm("#"), HasLeadingZeroes("0"),
531  HasObjCTechnicalTerm("tt"), IsPrivate("private"), IsPublic("public"),
532  IsSensitive("sensitive") {}
533 
534  static PrintfSpecifier Parse(const char *beg, const char *end);
535 
536  // Methods for incrementally constructing the PrintfSpecifier.
538  CS = cs;
539  }
540  void setHasThousandsGrouping(const char *position) {
541  HasThousandsGrouping.setPosition(position);
542  }
543  void setIsLeftJustified(const char *position) {
544  IsLeftJustified.setPosition(position);
545  }
546  void setHasPlusPrefix(const char *position) {
547  HasPlusPrefix.setPosition(position);
548  }
549  void setHasSpacePrefix(const char *position) {
550  HasSpacePrefix.setPosition(position);
551  }
552  void setHasAlternativeForm(const char *position) {
553  HasAlternativeForm.setPosition(position);
554  }
555  void setHasLeadingZeros(const char *position) {
556  HasLeadingZeroes.setPosition(position);
557  }
558  void setHasObjCTechnicalTerm(const char *position) {
559  HasObjCTechnicalTerm.setPosition(position);
560  }
561  void setIsPrivate(const char *position) { IsPrivate.setPosition(position); }
562  void setIsPublic(const char *position) { IsPublic.setPosition(position); }
563  void setIsSensitive(const char *position) {
564  IsSensitive.setPosition(position);
565  }
567 
568  // Methods for querying the format specifier.
569 
571  return cast<PrintfConversionSpecifier>(CS);
572  }
573 
574  void setPrecision(const OptionalAmount &Amt) {
575  Precision = Amt;
576  Precision.setUsesDotPrefix();
577  }
578 
579  const OptionalAmount &getPrecision() const {
580  return Precision;
581  }
582 
583  bool consumesDataArgument() const {
585  }
586 
587  /// Returns the builtin type that a data argument
588  /// paired with this format specifier should have. This method
589  /// will return null if the format specifier does not have
590  /// a matching data argument or the matching argument matches
591  /// more than one type.
592  ArgType getArgType(ASTContext &Ctx, bool IsObjCLiteral) const;
593 
595  return HasThousandsGrouping;
596  }
597  const OptionalFlag &isLeftJustified() const { return IsLeftJustified; }
598  const OptionalFlag &hasPlusPrefix() const { return HasPlusPrefix; }
599  const OptionalFlag &hasAlternativeForm() const { return HasAlternativeForm; }
600  const OptionalFlag &hasLeadingZeros() const { return HasLeadingZeroes; }
601  const OptionalFlag &hasSpacePrefix() const { return HasSpacePrefix; }
602  const OptionalFlag &hasObjCTechnicalTerm() const { return HasObjCTechnicalTerm; }
603  const OptionalFlag &isPrivate() const { return IsPrivate; }
604  const OptionalFlag &isPublic() const { return IsPublic; }
605  const OptionalFlag &isSensitive() const { return IsSensitive; }
606  bool usesPositionalArg() const { return UsesPositionalArg; }
607 
608  StringRef getMaskType() const { return MaskType; }
609  void setMaskType(StringRef S) { MaskType = S; }
610 
611  /// Changes the specifier and length according to a QualType, retaining any
612  /// flags or options. Returns true on success, or false when a conversion
613  /// was not successful.
614  bool fixType(QualType QT, const LangOptions &LangOpt, ASTContext &Ctx,
615  bool IsObjCLiteral);
616 
617  void toString(raw_ostream &os) const;
618 
619  // Validation methods - to check if any element results in undefined behavior
620  bool hasValidPlusPrefix() const;
621  bool hasValidAlternativeForm() const;
622  bool hasValidLeadingZeros() const;
623  bool hasValidSpacePrefix() const;
624  bool hasValidLeftJustified() const;
625  bool hasValidThousandsGroupingPrefix() const;
626 
627  bool hasValidPrecision() const;
628  bool hasValidFieldWidth() const;
629 };
630 } // end analyze_printf namespace
631 
632 //===----------------------------------------------------------------------===//
633 /// Pieces specific to fscanf format strings.
634 
635 namespace analyze_scanf {
636 
639 public:
642 
643  ScanfConversionSpecifier(const char *pos, Kind k)
644  : ConversionSpecifier(false, pos, k) {}
645 
647  return !CS->isPrintfKind();
648  }
649 };
650 
655 
657  OptionalFlag SuppressAssignment; // '*'
658 public:
660  FormatSpecifier(/* isPrintf = */ false),
661  SuppressAssignment("*") {}
662 
663  void setSuppressAssignment(const char *position) {
664  SuppressAssignment.setPosition(position);
665  }
666 
668  return SuppressAssignment;
669  }
670 
672  CS = cs;
673  }
674 
676  return cast<ScanfConversionSpecifier>(CS);
677  }
678 
679  bool consumesDataArgument() const {
680  return CS.consumesDataArgument() && !SuppressAssignment;
681  }
682 
683  ArgType getArgType(ASTContext &Ctx) const;
684 
685  bool fixType(QualType QT, QualType RawQT, const LangOptions &LangOpt,
686  ASTContext &Ctx);
687 
688  void toString(raw_ostream &os) const;
689 
690  static ScanfSpecifier Parse(const char *beg, const char *end);
691 };
692 
693 } // end analyze_scanf namespace
694 
695 //===----------------------------------------------------------------------===//
696 // Parsing and processing of format strings (both fprintf and fscanf).
697 
698 namespace analyze_format_string {
699 
701 
703 public:
705  virtual ~FormatStringHandler();
706 
707  virtual void HandleNullChar(const char *nullCharacter) {}
708 
709  virtual void HandlePosition(const char *startPos, unsigned posLen) {}
710 
711  virtual void HandleInvalidPosition(const char *startPos, unsigned posLen,
712  PositionContext p) {}
713 
714  virtual void HandleZeroPosition(const char *startPos, unsigned posLen) {}
715 
716  virtual void HandleIncompleteSpecifier(const char *startSpecifier,
717  unsigned specifierLen) {}
718 
719  virtual void HandleEmptyObjCModifierFlag(const char *startFlags,
720  unsigned flagsLen) {}
721 
722  virtual void HandleInvalidObjCModifierFlag(const char *startFlag,
723  unsigned flagLen) {}
724 
725  virtual void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart,
726  const char *flagsEnd,
727  const char *conversionPosition) {}
728  // Printf-specific handlers.
729 
732  const char *startSpecifier,
733  unsigned specifierLen) {
734  return true;
735  }
736 
738  const char *startSpecifier,
739  unsigned specifierLen,
740  const TargetInfo &Target) {
741  return true;
742  }
743 
744  /// Handle mask types whose sizes are not between one and eight bytes.
745  virtual void handleInvalidMaskType(StringRef MaskType) {}
746 
747  // Scanf-specific handlers.
748 
751  const char *startSpecifier,
752  unsigned specifierLen) {
753  return true;
754  }
755 
757  const char *startSpecifier,
758  unsigned specifierLen) {
759  return true;
760  }
761 
762  virtual void HandleIncompleteScanList(const char *start, const char *end) {}
763 };
764 
765 bool ParsePrintfString(FormatStringHandler &H,
766  const char *beg, const char *end, const LangOptions &LO,
767  const TargetInfo &Target, bool isFreeBSDKPrintf);
768 
769 bool ParseFormatStringHasSArg(const char *beg, const char *end,
770  const LangOptions &LO, const TargetInfo &Target);
771 
772 bool ParseScanfString(FormatStringHandler &H,
773  const char *beg, const char *end, const LangOptions &LO,
774  const TargetInfo &Target);
775 
776 /// Return true if the given string has at least one formatting specifier.
778  const char *End,
779  const LangOptions &LO,
780  const TargetInfo &Target);
781 
782 } // end analyze_format_string namespace
783 } // end clang namespace
784 #endif
clang::analyze_format_string::FormatSpecifier::setFieldWidth
void setFieldWidth(const OptionalAmount &Amt)
Definition: FormatString.h:458
clang::analyze_scanf::ScanfConversionSpecifier::ScanfConversionSpecifier
ScanfConversionSpecifier(const char *pos, Kind k)
Definition: FormatString.h:643
clang::analyze_printf::PrintfSpecifier::hasAlternativeForm
const OptionalFlag & hasAlternativeForm() const
Definition: FormatString.h:599
clang::analyze_printf::PrintfSpecifier::setUsesPositionalArg
void setUsesPositionalArg()
Definition: FormatString.h:566
clang::analyze_format_string::ConversionSpecifier::SArg
@ SArg
Definition: FormatString.h:162
clang::analyze_format_string::FormatSpecifier::getPositionalArgIndex
unsigned getPositionalArgIndex() const
Definition: FormatString.h:438
clang::analyze_printf::PrintfSpecifier::setHasThousandsGrouping
void setHasThousandsGrouping(const char *position)
Definition: FormatString.h:540
clang::analyze_format_string::ConversionSpecifier::oArg
@ oArg
Definition: FormatString.h:137
clang::analyze_scanf::ScanfConversionSpecifier::ScanfConversionSpecifier
ScanfConversionSpecifier()
Definition: FormatString.h:640
clang::analyze_printf::PrintfSpecifier::hasLeadingZeros
const OptionalFlag & hasLeadingZeros() const
Definition: FormatString.h:600
clang::analyze_printf::PrintfSpecifier::isPrivate
const OptionalFlag & isPrivate() const
Definition: FormatString.h:603
clang::analyze_printf::PrintfSpecifier::setConversionSpecifier
void setConversionSpecifier(const PrintfConversionSpecifier &cs)
Definition: FormatString.h:537
clang::analyze_format_string::FormatStringHandler::HandleInvalidObjCModifierFlag
virtual void HandleInvalidObjCModifierFlag(const char *startFlag, unsigned flagLen)
Definition: FormatString.h:722
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:312
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::FormatStringHandler::HandlePrintfSpecifier
virtual bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, unsigned specifierLen, const TargetInfo &Target)
Definition: FormatString.h:737
clang::analyze_format_string::OptionalAmount::usesDotPrefix
bool usesDotPrefix() const
Definition: FormatString.h:394
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:604
clang::analyze_format_string::ConversionSpecifier::ObjCObjArg
@ ObjCObjArg
Definition: FormatString.h:174
clang::analyze_scanf::ScanfSpecifier::fixType
bool fixType(QualType QT, QualType RawQT, const LangOptions &LangOpt, ASTContext &Ctx)
Definition: ScanfFormatString.cpp:414
clang::analyze_format_string::ConversionSpecifier::isAnyIntArg
bool isAnyIntArg() const
Definition: FormatString.h:235
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:274
clang::analyze_format_string::ConversionSpecifier::EndScanList
const char * EndScanList
Definition: FormatString.h:249
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:646
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:510
clang::analyze_format_string::ConversionSpecifier::setEndScanList
void setEndScanList(const char *pos)
Definition: FormatString.h:230
clang::analyze_printf::PrintfSpecifier::PrintfSpecifier
PrintfSpecifier()
Definition: FormatString.h:527
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:561
clang::analyze_printf::PrintfSpecifier::setIsLeftJustified
void setIsLeftJustified(const char *position)
Definition: FormatString.h:543
clang::analyze_format_string::FormatStringHandler::HandleEmptyObjCModifierFlag
virtual void HandleEmptyObjCModifierFlag(const char *startFlags, unsigned flagsLen)
Definition: FormatString.h:719
clang::analyze_scanf::ScanfSpecifier::setConversionSpecifier
void setConversionSpecifier(const ScanfConversionSpecifier &cs)
Definition: FormatString.h:671
clang::analyze_format_string::OptionalAmount::OptionalAmount
OptionalAmount(unsigned Amount)
Definition: FormatString.h:351
clang::analyze_format_string::ArgType::MatchPromotion
@ MatchPromotion
The conversion specifier and the argument type are compatible because of default argument promotions.
Definition: FormatString.h:268
clang::analyze_format_string::ConversionSpecifier::xArg
@ xArg
Definition: FormatString.h:141
clang::analyze_format_string::FormatStringHandler
Definition: FormatString.h:702
clang::analyze_format_string::LengthModifier::LengthModifier
LengthModifier(const char *pos, Kind k)
Definition: FormatString.h:89
clang::analyze_format_string::FormatSpecifier
Definition: FormatString.h:407
clang::analyze_printf::PrintfSpecifier::setIsPublic
void setIsPublic(const char *position)
Definition: FormatString.h:562
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:1047
clang::analyze_format_string::ArgType::SpecificTy
@ SpecificTy
Definition: FormatString.h:255
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::analyze_format_string::ConversionSpecifier::isDoubleArg
bool isDoubleArg() const
Definition: FormatString.h:236
clang::analyze_printf::PrintfSpecifier::hasValidPrecision
bool hasValidPrecision() const
Definition: PrintfFormatString.cpp:1086
clang::analyze_format_string::OptionalAmount::getConstantAmount
unsigned getConstantAmount() const
Definition: FormatString.h:369
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:227
clang::analyze_format_string::FormatSpecifier::getArgIndex
unsigned getArgIndex() const
Definition: FormatString.h:434
clang::analyze_format_string::ConversionSpecifier::sArg
@ sArg
Definition: FormatString.h:157
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:205
clang::analyze_format_string::FormatSpecifier::CS
ConversionSpecifier CS
Definition: FormatString.h:411
clang::analyze_format_string::OptionalAmount::usesPositionalArg
bool usesPositionalArg() const
Definition: FormatString.h:388
clang::analyze_printf::PrintfSpecifier::setMaskType
void setMaskType(StringRef S)
Definition: FormatString.h:609
clang::analyze_format_string::ConversionSpecifier::PrintfConvBeg
@ PrintfConvBeg
Definition: FormatString.h:187
clang::analyze_format_string::FormatStringHandler::HandleInvalidPosition
virtual void HandleInvalidPosition(const char *startPos, unsigned posLen, PositionContext p)
Definition: FormatString.h:711
clang::analyze_printf::PrintfConversionSpecifier::classof
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
Definition: FormatString.h:500
clang::analyze_format_string::LengthModifier::AsInt3264
@ AsInt3264
Definition: FormatString.h:78
clang::analyze_format_string::ArgType::WIntTy
@ WIntTy
Definition: FormatString.h:256
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:301
clang::analyze_format_string::ArgType::makeVectorType
ArgType makeVectorType(ASTContext &C, unsigned NumElts) const
Definition: FormatString.cpp:559
clang::analyze_scanf::ScanfSpecifier::setSuppressAssignment
void setSuppressAssignment(const char *position)
Definition: FormatString.h:663
clang::analyze_format_string::OptionalAmount::getStart
const char * getStart() const
Definition: FormatString.h:374
clang::analyze_format_string::FormatStringHandler::HandleZeroPosition
virtual void HandleZeroPosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:714
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:294
clang::analyze_format_string::ArgType::MatchKind
MatchKind
How well a given conversion specifier matches its argument.
Definition: FormatString.h:259
clang::analyze_printf::PrintfSpecifier::hasValidLeadingZeros
bool hasValidLeadingZeros() const
Definition: PrintfFormatString.cpp:992
clang::analyze_format_string::PrecisionPos
@ PrecisionPos
Definition: FormatString.h:700
clang::analyze_format_string::ConversionSpecifier::FArg
@ FArg
Definition: FormatString.h:147
clang::analyze_printf::PrintfConversionSpecifier
Definition: FormatString.h:487
End
SourceLocation End
Definition: USRLocFinder.cpp:167
clang::analyze_printf::PrintfConversionSpecifier::isDoubleArg
bool isDoubleArg() const
Definition: FormatString.h:497
clang::analyze_format_string::OptionalFlag::clear
void clear()
Definition: FormatString.h:39
clang::analyze_printf::PrintfSpecifier::hasValidPlusPrefix
bool hasValidPlusPrefix() const
Definition: PrintfFormatString.cpp:937
clang::analyze_format_string::ConversionSpecifier::fArg
@ fArg
Definition: FormatString.h:146
clang::analyze_format_string::OptionalAmount::OptionalAmount
OptionalAmount(bool valid=true)
Definition: FormatString.h:347
clang::analyze_format_string::FormatSpecifier::hasValidLengthModifier
bool hasValidLengthModifier(const TargetInfo &Target, const LangOptions &LO) const
Definition: FormatString.cpp:785
clang::analyze_format_string::ConversionSpecifier::toString
const char * toString() const
Definition: FormatString.cpp:684
clang::analyze_printf::PrintfSpecifier::hasValidThousandsGroupingPrefix
bool hasValidThousandsGroupingPrefix() const
Definition: PrintfFormatString.cpp:1066
clang::analyze_format_string::ConversionSpecifier::isPrintfKind
bool isPrintfKind() const
Definition: FormatString.h:242
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:389
clang::analyze_format_string::ConversionSpecifier::ScanfConvBeg
@ ScanfConvBeg
Definition: FormatString.h:192
clang::analyze_format_string::ConversionSpecifier::getKind
Kind getKind() const
Definition: FormatString.h:225
clang::analyze_format_string::ConversionSpecifier::FreeBSDDArg
@ FreeBSDDArg
Definition: FormatString.h:180
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:292
clang::analyze_format_string::OptionalAmount::HowSpecified
HowSpecified
Definition: FormatString.h:337
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:410
clang::analyze_format_string::OptionalAmount
Definition: FormatString.h:335
clang::analyze_printf::PrintfSpecifier::isSensitive
const OptionalFlag & isSensitive() const
Definition: FormatString.h:605
clang::analyze_scanf::ScanfSpecifier::getSuppressAssignment
const OptionalFlag & getSuppressAssignment() const
Definition: FormatString.h:667
clang::analyze_printf::PrintfConversionSpecifier::isObjCArg
bool isObjCArg() const
Definition: FormatString.h:496
clang::analyze_format_string::OptionalAmount::Constant
@ Constant
Definition: FormatString.h:337
clang::analyze_format_string::OptionalAmount::getArgType
ArgType getArgType(ASTContext &Ctx) const
Definition: FormatString.cpp:631
clang::analyze_format_string::FormatSpecifier::getVectorNumElts
const OptionalAmount & getVectorNumElts() const
Definition: FormatString.h:454
clang::analyze_format_string::OptionalAmount::Arg
@ Arg
Definition: FormatString.h:337
clang::analyze_format_string::ParseScanfString
bool ParseScanfString(FormatStringHandler &H, const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target)
Definition: ScanfFormatString.cpp:541
clang::analyze_format_string::ConversionSpecifier::IntArgEnd
@ IntArgEnd
Definition: FormatString.h:135
clang::analyze_format_string::OptionalAmount::getConstantLength
unsigned getConstantLength() const
Definition: FormatString.h:379
clang::analyze_format_string::ConversionSpecifier::nArg
@ nArg
Definition: FormatString.h:159
clang::analyze_format_string::ConversionSpecifier::IsPrintf
bool IsPrintf
Definition: FormatString.h:247
clang::analyze_format_string::OptionalAmount::toString
void toString(raw_ostream &os) const
Definition: FormatString.cpp:764
clang::analyze_scanf::ScanfConversionSpecifier
Definition: FormatString.h:637
clang::analyze_format_string::ConversionSpecifier::gArg
@ gArg
Definition: FormatString.h:150
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:745
clang::analyze_format_string::PositionContext
PositionContext
Definition: FormatString.h:700
clang::analyze_format_string::FormatSpecifier::FormatSpecifier
FormatSpecifier(bool isPrintf)
Definition: FormatString.h:420
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:320
clang::analyze_format_string::ConversionSpecifier::Position
const char * Position
Definition: FormatString.h:248
clang::analyze_format_string::ConversionSpecifier::BArg
@ BArg
Definition: FormatString.h:132
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:684
clang::analyze_format_string::FormatSpecifier::setUsesPositionalArg
void setUsesPositionalArg()
Definition: FormatString.h:428
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::analyze_format_string::FormatSpecifier::UsesPositionalArg
bool UsesPositionalArg
Positional arguments, an IEEE extension: IEEE Std 1003.1, 2004 Edition http://www....
Definition: FormatString.h:417
clang::analyze_printf::PrintfSpecifier::setHasPlusPrefix
void setHasPlusPrefix(const char *position)
Definition: FormatString.h:546
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:304
clang::analyze_format_string::ConversionSpecifier::consumesDataArgument
bool consumesDataArgument() const
Definition: FormatString.h:211
clang::analyze_format_string::ConversionSpecifier::FreeBSDyArg
@ FreeBSDyArg
Definition: FormatString.h:182
clang::analyze_format_string::ConversionSpecifier::bArg
@ bArg
Definition: FormatString.h:131
clang::analyze_format_string::ConversionSpecifier::dArg
@ dArg
Definition: FormatString.h:127
clang::analyze_printf::PrintfSpecifier::hasValidSpacePrefix
bool hasValidSpacePrefix() const
Definition: PrintfFormatString.cpp:1026
clang::analyze_format_string::ArgType::Match
@ Match
The conversion specifier and the argument type are compatible.
Definition: FormatString.h:265
clang::analyze_format_string::FormatStringHandler::HandleInvalidScanfConversionSpecifier
virtual bool HandleInvalidScanfConversionSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:749
clang::analyze_format_string::FieldWidthPos
@ FieldWidthPos
Definition: FormatString.h:700
clang::analyze_printf::PrintfSpecifier::getConversionSpecifier
const PrintfConversionSpecifier & getConversionSpecifier() const
Definition: FormatString.h:570
clang::analyze_format_string::ConversionSpecifier::ObjCBeg
@ ObjCBeg
Definition: FormatString.h:175
clang::analyze_format_string::ArgType::AnyCharTy
@ AnyCharTy
Definition: FormatString.h:256
clang::analyze_format_string::ArgType::CPointerTy
@ CPointerTy
Definition: FormatString.h:255
clang::analyze_printf::PrintfSpecifier::getMaskType
StringRef getMaskType() const
Definition: FormatString.h:608
bool
#define bool
Definition: stdbool.h:20
clang::analyze_format_string::LengthModifier::AsWide
@ AsWide
Definition: FormatString.h:83
clang::analyze_format_string::ConversionSpecifier::ScanListArg
@ ScanListArg
Definition: FormatString.h:191
clang::analyze_format_string::ConversionSpecifier::isIntArg
bool isIntArg() const
Definition: FormatString.h:232
clang::analyze_format_string::FormatSpecifier::getFieldWidth
const OptionalAmount & getFieldWidth() const
Definition: FormatString.h:446
clang::analyze_format_string::ConversionSpecifier::kind
Kind kind
Definition: FormatString.h:250
clang::analyze_format_string::ConversionSpecifier::uArg
@ uArg
Definition: FormatString.h:139
clang::analyze_format_string::ConversionSpecifier::getCharacters
StringRef getCharacters() const
Definition: FormatString.h:207
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:707
clang::analyze_printf::PrintfSpecifier::hasValidAlternativeForm
bool hasValidAlternativeForm() const
Definition: PrintfFormatString.cpp:963
clang::analyze_printf::PrintfSpecifier::setHasAlternativeForm
void setHasAlternativeForm(const char *position)
Definition: FormatString.h:552
clang::CanQual< Type >
clang::analyze_scanf::ScanfSpecifier
Definition: FormatString.h:656
clang::analyze_printf::PrintfSpecifier::isLeftJustified
const OptionalFlag & isLeftJustified() const
Definition: FormatString.h:597
clang::analyze_format_string::ConversionSpecifier::ConversionSpecifier
ConversionSpecifier(bool isPrintf, const char *pos, Kind k)
Definition: FormatString.h:200
clang::analyze_format_string::LengthModifier::AsQuad
@ AsQuad
Definition: FormatString.h:73
clang::analyze_scanf::ScanfSpecifier::consumesDataArgument
bool consumesDataArgument() const
Definition: FormatString.h:679
clang::analyze_format_string::OptionalAmount::getArgIndex
unsigned getArgIndex() const
Definition: FormatString.h:364
clang::analyze_format_string::LengthModifier::AsInt32
@ AsInt32
Definition: FormatString.h:77
clang::analyze_format_string::ConversionSpecifier::ScanfConvEnd
@ ScanfConvEnd
Definition: FormatString.h:193
clang::analyze_scanf::ScanfSpecifier::toString
void toString(raw_ostream &os) const
Definition: ScanfFormatString.cpp:528
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:1121
clang::analyze_format_string::FormatSpecifier::hasStandardConversionSpecifier
bool hasStandardConversionSpecifier(const LangOptions &LangOpt) const
Definition: FormatString.cpp:971
clang::analyze_format_string::ArgType::isValid
bool isValid() const
Definition: FormatString.h:297
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:234
clang::analyze_format_string::OptionalAmount::Invalid
@ Invalid
Definition: FormatString.h:337
clang::analyze_format_string::FormatSpecifier::hasStandardLengthConversionCombination
bool hasStandardLengthConversionCombination() const
Definition: FormatString.cpp:1017
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:262
clang::analyze_format_string::FormatSpecifier::argIndex
unsigned argIndex
Definition: FormatString.h:418
clang::analyze_printf::PrintfSpecifier::setHasObjCTechnicalTerm
void setHasObjCTechnicalTerm(const char *position)
Definition: FormatString.h:558
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:450
clang::analyze_format_string::ArgType::matchesType
MatchKind matchesType(ASTContext &C, QualType argTy) const
Definition: FormatString.cpp:323
clang::analyze_format_string::ConversionSpecifier::XArg
@ XArg
Definition: FormatString.h:142
clang::analyze_format_string::FormatStringHandler::FormatStringHandler
FormatStringHandler()
Definition: FormatString.h:704
false
#define false
Definition: stdbool.h:22
clang::analyze_printf::PrintfConversionSpecifier::PrintfConversionSpecifier
PrintfConversionSpecifier()
Definition: FormatString.h:490
clang::analyze_format_string::LengthModifier::toString
const char * toString() const
Definition: FormatString.cpp:640
clang::analyze_format_string::ConversionSpecifier::getStart
const char * getStart() const
Definition: FormatString.h:203
clang::analyze_format_string::ConversionSpecifier::GArg
@ GArg
Definition: FormatString.h:151
clang::analyze_format_string::ArgType::UnknownTy
@ UnknownTy
Definition: FormatString.h:255
clang::analyze_format_string::OptionalAmount::getHowSpecified
HowSpecified getHowSpecified() const
Definition: FormatString.h:359
clang::analyze_format_string::ArgType::Kind
Kind
Definition: FormatString.h:255
Begin
SourceLocation Begin
Definition: USRLocFinder.cpp:165
clang::analyze_format_string::FormatSpecifier::setLengthModifier
void setLengthModifier(LengthModifier lm)
Definition: FormatString.h:424
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:670
clang::analyze_format_string::FormatSpecifier::usesPositionalArg
bool usesPositionalArg() const
Definition: FormatString.h:462
clang::analyze_printf::PrintfSpecifier::hasPlusPrefix
const OptionalFlag & hasPlusPrefix() const
Definition: FormatString.h:598
clang::analyze_format_string::ConversionSpecifier::PrintErrno
@ PrintErrno
Definition: FormatString.h:185
clang::analyze_format_string::FormatStringHandler::HandleObjCFlagsWithNonObjCConversion
virtual void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, const char *flagsEnd, const char *conversionPosition)
Definition: FormatString.h:725
clang::analyze_scanf::ScanfSpecifier::ScanfSpecifier
ScanfSpecifier()
Definition: FormatString.h:659
clang::analyze_printf::PrintfSpecifier::getPrecision
const OptionalAmount & getPrecision() const
Definition: FormatString.h:579
clang::analyze_format_string::FormatStringHandler::HandleIncompleteScanList
virtual void HandleIncompleteScanList(const char *start, const char *end)
Definition: FormatString.h:762
clang::analyze_format_string::ConversionSpecifier::PercentArg
@ PercentArg
Definition: FormatString.h:160
clang::analyze_format_string::LengthModifier::None
@ None
Definition: FormatString.h:67
clang::analyze_format_string::ConversionSpecifier::aArg
@ aArg
Definition: FormatString.h:152
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:905
clang::analyze_format_string::LengthModifier::getLength
unsigned getLength() const
Definition: FormatString.h:96
clang::analyze_format_string::FormatSpecifier::LM
LengthModifier LM
Definition: FormatString.h:409
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:470
clang::analyze_format_string::ArgType::getRepresentativeType
QualType getRepresentativeType(ASTContext &C) const
Definition: FormatString.cpp:568
clang::analyze_format_string::FormatSpecifier::setArgIndex
void setArgIndex(unsigned i)
Definition: FormatString.h:430
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:81
clang::analyze_format_string::FormatStringHandler::HandlePosition
virtual void HandlePosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:709
clang::analyze_format_string::ConversionSpecifier::FreeBSDrArg
@ FreeBSDrArg
Definition: FormatString.h:181
clang::analyze_format_string::ConversionSpecifier::OArg
@ OArg
Definition: FormatString.h:138
clang::analyze_format_string::ArgType::ArgType
ArgType(QualType T, const char *N=nullptr)
Definition: FormatString.h:293
clang::analyze_format_string::ConversionSpecifier::PArg
@ PArg
Definition: FormatString.h:167
clang::analyze_printf::PrintfSpecifier::hasValidLeftJustified
bool hasValidLeftJustified() const
Definition: PrintfFormatString.cpp:1052
clang::analyze_format_string::FormatStringHandler::HandleIncompleteSpecifier
virtual void HandleIncompleteSpecifier(const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:716
clang::analyze_format_string::ArgType::InvalidTy
@ InvalidTy
Definition: FormatString.h:255
clang::analyze_format_string::OptionalAmount::isInvalid
bool isInvalid() const
Definition: FormatString.h:355
clang::analyze_format_string::ArgType::NoMatchPromotionTypeConfusion
@ NoMatchPromotionTypeConfusion
The conversion specifier and the argument type are compatible but still seems likely to be an error.
Definition: FormatString.h:271
clang::analyze_format_string::ConversionSpecifier::setKind
void setKind(Kind k)
Definition: FormatString.h:226
clang
Definition: CalledOnceCheck.h:17
clang::analyze_format_string::ArgType
Definition: FormatString.h:253
clang::analyze_printf::PrintfSpecifier::hasThousandsGrouping
const OptionalFlag & hasThousandsGrouping() const
Definition: FormatString.h:594
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:161
clang::analyze_format_string::LengthModifier::AsAllocate
@ AsAllocate
Definition: FormatString.h:81
clang::analyze_printf::PrintfSpecifier::hasSpacePrefix
const OptionalFlag & hasSpacePrefix() const
Definition: FormatString.h:601
clang::analyze_printf::PrintfSpecifier::usesPositionalArg
bool usesPositionalArg() const
Definition: FormatString.h:606
clang::analyze_format_string::ConversionSpecifier::ConversionSpecifier
ConversionSpecifier(bool isPrintf=true)
Definition: FormatString.h:196
clang::analyze_scanf::ScanfSpecifier::Parse
static ScanfSpecifier Parse(const char *beg, const char *end)
clang::analyze_format_string::ArgType::ObjCPointerTy
@ ObjCPointerTy
Definition: FormatString.h:255
clang::analyze_format_string::FormatSpecifier::VectorNumElts
OptionalAmount VectorNumElts
Definition: FormatString.h:412
clang::analyze_format_string::FormatSpecifier::getCorrectedLengthModifier
Optional< LengthModifier > getCorrectedLengthModifier() const
Definition: FormatString.cpp:1034
clang::analyze_format_string::ConversionSpecifier::ZArg
@ ZArg
Definition: FormatString.h:171
clang::analyze_format_string::ConversionSpecifier::AArg
@ AArg
Definition: FormatString.h:153
clang::analyze_format_string::LengthModifier::AsChar
@ AsChar
Definition: FormatString.h:68
clang::analyze_format_string::ConversionSpecifier::pArg
@ pArg
Definition: FormatString.h:158
clang::analyze_format_string::OptionalAmount::hasDataArgument
bool hasDataArgument() const
Definition: FormatString.h:362
clang::analyze_printf::PrintfSpecifier::consumesDataArgument
bool consumesDataArgument() const
Definition: FormatString.h:583
clang::analyze_printf::PrintfSpecifier::isPublic
const OptionalFlag & isPublic() const
Definition: FormatString.h:604
clang::analyze_format_string::ConversionSpecifier::UIntArgBeg
@ UIntArgBeg
Definition: FormatString.h:143
clang::analyze_format_string::ArgType::CStrTy
@ CStrTy
Definition: FormatString.h:256
clang::analyze_format_string::FormatSpecifier::FieldWidth
OptionalAmount FieldWidth
Definition: FormatString.h:410
clang::analyze_format_string::ConversionSpecifier::UArg
@ UArg
Definition: FormatString.h:140
clang::analyze_format_string::FormatStringHandler::HandleInvalidPrintfConversionSpecifier
virtual bool HandleInvalidPrintfConversionSpecifier(const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:730
clang::analyze_format_string::OptionalAmount::OptionalAmount
OptionalAmount(HowSpecified howSpecified, unsigned amount, const char *amountStart, unsigned amountLength, bool usesPositionalArg)
Definition: FormatString.h:339
clang::analyze_format_string::ParseFormatStringHasSArg
bool ParseFormatStringHasSArg(const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target)
Definition: PrintfFormatString.cpp:441
clang::analyze_format_string::OptionalAmount::setUsesDotPrefix
void setUsesDotPrefix()
Definition: FormatString.h:395
clang::analyze_format_string::FormatSpecifier::hasStandardLengthModifier
bool hasStandardLengthModifier() const
Definition: FormatString.cpp:946
clang::analyze_format_string::FormatStringHandler::HandleScanfSpecifier
virtual bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:756
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:277
clang::analyze_format_string::ArgType::isSizeT
bool isSizeT() const
Definition: FormatString.h:299
CanonicalType.h
clang::analyze_scanf::ScanfSpecifier::getConversionSpecifier
const ScanfConversionSpecifier & getConversionSpecifier() const
Definition: FormatString.h:675
clang::analyze_format_string::ConversionSpecifier::ObjCEnd
@ ObjCEnd
Definition: FormatString.h:176
clang::analyze_printf::PrintfSpecifier::hasObjCTechnicalTerm
const OptionalFlag & hasObjCTechnicalTerm() const
Definition: FormatString.h:602
clang::analyze_format_string::ConversionSpecifier::DoubleArgBeg
@ DoubleArgBeg
Definition: FormatString.h:154
clang::analyze_format_string::ArgType::Invalid
static ArgType Invalid()
Definition: FormatString.h:296
clang::analyze_format_string::ConversionSpecifier::eArg
@ eArg
Definition: FormatString.h:148
clang::analyze_format_string::ConversionSpecifier::IntArgBeg
@ IntArgBeg
Definition: FormatString.h:134
clang::analyze_format_string::OptionalAmount::NotSpecified
@ NotSpecified
Definition: FormatString.h:337
clang::analyze_format_string::ConversionSpecifier::FreeBSDbArg
@ FreeBSDbArg
Definition: FormatString.h:179
clang::analyze_format_string::ConversionSpecifier::PrintfConvEnd
@ PrintfConvEnd
Definition: FormatString.h:188
clang::analyze_format_string::FormatStringHandler::~FormatStringHandler
virtual ~FormatStringHandler()
Definition: FormatString.cpp:28
true
#define true
Definition: stdbool.h:21
clang::analyze_format_string::ConversionSpecifier::getStandardSpecifier
Optional< ConversionSpecifier > getStandardSpecifier() const
Definition: FormatString.cpp:738
clang::analyze_format_string::LengthModifier::AsShortLong
@ AsShortLong
Definition: FormatString.h:70
clang::analyze_format_string::ConversionSpecifier::DoubleArgEnd
@ DoubleArgEnd
Definition: FormatString.h:155
clang::analyze_printf::PrintfSpecifier::setPrecision
void setPrecision(const OptionalAmount &Amt)
Definition: FormatString.h:574
clang::analyze_printf::PrintfConversionSpecifier::PrintfConversionSpecifier
PrintfConversionSpecifier(const char *pos, Kind k)
Definition: FormatString.h:493
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:563
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:149
clang::analyze_format_string::LengthModifier::AsLong
@ AsLong
Definition: FormatString.h:71
clang::analyze_format_string::OptionalAmount::setHowSpecified
void setHowSpecified(HowSpecified h)
Definition: FormatString.h:360
clang::analyze_format_string::ConversionSpecifier::UIntArgEnd
@ UIntArgEnd
Definition: FormatString.h:144
clang::analyze_format_string::LengthModifier::AsPtrDiff
@ AsPtrDiff
Definition: FormatString.h:76
clang::analyze_printf::PrintfSpecifier::setHasSpacePrefix
void setHasSpacePrefix(const char *position)
Definition: FormatString.h:549
clang::analyze_format_string::LengthModifier::AsInt64
@ AsInt64
Definition: FormatString.h:79
clang::analyze_format_string::FormatSpecifier::getLengthModifier
const LengthModifier & getLengthModifier() const
Definition: FormatString.h:442
clang::analyze_format_string::ArgType::WCStrTy
@ WCStrTy
Definition: FormatString.h:256
clang::analyze_printf::PrintfSpecifier::setHasLeadingZeros
void setHasLeadingZeros(const char *position)
Definition: FormatString.h:555
clang::analyze_scanf::ScanfSpecifier::getArgType
ArgType getArgType(ASTContext &Ctx) const
Definition: ScanfFormatString.cpp:226