clang  16.0.0git
ScanfFormatString.cpp
Go to the documentation of this file.
1 //= ScanfFormatString.cpp - Analysis of printf 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 // Handling of format string in scanf and friends. The structure of format
10 // strings for fscanf() are described in C99 7.19.6.2.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/FormatString.h"
15 #include "FormatStringParsing.h"
16 #include "clang/Basic/TargetInfo.h"
17 
26 using namespace clang;
27 
30 
33  const char *&Beg, const char *E) {
34  const char *I = Beg;
35  const char *start = I - 1;
36  UpdateOnReturn <const char*> UpdateBeg(Beg, I);
37 
38  // No more characters?
39  if (I == E) {
40  H.HandleIncompleteScanList(start, I);
41  return true;
42  }
43 
44  // Special case: ']' is the first character.
45  if (*I == ']') {
46  if (++I == E) {
47  H.HandleIncompleteScanList(start, I - 1);
48  return true;
49  }
50  }
51 
52  // Special case: "^]" are the first characters.
53  if (I + 1 != E && I[0] == '^' && I[1] == ']') {
54  I += 2;
55  if (I == E) {
56  H.HandleIncompleteScanList(start, I - 1);
57  return true;
58  }
59  }
60 
61  // Look for a ']' character which denotes the end of the scan list.
62  while (*I != ']') {
63  if (++I == E) {
64  H.HandleIncompleteScanList(start, I - 1);
65  return true;
66  }
67  }
68 
69  CS.setEndScanList(I);
70  return false;
71 }
72 
73 // FIXME: Much of this is copy-paste from ParsePrintfSpecifier.
74 // We can possibly refactor.
76  const char *&Beg,
77  const char *E,
78  unsigned &argIndex,
79  const LangOptions &LO,
80  const TargetInfo &Target) {
81  using namespace clang::analyze_format_string;
82  using namespace clang::analyze_scanf;
83  const char *I = Beg;
84  const char *Start = nullptr;
85  UpdateOnReturn <const char*> UpdateBeg(Beg, I);
86 
87  // Look for a '%' character that indicates the start of a format specifier.
88  for ( ; I != E ; ++I) {
89  char c = *I;
90  if (c == '\0') {
91  // Detect spurious null characters, which are likely errors.
92  H.HandleNullChar(I);
93  return true;
94  }
95  if (c == '%') {
96  Start = I++; // Record the start of the format specifier.
97  break;
98  }
99  }
100 
101  // No format specifier found?
102  if (!Start)
103  return false;
104 
105  if (I == E) {
106  // No more characters left?
107  H.HandleIncompleteSpecifier(Start, E - Start);
108  return true;
109  }
110 
111  ScanfSpecifier FS;
112  if (ParseArgPosition(H, FS, Start, I, E))
113  return true;
114 
115  if (I == E) {
116  // No more characters left?
117  H.HandleIncompleteSpecifier(Start, E - Start);
118  return true;
119  }
120 
121  // Look for '*' flag if it is present.
122  if (*I == '*') {
123  FS.setSuppressAssignment(I);
124  if (++I == E) {
125  H.HandleIncompleteSpecifier(Start, E - Start);
126  return true;
127  }
128  }
129 
130  // Look for the field width (if any). Unlike printf, this is either
131  // a fixed integer or isn't present.
134  assert(Amt.getHowSpecified() == OptionalAmount::Constant);
135  FS.setFieldWidth(Amt);
136 
137  if (I == E) {
138  // No more characters left?
139  H.HandleIncompleteSpecifier(Start, E - Start);
140  return true;
141  }
142  }
143 
144  // Look for the length modifier.
145  if (ParseLengthModifier(FS, I, E, LO, /*IsScanf=*/true) && I == E) {
146  // No more characters left?
147  H.HandleIncompleteSpecifier(Start, E - Start);
148  return true;
149  }
150 
151  // Detect spurious null characters, which are likely errors.
152  if (*I == '\0') {
153  H.HandleNullChar(I);
154  return true;
155  }
156 
157  // Finally, look for the conversion specifier.
158  const char *conversionPosition = I++;
159  ScanfConversionSpecifier::Kind k = ScanfConversionSpecifier::InvalidSpecifier;
160  switch (*conversionPosition) {
161  default:
162  break;
163  case '%': k = ConversionSpecifier::PercentArg; break;
164  case 'b': k = ConversionSpecifier::bArg; break;
165  case 'A': k = ConversionSpecifier::AArg; break;
166  case 'E': k = ConversionSpecifier::EArg; break;
167  case 'F': k = ConversionSpecifier::FArg; break;
168  case 'G': k = ConversionSpecifier::GArg; break;
169  case 'X': k = ConversionSpecifier::XArg; break;
170  case 'a': k = ConversionSpecifier::aArg; break;
171  case 'd': k = ConversionSpecifier::dArg; break;
172  case 'e': k = ConversionSpecifier::eArg; break;
173  case 'f': k = ConversionSpecifier::fArg; break;
174  case 'g': k = ConversionSpecifier::gArg; break;
175  case 'i': k = ConversionSpecifier::iArg; break;
176  case 'n': k = ConversionSpecifier::nArg; break;
177  case 'c': k = ConversionSpecifier::cArg; break;
178  case 'C': k = ConversionSpecifier::CArg; break;
179  case 'S': k = ConversionSpecifier::SArg; break;
180  case '[': k = ConversionSpecifier::ScanListArg; break;
181  case 'u': k = ConversionSpecifier::uArg; break;
182  case 'x': k = ConversionSpecifier::xArg; break;
183  case 'o': k = ConversionSpecifier::oArg; break;
184  case 's': k = ConversionSpecifier::sArg; break;
185  case 'p': k = ConversionSpecifier::pArg; break;
186  // Apple extensions
187  // Apple-specific
188  case 'D':
189  if (Target.getTriple().isOSDarwin())
191  break;
192  case 'O':
193  if (Target.getTriple().isOSDarwin())
195  break;
196  case 'U':
197  if (Target.getTriple().isOSDarwin())
199  break;
200  }
201  ScanfConversionSpecifier CS(conversionPosition, k);
202  if (k == ScanfConversionSpecifier::ScanListArg) {
203  if (ParseScanList(H, CS, I, E))
204  return true;
205  }
206  FS.setConversionSpecifier(CS);
207  if (CS.consumesDataArgument() && !FS.getSuppressAssignment()
208  && !FS.usesPositionalArg())
209  FS.setArgIndex(argIndex++);
210 
211  // FIXME: '%' and '*' doesn't make sense. Issue a warning.
212  // FIXME: 'ConsumedSoFar' and '*' doesn't make sense.
213 
214  if (k == ScanfConversionSpecifier::InvalidSpecifier) {
215  unsigned Len = I - Beg;
216  if (ParseUTF8InvalidSpecifier(Beg, E, Len)) {
217  CS.setEndScanList(Beg + Len);
218  FS.setConversionSpecifier(CS);
219  }
220  // Assume the conversion takes one argument.
221  return !H.HandleInvalidScanfConversionSpecifier(FS, Beg, Len);
222  }
223  return ScanfSpecifierResult(Start, FS);
224 }
225 
226 ArgType ScanfSpecifier::getArgType(ASTContext &Ctx) const {
227  const ScanfConversionSpecifier &CS = getConversionSpecifier();
228 
229  if (!CS.consumesDataArgument())
230  return ArgType::Invalid();
231 
232  switch(CS.getKind()) {
233  // Signed int.
237  switch (LM.getKind()) {
239  return ArgType::PtrTo(Ctx.IntTy);
243  return ArgType::PtrTo(Ctx.ShortTy);
245  return ArgType::PtrTo(Ctx.LongTy);
248  return ArgType::PtrTo(Ctx.LongLongTy);
250  return ArgType::PtrTo(ArgType(Ctx.LongLongTy, "__int64"));
252  return ArgType::PtrTo(ArgType(Ctx.getIntMaxType(), "intmax_t"));
254  return ArgType::PtrTo(ArgType(Ctx.getSignedSizeType(), "ssize_t"));
256  return ArgType::PtrTo(ArgType(Ctx.getPointerDiffType(), "ptrdiff_t"));
258  // GNU extension.
259  return ArgType::PtrTo(Ctx.LongLongTy);
266  return ArgType::Invalid();
267  }
268  llvm_unreachable("Unsupported LengthModifier Type");
269 
270  // Unsigned int.
278  switch (LM.getKind()) {
280  return ArgType::PtrTo(Ctx.UnsignedIntTy);
282  return ArgType::PtrTo(Ctx.UnsignedCharTy);
284  return ArgType::PtrTo(Ctx.UnsignedShortTy);
286  return ArgType::PtrTo(Ctx.UnsignedLongTy);
291  return ArgType::PtrTo(ArgType(Ctx.UnsignedLongLongTy, "unsigned __int64"));
293  return ArgType::PtrTo(ArgType(Ctx.getUIntMaxType(), "uintmax_t"));
295  return ArgType::PtrTo(ArgType(Ctx.getSizeType(), "size_t"));
297  return ArgType::PtrTo(
298  ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t"));
300  // GNU extension.
308  return ArgType::Invalid();
309  }
310  llvm_unreachable("Unsupported LengthModifier Type");
311 
312  // Float.
321  switch (LM.getKind()) {
323  return ArgType::PtrTo(Ctx.FloatTy);
325  return ArgType::PtrTo(Ctx.DoubleTy);
327  return ArgType::PtrTo(Ctx.LongDoubleTy);
328  default:
329  return ArgType::Invalid();
330  }
331 
332  // Char, string and scanlist.
336  switch (LM.getKind()) {
341  return ArgType::PtrTo(ArgType(Ctx.getWideCharType(), "wchar_t"));
346  if (Ctx.getTargetInfo().getTriple().isOSMSVCRT())
348  [[fallthrough]];
349  default:
350  return ArgType::Invalid();
351  }
354  // FIXME: Mac OS X specific?
355  switch (LM.getKind()) {
358  return ArgType::PtrTo(ArgType(Ctx.getWideCharType(), "wchar_t"));
361  return ArgType::PtrTo(ArgType(ArgType::WCStrTy, "wchar_t *"));
363  if (Ctx.getTargetInfo().getTriple().isOSMSVCRT())
365  [[fallthrough]];
366  default:
367  return ArgType::Invalid();
368  }
369 
370  // Pointer.
373 
374  // Write-back.
376  switch (LM.getKind()) {
378  return ArgType::PtrTo(Ctx.IntTy);
380  return ArgType::PtrTo(Ctx.SignedCharTy);
382  return ArgType::PtrTo(Ctx.ShortTy);
384  return ArgType::PtrTo(Ctx.LongTy);
387  return ArgType::PtrTo(Ctx.LongLongTy);
389  return ArgType::PtrTo(ArgType(Ctx.LongLongTy, "__int64"));
391  return ArgType::PtrTo(ArgType(Ctx.getIntMaxType(), "intmax_t"));
393  return ArgType::PtrTo(ArgType(Ctx.getSignedSizeType(), "ssize_t"));
395  return ArgType::PtrTo(ArgType(Ctx.getPointerDiffType(), "ptrdiff_t"));
397  return ArgType(); // FIXME: Is this a known extension?
404  return ArgType::Invalid();
405  }
406 
407  default:
408  break;
409  }
410 
411  return ArgType();
412 }
413 
414 bool ScanfSpecifier::fixType(QualType QT, QualType RawQT,
415  const LangOptions &LangOpt,
416  ASTContext &Ctx) {
417 
418  // %n is different from other conversion specifiers; don't try to fix it.
419  if (CS.getKind() == ConversionSpecifier::nArg)
420  return false;
421 
422  if (!QT->isPointerType())
423  return false;
424 
425  QualType PT = QT->getPointeeType();
426 
427  // If it's an enum, get its underlying type.
428  if (const EnumType *ETy = PT->getAs<EnumType>()) {
429  // Don't try to fix incomplete enums.
430  if (!ETy->getDecl()->isComplete())
431  return false;
432  PT = ETy->getDecl()->getIntegerType();
433  }
434 
435  const BuiltinType *BT = PT->getAs<BuiltinType>();
436  if (!BT)
437  return false;
438 
439  // Pointer to a character.
440  if (PT->isAnyCharacterType()) {
441  CS.setKind(ConversionSpecifier::sArg);
442  if (PT->isWideCharType())
443  LM.setKind(LengthModifier::AsWideChar);
444  else
445  LM.setKind(LengthModifier::None);
446 
447  // If we know the target array length, we can use it as a field width.
448  if (const ConstantArrayType *CAT = Ctx.getAsConstantArrayType(RawQT)) {
449  if (CAT->getSizeModifier() == ArrayType::Normal)
451  CAT->getSize().getZExtValue() - 1,
452  "", 0, false);
453 
454  }
455  return true;
456  }
457 
458  // Figure out the length modifier.
459  switch (BT->getKind()) {
460  // no modifier
461  case BuiltinType::UInt:
462  case BuiltinType::Int:
463  case BuiltinType::Float:
464  LM.setKind(LengthModifier::None);
465  break;
466 
467  // hh
468  case BuiltinType::Char_U:
469  case BuiltinType::UChar:
470  case BuiltinType::Char_S:
471  case BuiltinType::SChar:
472  LM.setKind(LengthModifier::AsChar);
473  break;
474 
475  // h
476  case BuiltinType::Short:
477  case BuiltinType::UShort:
478  LM.setKind(LengthModifier::AsShort);
479  break;
480 
481  // l
482  case BuiltinType::Long:
483  case BuiltinType::ULong:
484  case BuiltinType::Double:
485  LM.setKind(LengthModifier::AsLong);
486  break;
487 
488  // ll
489  case BuiltinType::LongLong:
490  case BuiltinType::ULongLong:
491  LM.setKind(LengthModifier::AsLongLong);
492  break;
493 
494  // L
495  case BuiltinType::LongDouble:
496  LM.setKind(LengthModifier::AsLongDouble);
497  break;
498 
499  // Don't know.
500  default:
501  return false;
502  }
503 
504  // Handle size_t, ptrdiff_t, etc. that have dedicated length modifiers in C99.
505  if (LangOpt.C99 || LangOpt.CPlusPlus11)
506  namedTypeToLengthModifier(PT, LM);
507 
508  // If fixing the length modifier was enough, we are done.
509  if (hasValidLengthModifier(Ctx.getTargetInfo(), LangOpt)) {
510  const analyze_scanf::ArgType &AT = getArgType(Ctx);
511  if (AT.isValid() && AT.matchesType(Ctx, QT))
512  return true;
513  }
514 
515  // Figure out the conversion specifier.
516  if (PT->isRealFloatingType())
517  CS.setKind(ConversionSpecifier::fArg);
518  else if (PT->isSignedIntegerType())
519  CS.setKind(ConversionSpecifier::dArg);
520  else if (PT->isUnsignedIntegerType())
521  CS.setKind(ConversionSpecifier::uArg);
522  else
523  llvm_unreachable("Unexpected type");
524 
525  return true;
526 }
527 
528 void ScanfSpecifier::toString(raw_ostream &os) const {
529  os << "%";
530 
531  if (usesPositionalArg())
532  os << getPositionalArgIndex() << "$";
533  if (SuppressAssignment)
534  os << "*";
535 
536  FieldWidth.toString(os);
537  os << LM.toString();
538  os << CS.toString();
539 }
540 
542  const char *I,
543  const char *E,
544  const LangOptions &LO,
545  const TargetInfo &Target) {
546 
547  unsigned argIndex = 0;
548 
549  // Keep looking for a format specifier until we have exhausted the string.
550  while (I != E) {
551  const ScanfSpecifierResult &FSR = ParseScanfSpecifier(H, I, E, argIndex,
552  LO, Target);
553  // Did a fail-stop error of any kind occur when parsing the specifier?
554  // If so, don't do any more processing.
555  if (FSR.shouldStop())
556  return true;
557  // Did we exhaust the string or encounter an error that
558  // we can recover from?
559  if (!FSR.hasValue())
560  continue;
561  // We have a format specifier. Pass it to the callback.
562  if (!H.HandleScanfSpecifier(FSR.getValue(), FSR.getStart(),
563  I - FSR.getStart())) {
564  return true;
565  }
566  }
567  assert(I == E && "Format string not exhausted");
568  return false;
569 }
clang::BuiltinType
This class is used for builtin types like 'int'.
Definition: Type.h:2620
clang::ASTContext::LongDoubleTy
CanQualType LongDoubleTy
Definition: ASTContext.h:1119
clang::analyze_format_string::ConversionSpecifier::SArg
@ SArg
Definition: FormatString.h:162
clang::analyze_format_string::ConversionSpecifier::oArg
@ oArg
Definition: FormatString.h:137
clang::analyze_format_string::ConversionSpecifier::cArg
@ cArg
Definition: FormatString.h:126
clang::analyze_format_string::LengthModifier::AsWideChar
@ AsWideChar
Definition: FormatString.h:84
clang::ASTContext::UnsignedShortTy
CanQualType UnsignedShortTy
Definition: ASTContext.h:1117
clang::analyze_format_string::SpecifierResult
Definition: FormatStringParsing.h:72
clang::analyze_format_string::ConversionSpecifier::setEndScanList
void setEndScanList(const char *pos)
Definition: FormatString.h:230
clang::analyze_format_string::LengthModifier::AsMAllocate
@ AsMAllocate
Definition: FormatString.h:82
clang::analyze_format_string::LengthModifier::AsLongDouble
@ AsLongDouble
Definition: FormatString.h:80
clang::ConstantArrayType
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:3058
clang::analyze_format_string::ConversionSpecifier::xArg
@ xArg
Definition: FormatString.h:141
clang::analyze_format_string::FormatStringHandler
Definition: FormatString.h:702
TargetInfo.h
clang::MultiVersionKind::Target
@ Target
clang::Type::isWideCharType
bool isWideCharType() const
Definition: Type.cpp:1971
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::analyze_format_string::ConversionSpecifier::sArg
@ sArg
Definition: FormatString.h:157
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:205
clang::Type::isRealFloatingType
bool isRealFloatingType() const
Floating point categories.
Definition: Type.cpp:2138
clang::analyze_format_string::LengthModifier::AsInt3264
@ AsInt3264
Definition: FormatString.h:78
clang::ASTContext::getUnsignedPointerDiffType
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
Definition: ASTContext.cpp:5984
clang::analyze_format_string::ConversionSpecifier::iArg
@ iArg
Definition: FormatString.h:129
clang::analyze_format_string::ConversionSpecifier
Definition: FormatString.h:121
clang::analyze_format_string::ConversionSpecifier::FArg
@ FArg
Definition: FormatString.h:147
clang::analyze_format_string::ConversionSpecifier::fArg
@ fArg
Definition: FormatString.h:146
clang::ArrayType::Normal
@ Normal
Definition: Type.h:3019
clang::analyze_format_string::ConversionSpecifier::getKind
Kind getKind() const
Definition: FormatString.h:225
clang::analyze_format_string::SpecifierResult::shouldStop
bool shouldStop() const
Definition: FormatStringParsing.h:84
clang::analyze_format_string::OptionalAmount
Definition: FormatString.h:335
clang::analyze_format_string::OptionalAmount::Constant
@ Constant
Definition: FormatString.h:337
clang::ASTContext::getIntMaxType
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
Definition: ASTContext.cpp:5944
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::nArg
@ nArg
Definition: FormatString.h:159
clang::ASTContext::getAsConstantArrayType
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Definition: ASTContext.h:2726
clang::analyze_scanf::ScanfConversionSpecifier
Definition: FormatString.h:637
clang::analyze_format_string::ConversionSpecifier::gArg
@ gArg
Definition: FormatString.h:150
clang::Type::isAnyCharacterType
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
Definition: Type.cpp:1998
clang::threadSafety::sx::toString
std::string toString(const til::SExpr *E)
Definition: ThreadSafetyCommon.h:91
clang::analyze_format_string::ConversionSpecifier::DArg
@ DArg
Definition: FormatString.h:128
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::ASTContext::getSizeType
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Definition: ASTContext.cpp:5933
ParseScanList
static bool ParseScanList(FormatStringHandler &H, ScanfConversionSpecifier &CS, const char *&Beg, const char *E)
Definition: ScanfFormatString.cpp:31
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::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7386
clang::analyze_format_string::ParseLengthModifier
bool ParseLengthModifier(FormatSpecifier &FS, const char *&Beg, const char *E, const LangOptions &LO, bool IsScanf=false)
Returns true if a LengthModifier was parsed and installed in the FormatSpecifier& argument,...
Definition: FormatString.cpp:210
FormatStringParsing.h
clang::analyze_format_string::ConversionSpecifier::bArg
@ bArg
Definition: FormatString.h:131
clang::analyze_format_string::ConversionSpecifier::dArg
@ dArg
Definition: FormatString.h:127
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::SpecifierResult::getValue
const T & getValue() const
Definition: FormatStringParsing.h:86
clang::analyze_format_string::ArgType::AnyCharTy
@ AnyCharTy
Definition: FormatString.h:256
clang::analyze_format_string::ArgType::CPointerTy
@ CPointerTy
Definition: FormatString.h:255
clang::analyze_format_string::LengthModifier::AsWide
@ AsWide
Definition: FormatString.h:83
clang::analyze_format_string::ConversionSpecifier::ScanListArg
@ ScanListArg
Definition: FormatString.h:191
clang::ASTContext::FloatTy
CanQualType FloatTy
Definition: ASTContext.h:1119
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:625
clang::analyze_format_string::ConversionSpecifier::uArg
@ uArg
Definition: FormatString.h:139
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_scanf::ScanfSpecifier
Definition: FormatString.h:656
clang::analyze_format_string::LengthModifier::AsQuad
@ AsQuad
Definition: FormatString.h:73
clang::ASTContext::getSignedSizeType
CanQualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
Definition: ASTContext.cpp:5939
clang::analyze_format_string::LengthModifier::AsInt32
@ AsInt32
Definition: FormatString.h:77
clang::ASTContext::ShortTy
CanQualType ShortTy
Definition: ASTContext.h:1116
clang::ASTContext::UnsignedLongLongTy
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:1118
clang::analyze_format_string::LengthModifier::AsIntMax
@ AsIntMax
Definition: FormatString.h:74
clang::analyze_format_string::LengthModifier::AsShort
@ AsShort
Definition: FormatString.h:69
clang::analyze_format_string::ArgType::isValid
bool isValid() const
Definition: FormatString.h:297
clang::ASTContext::getWideCharType
QualType getWideCharType() const
Return the type of wide characters.
Definition: ASTContext.h:1776
clang::ASTContext::UnsignedCharTy
CanQualType UnsignedCharTy
Definition: ASTContext.h:1117
clang::TargetInfo::getTriple
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:1197
clang::ASTContext::UnsignedLongTy
CanQualType UnsignedLongTy
Definition: ASTContext.h:1117
clang::analyze_format_string::LengthModifier::AsSizeT
@ AsSizeT
Definition: FormatString.h:75
clang::ASTContext::LongLongTy
CanQualType LongLongTy
Definition: ASTContext.h:1116
FormatString.h
clang::analyze_format_string::ArgType::matchesType
MatchKind matchesType(ASTContext &C, QualType argTy) const
Definition: FormatString.cpp:323
clang::ASTContext::UnsignedIntTy
CanQualType UnsignedIntTy
Definition: ASTContext.h:1117
clang::analyze_format_string::ConversionSpecifier::XArg
@ XArg
Definition: FormatString.h:142
clang::Type::isPointerType
bool isPointerType() const
Definition: Type.h:6883
clang::ASTContext::DoubleTy
CanQualType DoubleTy
Definition: ASTContext.h:1119
clang::analyze_format_string::SpecifierResult::getStart
const char * getStart() const
Definition: FormatStringParsing.h:83
clang::ASTContext::IntTy
CanQualType IntTy
Definition: ASTContext.h:1116
clang::ASTContext::getUIntMaxType
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
Definition: ASTContext.cpp:5949
clang::analyze_format_string::ConversionSpecifier::GArg
@ GArg
Definition: FormatString.h:151
clang::analyze_format_string::OptionalAmount::getHowSpecified
HowSpecified getHowSpecified() const
Definition: FormatString.h:359
clang::ASTContext::LongTy
CanQualType LongTy
Definition: ASTContext.h:1116
clang::RISCV::Float
@ Float
Definition: RISCVVIntrinsicUtils.h:170
clang::analyze_format_string::FormatStringHandler::HandleIncompleteScanList
virtual void HandleIncompleteScanList(const char *start, const char *end)
Definition: FormatString.h:762
clang::Type::isSignedIntegerType
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
Definition: Type.cpp:2019
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::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:773
clang::analyze_format_string
Common components of both fprintf and fscanf format strings.
Definition: FormatString.h:29
clang::analyze_format_string::ParseArgPosition
bool ParseArgPosition(FormatStringHandler &H, FormatSpecifier &CS, const char *Start, const char *&Beg, const char *E)
Definition: FormatString.cpp:143
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::ConversionSpecifier::OArg
@ OArg
Definition: FormatString.h:138
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::BuiltinType::getKind
Kind getKind() const
Definition: Type.h:2655
clang::UpdateOnReturn
Definition: FormatStringParsing.h:26
clang::analyze_format_string::FormatStringHandler::HandleIncompleteSpecifier
virtual void HandleIncompleteSpecifier(const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:716
clang
Definition: CalledOnceCheck.h:17
clang::analyze_format_string::ArgType
Definition: FormatString.h:253
clang::analyze_format_string::ConversionSpecifier::CArg
@ CArg
Definition: FormatString.h:161
ParseScanfSpecifier
static ScanfSpecifierResult ParseScanfSpecifier(FormatStringHandler &H, const char *&Beg, const char *E, unsigned &argIndex, const LangOptions &LO, const TargetInfo &Target)
Definition: ScanfFormatString.cpp:75
clang::analyze_format_string::LengthModifier::AsAllocate
@ AsAllocate
Definition: FormatString.h:81
clang::ASTContext::SignedCharTy
CanQualType SignedCharTy
Definition: ASTContext.h:1116
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::ArgType::CStrTy
@ CStrTy
Definition: FormatString.h:256
clang::ASTContext::getPointerDiffType
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Definition: ASTContext.cpp:5977
clang::analyze_format_string::ConversionSpecifier::UArg
@ UArg
Definition: FormatString.h:140
clang::analyze_format_string::ParseUTF8InvalidSpecifier
bool ParseUTF8InvalidSpecifier(const char *SpecifierBegin, const char *FmtStrEnd, unsigned &Len)
Returns true if the invalid specifier in SpecifierBegin is a UTF-8 string; check that it won't go fur...
Definition: FormatString.cpp:295
ScanfSpecifierResult
clang::analyze_format_string::SpecifierResult< ScanfSpecifier > ScanfSpecifierResult
Definition: ScanfFormatString.cpp:29
clang::analyze_format_string::FormatStringHandler::HandleScanfSpecifier
virtual bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:756
c
__device__ __2f16 float c
Definition: __clang_hip_libdevice_declares.h:320
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_scanf
Pieces specific to fscanf format strings.
Definition: FormatString.h:635
clang::analyze_format_string::OptionalAmount::NotSpecified
@ NotSpecified
Definition: FormatString.h:337
clang::analyze_format_string::LengthModifier::AsShortLong
@ AsShortLong
Definition: FormatString.h:70
clang::Type::isUnsignedIntegerType
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
Definition: Type.cpp:2069
clang::EnumType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:4842
clang::analyze_format_string::ParseAmount
OptionalAmount ParseAmount(const char *&Beg, const char *E)
Definition: FormatString.cpp:36
clang::analyze_format_string::SpecifierResult::hasValue
bool hasValue() const
Definition: FormatStringParsing.h:85
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::LengthModifier::AsPtrDiff
@ AsPtrDiff
Definition: FormatString.h:76
clang::analyze_format_string::LengthModifier::AsInt64
@ AsInt64
Definition: FormatString.h:79
clang::analyze_format_string::ArgType::WCStrTy
@ WCStrTy
Definition: FormatString.h:256