clang  3.7.0
FormatString.cpp
Go to the documentation of this file.
1 // FormatString.cpp - Common stuff for handling printf/scanf formats -*- C++ -*-
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Shared details for processing format strings of printf and scanf
11 // (and friends).
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "FormatStringParsing.h"
17 #include "clang/Basic/TargetInfo.h"
18 
26 using namespace clang;
27 
28 // Key function to FormatStringHandler.
29 FormatStringHandler::~FormatStringHandler() {}
30 
31 //===----------------------------------------------------------------------===//
32 // Functions for parsing format strings components in both printf and
33 // scanf format strings.
34 //===----------------------------------------------------------------------===//
35 
37 clang::analyze_format_string::ParseAmount(const char *&Beg, const char *E) {
38  const char *I = Beg;
39  UpdateOnReturn <const char*> UpdateBeg(Beg, I);
40 
41  unsigned accumulator = 0;
42  bool hasDigits = false;
43 
44  for ( ; I != E; ++I) {
45  char c = *I;
46  if (c >= '0' && c <= '9') {
47  hasDigits = true;
48  accumulator = (accumulator * 10) + (c - '0');
49  continue;
50  }
51 
52  if (hasDigits)
53  return OptionalAmount(OptionalAmount::Constant, accumulator, Beg, I - Beg,
54  false);
55 
56  break;
57  }
58 
59  return OptionalAmount();
60 }
61 
64  const char *E,
65  unsigned &argIndex) {
66  if (*Beg == '*') {
67  ++Beg;
68  return OptionalAmount(OptionalAmount::Arg, argIndex++, Beg, 0, false);
69  }
70 
71  return ParseAmount(Beg, E);
72 }
73 
76  const char *Start,
77  const char *&Beg,
78  const char *E,
80  if (*Beg == '*') {
81  const char *I = Beg + 1;
82  const OptionalAmount &Amt = ParseAmount(I, E);
83 
84  if (Amt.getHowSpecified() == OptionalAmount::NotSpecified) {
85  H.HandleInvalidPosition(Beg, I - Beg, p);
86  return OptionalAmount(false);
87  }
88 
89  if (I == E) {
90  // No more characters left?
91  H.HandleIncompleteSpecifier(Start, E - Start);
92  return OptionalAmount(false);
93  }
94 
95  assert(Amt.getHowSpecified() == OptionalAmount::Constant);
96 
97  if (*I == '$') {
98  // Handle positional arguments
99 
100  // Special case: '*0$', since this is an easy mistake.
101  if (Amt.getConstantAmount() == 0) {
102  H.HandleZeroPosition(Beg, I - Beg + 1);
103  return OptionalAmount(false);
104  }
105 
106  const char *Tmp = Beg;
107  Beg = ++I;
108 
109  return OptionalAmount(OptionalAmount::Arg, Amt.getConstantAmount() - 1,
110  Tmp, 0, true);
111  }
112 
113  H.HandleInvalidPosition(Beg, I - Beg, p);
114  return OptionalAmount(false);
115  }
116 
117  return ParseAmount(Beg, E);
118 }
119 
120 
121 bool
123  FormatSpecifier &CS,
124  const char *Start,
125  const char *&Beg, const char *E,
126  unsigned *argIndex) {
127  // FIXME: Support negative field widths.
128  if (argIndex) {
129  CS.setFieldWidth(ParseNonPositionAmount(Beg, E, *argIndex));
130  }
131  else {
132  const OptionalAmount Amt =
133  ParsePositionAmount(H, Start, Beg, E,
135 
136  if (Amt.isInvalid())
137  return true;
138  CS.setFieldWidth(Amt);
139  }
140  return false;
141 }
142 
143 bool
145  FormatSpecifier &FS,
146  const char *Start,
147  const char *&Beg,
148  const char *E) {
149  const char *I = Beg;
150 
151  const OptionalAmount &Amt = ParseAmount(I, E);
152 
153  if (I == E) {
154  // No more characters left?
155  H.HandleIncompleteSpecifier(Start, E - Start);
156  return true;
157  }
158 
159  if (Amt.getHowSpecified() == OptionalAmount::Constant && *(I++) == '$') {
160  // Warn that positional arguments are non-standard.
161  H.HandlePosition(Start, I - Start);
162 
163  // Special case: '%0$', since this is an easy mistake.
164  if (Amt.getConstantAmount() == 0) {
165  H.HandleZeroPosition(Start, I - Start);
166  return true;
167  }
168 
169  FS.setArgIndex(Amt.getConstantAmount() - 1);
171  // Update the caller's pointer if we decided to consume
172  // these characters.
173  Beg = I;
174  return false;
175  }
176 
177  return false;
178 }
179 
180 bool
182  const char *&I,
183  const char *E,
184  const LangOptions &LO,
185  bool IsScanf) {
187  const char *lmPosition = I;
188  switch (*I) {
189  default:
190  return false;
191  case 'h':
192  ++I;
193  lmKind = (I != E && *I == 'h') ? (++I, LengthModifier::AsChar)
194  : LengthModifier::AsShort;
195  break;
196  case 'l':
197  ++I;
198  lmKind = (I != E && *I == 'l') ? (++I, LengthModifier::AsLongLong)
199  : LengthModifier::AsLong;
200  break;
201  case 'j': lmKind = LengthModifier::AsIntMax; ++I; break;
202  case 'z': lmKind = LengthModifier::AsSizeT; ++I; break;
203  case 't': lmKind = LengthModifier::AsPtrDiff; ++I; break;
204  case 'L': lmKind = LengthModifier::AsLongDouble; ++I; break;
205  case 'q': lmKind = LengthModifier::AsQuad; ++I; break;
206  case 'a':
207  if (IsScanf && !LO.C99 && !LO.CPlusPlus11) {
208  // For scanf in C90, look at the next character to see if this should
209  // be parsed as the GNU extension 'a' length modifier. If not, this
210  // will be parsed as a conversion specifier.
211  ++I;
212  if (I != E && (*I == 's' || *I == 'S' || *I == '[')) {
213  lmKind = LengthModifier::AsAllocate;
214  break;
215  }
216  --I;
217  }
218  return false;
219  case 'm':
220  if (IsScanf) {
221  lmKind = LengthModifier::AsMAllocate;
222  ++I;
223  break;
224  }
225  return false;
226  // printf: AsInt64, AsInt32, AsInt3264
227  // scanf: AsInt64
228  case 'I':
229  if (I + 1 != E && I + 2 != E) {
230  if (I[1] == '6' && I[2] == '4') {
231  I += 3;
232  lmKind = LengthModifier::AsInt64;
233  break;
234  }
235  if (IsScanf)
236  return false;
237 
238  if (I[1] == '3' && I[2] == '2') {
239  I += 3;
240  lmKind = LengthModifier::AsInt32;
241  break;
242  }
243  }
244  ++I;
245  lmKind = LengthModifier::AsInt3264;
246  break;
247  case 'w':
248  lmKind = LengthModifier::AsWide; ++I; break;
249  }
250  LengthModifier lm(lmPosition, lmKind);
251  FS.setLengthModifier(lm);
252  return true;
253 }
254 
255 //===----------------------------------------------------------------------===//
256 // Methods on ArgType.
257 //===----------------------------------------------------------------------===//
258 
260 ArgType::matchesType(ASTContext &C, QualType argTy) const {
261  if (Ptr) {
262  // It has to be a pointer.
263  const PointerType *PT = argTy->getAs<PointerType>();
264  if (!PT)
265  return NoMatch;
266 
267  // We cannot write through a const qualified pointer.
268  if (PT->getPointeeType().isConstQualified())
269  return NoMatch;
270 
271  argTy = PT->getPointeeType();
272  }
273 
274  switch (K) {
275  case InvalidTy:
276  llvm_unreachable("ArgType must be valid");
277 
278  case UnknownTy:
279  return Match;
280 
281  case AnyCharTy: {
282  if (const EnumType *ETy = argTy->getAs<EnumType>())
283  argTy = ETy->getDecl()->getIntegerType();
284 
285  if (const BuiltinType *BT = argTy->getAs<BuiltinType>())
286  switch (BT->getKind()) {
287  default:
288  break;
289  case BuiltinType::Char_S:
290  case BuiltinType::SChar:
291  case BuiltinType::UChar:
292  case BuiltinType::Char_U:
293  return Match;
294  }
295  return NoMatch;
296  }
297 
298  case SpecificTy: {
299  if (const EnumType *ETy = argTy->getAs<EnumType>())
300  argTy = ETy->getDecl()->getIntegerType();
301  argTy = C.getCanonicalType(argTy).getUnqualifiedType();
302 
303  if (T == argTy)
304  return Match;
305  // Check for "compatible types".
306  if (const BuiltinType *BT = argTy->getAs<BuiltinType>())
307  switch (BT->getKind()) {
308  default:
309  break;
310  case BuiltinType::Char_S:
311  case BuiltinType::SChar:
312  case BuiltinType::Char_U:
313  case BuiltinType::UChar:
314  return T == C.UnsignedCharTy || T == C.SignedCharTy ? Match
315  : NoMatch;
316  case BuiltinType::Short:
317  return T == C.UnsignedShortTy ? Match : NoMatch;
318  case BuiltinType::UShort:
319  return T == C.ShortTy ? Match : NoMatch;
320  case BuiltinType::Int:
321  return T == C.UnsignedIntTy ? Match : NoMatch;
322  case BuiltinType::UInt:
323  return T == C.IntTy ? Match : NoMatch;
324  case BuiltinType::Long:
325  return T == C.UnsignedLongTy ? Match : NoMatch;
326  case BuiltinType::ULong:
327  return T == C.LongTy ? Match : NoMatch;
328  case BuiltinType::LongLong:
329  return T == C.UnsignedLongLongTy ? Match : NoMatch;
330  case BuiltinType::ULongLong:
331  return T == C.LongLongTy ? Match : NoMatch;
332  }
333  return NoMatch;
334  }
335 
336  case CStrTy: {
337  const PointerType *PT = argTy->getAs<PointerType>();
338  if (!PT)
339  return NoMatch;
340  QualType pointeeTy = PT->getPointeeType();
341  if (const BuiltinType *BT = pointeeTy->getAs<BuiltinType>())
342  switch (BT->getKind()) {
343  case BuiltinType::Void:
344  case BuiltinType::Char_U:
345  case BuiltinType::UChar:
346  case BuiltinType::Char_S:
347  case BuiltinType::SChar:
348  return Match;
349  default:
350  break;
351  }
352 
353  return NoMatch;
354  }
355 
356  case WCStrTy: {
357  const PointerType *PT = argTy->getAs<PointerType>();
358  if (!PT)
359  return NoMatch;
360  QualType pointeeTy =
361  C.getCanonicalType(PT->getPointeeType()).getUnqualifiedType();
362  return pointeeTy == C.getWideCharType() ? Match : NoMatch;
363  }
364 
365  case WIntTy: {
366 
367  QualType PromoArg =
368  argTy->isPromotableIntegerType()
369  ? C.getPromotedIntegerType(argTy) : argTy;
370 
371  QualType WInt = C.getCanonicalType(C.getWIntType()).getUnqualifiedType();
372  PromoArg = C.getCanonicalType(PromoArg).getUnqualifiedType();
373 
374  // If the promoted argument is the corresponding signed type of the
375  // wint_t type, then it should match.
376  if (PromoArg->hasSignedIntegerRepresentation() &&
377  C.getCorrespondingUnsignedType(PromoArg) == WInt)
378  return Match;
379 
380  return WInt == PromoArg ? Match : NoMatch;
381  }
382 
383  case CPointerTy:
384  if (argTy->isVoidPointerType()) {
385  return Match;
386  } if (argTy->isPointerType() || argTy->isObjCObjectPointerType() ||
387  argTy->isBlockPointerType() || argTy->isNullPtrType()) {
388  return NoMatchPedantic;
389  } else {
390  return NoMatch;
391  }
392 
393  case ObjCPointerTy: {
394  if (argTy->getAs<ObjCObjectPointerType>() ||
395  argTy->getAs<BlockPointerType>())
396  return Match;
397 
398  // Handle implicit toll-free bridging.
399  if (const PointerType *PT = argTy->getAs<PointerType>()) {
400  // Things such as CFTypeRef are really just opaque pointers
401  // to C structs representing CF types that can often be bridged
402  // to Objective-C objects. Since the compiler doesn't know which
403  // structs can be toll-free bridged, we just accept them all.
404  QualType pointee = PT->getPointeeType();
405  if (pointee->getAsStructureType() || pointee->isVoidType())
406  return Match;
407  }
408  return NoMatch;
409  }
410  }
411 
412  llvm_unreachable("Invalid ArgType Kind!");
413 }
414 
415 QualType ArgType::getRepresentativeType(ASTContext &C) const {
416  QualType Res;
417  switch (K) {
418  case InvalidTy:
419  llvm_unreachable("No representative type for Invalid ArgType");
420  case UnknownTy:
421  llvm_unreachable("No representative type for Unknown ArgType");
422  case AnyCharTy:
423  Res = C.CharTy;
424  break;
425  case SpecificTy:
426  Res = T;
427  break;
428  case CStrTy:
429  Res = C.getPointerType(C.CharTy);
430  break;
431  case WCStrTy:
432  Res = C.getPointerType(C.getWideCharType());
433  break;
434  case ObjCPointerTy:
435  Res = C.ObjCBuiltinIdTy;
436  break;
437  case CPointerTy:
438  Res = C.VoidPtrTy;
439  break;
440  case WIntTy: {
441  Res = C.getWIntType();
442  break;
443  }
444  }
445 
446  if (Ptr)
447  Res = C.getPointerType(Res);
448  return Res;
449 }
450 
451 std::string ArgType::getRepresentativeTypeName(ASTContext &C) const {
452  std::string S = getRepresentativeType(C).getAsString();
453 
454  std::string Alias;
455  if (Name) {
456  // Use a specific name for this type, e.g. "size_t".
457  Alias = Name;
458  if (Ptr) {
459  // If ArgType is actually a pointer to T, append an asterisk.
460  Alias += (Alias[Alias.size()-1] == '*') ? "*" : " *";
461  }
462  // If Alias is the same as the underlying type, e.g. wchar_t, then drop it.
463  if (S == Alias)
464  Alias.clear();
465  }
466 
467  if (!Alias.empty())
468  return std::string("'") + Alias + "' (aka '" + S + "')";
469  return std::string("'") + S + "'";
470 }
471 
472 
473 //===----------------------------------------------------------------------===//
474 // Methods on OptionalAmount.
475 //===----------------------------------------------------------------------===//
476 
477 ArgType
479  return Ctx.IntTy;
480 }
481 
482 //===----------------------------------------------------------------------===//
483 // Methods on LengthModifier.
484 //===----------------------------------------------------------------------===//
485 
486 const char *
488  switch (kind) {
489  case AsChar:
490  return "hh";
491  case AsShort:
492  return "h";
493  case AsLong: // or AsWideChar
494  return "l";
495  case AsLongLong:
496  return "ll";
497  case AsQuad:
498  return "q";
499  case AsIntMax:
500  return "j";
501  case AsSizeT:
502  return "z";
503  case AsPtrDiff:
504  return "t";
505  case AsInt32:
506  return "I32";
507  case AsInt3264:
508  return "I";
509  case AsInt64:
510  return "I64";
511  case AsLongDouble:
512  return "L";
513  case AsAllocate:
514  return "a";
515  case AsMAllocate:
516  return "m";
517  case AsWide:
518  return "w";
519  case None:
520  return "";
521  }
522  return nullptr;
523 }
524 
525 //===----------------------------------------------------------------------===//
526 // Methods on ConversionSpecifier.
527 //===----------------------------------------------------------------------===//
528 
529 const char *ConversionSpecifier::toString() const {
530  switch (kind) {
531  case dArg: return "d";
532  case DArg: return "D";
533  case iArg: return "i";
534  case oArg: return "o";
535  case OArg: return "O";
536  case uArg: return "u";
537  case UArg: return "U";
538  case xArg: return "x";
539  case XArg: return "X";
540  case fArg: return "f";
541  case FArg: return "F";
542  case eArg: return "e";
543  case EArg: return "E";
544  case gArg: return "g";
545  case GArg: return "G";
546  case aArg: return "a";
547  case AArg: return "A";
548  case cArg: return "c";
549  case sArg: return "s";
550  case pArg: return "p";
551  case nArg: return "n";
552  case PercentArg: return "%";
553  case ScanListArg: return "[";
554  case InvalidSpecifier: return nullptr;
555 
556  // POSIX unicode extensions.
557  case CArg: return "C";
558  case SArg: return "S";
559 
560  // Objective-C specific specifiers.
561  case ObjCObjArg: return "@";
562 
563  // FreeBSD kernel specific specifiers.
564  case FreeBSDbArg: return "b";
565  case FreeBSDDArg: return "D";
566  case FreeBSDrArg: return "r";
567  case FreeBSDyArg: return "y";
568 
569  // GlibC specific specifiers.
570  case PrintErrno: return "m";
571 
572  // MS specific specifiers.
573  case ZArg: return "Z";
574  }
575  return nullptr;
576 }
577 
581 
582  switch (getKind()) {
583  default:
584  return None;
585  case DArg:
586  NewKind = dArg;
587  break;
588  case UArg:
589  NewKind = uArg;
590  break;
591  case OArg:
592  NewKind = oArg;
593  break;
594  }
595 
596  ConversionSpecifier FixedCS(*this);
597  FixedCS.setKind(NewKind);
598  return FixedCS;
599 }
600 
601 //===----------------------------------------------------------------------===//
602 // Methods on OptionalAmount.
603 //===----------------------------------------------------------------------===//
604 
605 void OptionalAmount::toString(raw_ostream &os) const {
606  switch (hs) {
607  case Invalid:
608  case NotSpecified:
609  return;
610  case Arg:
611  if (UsesDotPrefix)
612  os << ".";
613  if (usesPositionalArg())
614  os << "*" << getPositionalArgIndex() << "$";
615  else
616  os << "*";
617  break;
618  case Constant:
619  if (UsesDotPrefix)
620  os << ".";
621  os << amt;
622  break;
623  }
624 }
625 
627  switch (LM.getKind()) {
629  return true;
630 
631  // Handle most integer flags
633  if (Target.getTriple().isOSMSVCRT()) {
634  switch (CS.getKind()) {
640  return true;
641  default:
642  break;
643  }
644  }
645  // Fall through.
652  switch (CS.getKind()) {
663  return true;
666  return Target.getTriple().isOSFreeBSD();
667  default:
668  return false;
669  }
670 
671  // Handle 'l' flag
672  case LengthModifier::AsLong: // or AsWideChar
673  switch (CS.getKind()) {
696  return true;
699  return Target.getTriple().isOSFreeBSD();
700  default:
701  return false;
702  }
703 
705  switch (CS.getKind()) {
714  return true;
715  // GNU libc extension.
722  return !Target.getTriple().isOSDarwin() &&
723  !Target.getTriple().isOSWindows();
724  default:
725  return false;
726  }
727 
729  switch (CS.getKind()) {
733  return true;
734  default:
735  return false;
736  }
737 
739  switch (CS.getKind()) {
745  return true;
746  default:
747  return false;
748  }
752  switch (CS.getKind()) {
759  return Target.getTriple().isOSMSVCRT();
760  default:
761  return false;
762  }
764  switch (CS.getKind()) {
770  return Target.getTriple().isOSMSVCRT();
771  default:
772  return false;
773  }
774  }
775  llvm_unreachable("Invalid LengthModifier Kind!");
776 }
777 
779  switch (LM.getKind()) {
789  return true;
797  return false;
798  }
799  llvm_unreachable("Invalid LengthModifier Kind!");
800 }
801 
803  const LangOptions &LangOpt) const {
804  switch (CS.getKind()) {
826  return true;
829  return LangOpt.ObjC1 || LangOpt.ObjC2;
840  return false;
841  }
842  llvm_unreachable("Invalid ConversionSpecifier Kind!");
843 }
844 
847  switch(CS.getKind()) {
854  return false;
855  default:
856  return true;
857  }
858  }
859  return true;
860 }
861 
866  LengthModifier FixedLM(LM);
868  return FixedLM;
869  }
870  }
871 
872  return None;
873 }
874 
876  LengthModifier &LM) {
877  assert(isa<TypedefType>(QT) && "Expected a TypedefType");
878  const TypedefNameDecl *Typedef = cast<TypedefType>(QT)->getDecl();
879 
880  for (;;) {
881  const IdentifierInfo *Identifier = Typedef->getIdentifier();
882  if (Identifier->getName() == "size_t") {
884  return true;
885  } else if (Identifier->getName() == "ssize_t") {
886  // Not C99, but common in Unix.
888  return true;
889  } else if (Identifier->getName() == "intmax_t") {
891  return true;
892  } else if (Identifier->getName() == "uintmax_t") {
894  return true;
895  } else if (Identifier->getName() == "ptrdiff_t") {
897  return true;
898  }
899 
900  QualType T = Typedef->getUnderlyingType();
901  if (!isa<TypedefType>(T))
902  break;
903 
904  Typedef = cast<TypedefType>(T)->getDecl();
905  }
906  return false;
907 }
virtual void HandlePosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:614
CanQualType LongLongTy
Definition: ASTContext.h:825
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
bool isNullPtrType() const
Definition: Type.h:5439
CanQualType VoidPtrTy
Definition: ASTContext.h:831
IdentifierInfo * getIdentifier() const
Definition: Decl.h:163
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Optional< LengthModifier > getCorrectedLengthModifier() const
bool hasStandardConversionSpecifier(const LangOptions &LangOpt) const
QualType getUnderlyingType() const
Definition: Decl.h:2616
virtual void HandleZeroPosition(const char *startPos, unsigned posLen)
Definition: FormatString.h:619
bool isVoidPointerType() const
Definition: Type.cpp:384
bool ParseArgPosition(FormatStringHandler &H, FormatSpecifier &CS, const char *Start, const char *&Beg, const char *E)
CanQualType LongTy
Definition: ASTContext.h:825
bool isBlockPointerType() const
Definition: Type.h:5238
bool isVoidType() const
Definition: Type.h:5426
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:89
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
void setFieldWidth(const OptionalAmount &Amt)
Definition: FormatString.h:376
Optional< ConversionSpecifier > getStandardSpecifier() const
Represents the length modifier in a format string in scanf/printf.
Definition: FormatString.h:65
CanQualType UnsignedCharTy
Definition: ASTContext.h:826
OptionalAmount ParseNonPositionAmount(const char *&Beg, const char *E, unsigned &argIndex)
QualType getPointeeType() const
Definition: Type.cpp:414
Exposes information about the current target.
Defines the clang::LangOptions interface.
StringRef getName() const
Return the actual identifier string.
QualType getWIntType() const
In C99, this returns a type compatible with the type defined in <stddef.h> as defined by the target...
Definition: ASTContext.h:1278
CanQualType ShortTy
Definition: ASTContext.h:825
QualType getWideCharType() const
Return the type of wide characters. In C++, this returns the unique wchar_t type. In C99...
Definition: ASTContext.h:1264
CanQualType SignedCharTy
Definition: ASTContext.h:825
virtual void HandleInvalidPosition(const char *startPos, unsigned posLen, PositionContext p)
Definition: FormatString.h:616
static bool namedTypeToLengthModifier(QualType QT, LengthModifier &LM)
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
Definition: Type.cpp:2275
bool ParseFieldWidth(FormatStringHandler &H, FormatSpecifier &CS, const char *Start, const char *&Beg, const char *E, unsigned *argIndex)
QualType getPointeeType() const
Definition: Type.h:2139
CanQualType UnsignedShortTy
Definition: ASTContext.h:826
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2576
CanQualType CharTy
Definition: ASTContext.h:819
CanQualType ObjCBuiltinIdTy
Definition: ASTContext.h:835
static __inline__ uint32_t volatile uint32_t * p
Definition: arm_acle.h:75
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:827
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:1855
QualType getCorrespondingUnsignedType(QualType T) const
const RecordType * getAsStructureType() const
Definition: Type.cpp:430
const T * getAs() const
Definition: Type.h:5555
CanQualType UnsignedLongTy
Definition: ASTContext.h:826
bool ParseLengthModifier(FormatSpecifier &FS, const char *&Beg, const char *E, const LangOptions &LO, bool IsScanf=false)
bool isObjCObjectPointerType() const
Definition: Type.h:5304
virtual void HandleIncompleteSpecifier(const char *startSpecifier, unsigned specifierLen)
Definition: FormatString.h:621
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:43
Defines the clang::TargetInfo interface.
OptionalAmount ParseAmount(const char *&Beg, const char *E)
CanQualType IntTy
Definition: ASTContext.h:825
ArgType getArgType(ASTContext &Ctx) const
bool hasValidLengthModifier(const TargetInfo &Target) const
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition: Type.h:5075
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
Definition: Type.cpp:1713
CanQualType UnsignedIntTy
Definition: ASTContext.h:826
OptionalAmount ParsePositionAmount(FormatStringHandler &H, const char *Start, const char *&Beg, const char *E, PositionContext p)
bool isPointerType() const
Definition: Type.h:5232