clang  10.0.0svn
ODRHash.cpp
Go to the documentation of this file.
1 //===-- ODRHash.cpp - Hashing to diagnose ODR failures ----------*- 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 /// \file
10 /// This file implements the ODRHash class, which calculates a hash based
11 /// on AST nodes, which is stable across different runs.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #include "clang/AST/ODRHash.h"
16 
17 #include "clang/AST/DeclVisitor.h"
19 #include "clang/AST/StmtVisitor.h"
20 #include "clang/AST/TypeVisitor.h"
21 
22 using namespace clang;
23 
24 void ODRHash::AddStmt(const Stmt *S) {
25  assert(S && "Expecting non-null pointer.");
26  S->ProcessODRHash(ID, *this);
27 }
28 
30  assert(II && "Expecting non-null pointer.");
31  ID.AddString(II->getName());
32 }
33 
34 void ODRHash::AddDeclarationName(DeclarationName Name, bool TreatAsDecl) {
35  if (TreatAsDecl)
36  // Matches the NamedDecl check in AddDecl
37  AddBoolean(true);
38 
39  AddDeclarationNameImpl(Name);
40 
41  if (TreatAsDecl)
42  // Matches the ClassTemplateSpecializationDecl check in AddDecl
43  AddBoolean(false);
44 }
45 
46 void ODRHash::AddDeclarationNameImpl(DeclarationName Name) {
47  // Index all DeclarationName and use index numbers to refer to them.
48  auto Result = DeclNameMap.insert(std::make_pair(Name, DeclNameMap.size()));
49  ID.AddInteger(Result.first->second);
50  if (!Result.second) {
51  // If found in map, the DeclarationName has previously been processed.
52  return;
53  }
54 
55  // First time processing each DeclarationName, also process its details.
56  AddBoolean(Name.isEmpty());
57  if (Name.isEmpty())
58  return;
59 
60  auto Kind = Name.getNameKind();
61  ID.AddInteger(Kind);
62  switch (Kind) {
65  break;
69  Selector S = Name.getObjCSelector();
70  AddBoolean(S.isNull());
73  unsigned NumArgs = S.getNumArgs();
74  ID.AddInteger(NumArgs);
75  for (unsigned i = 0; i < NumArgs; ++i) {
77  AddBoolean(II);
78  if (II) {
80  }
81  }
82  break;
83  }
87  break;
89  ID.AddInteger(Name.getCXXOverloadedOperator());
90  break;
93  break;
96  break;
98  break;
100  auto *Template = Name.getCXXDeductionGuideTemplate();
101  AddBoolean(Template);
102  if (Template) {
103  AddDecl(Template);
104  }
105  }
106  }
107 }
108 
110  assert(NNS && "Expecting non-null pointer.");
111  const auto *Prefix = NNS->getPrefix();
112  AddBoolean(Prefix);
113  if (Prefix) {
114  AddNestedNameSpecifier(Prefix);
115  }
116  auto Kind = NNS->getKind();
117  ID.AddInteger(Kind);
118  switch (Kind) {
121  break;
123  AddDecl(NNS->getAsNamespace());
124  break;
127  break;
130  AddType(NNS->getAsType());
131  break;
134  break;
135  }
136 }
137 
139  auto Kind = Name.getKind();
140  ID.AddInteger(Kind);
141 
142  switch (Kind) {
144  AddDecl(Name.getAsTemplateDecl());
145  break;
146  // TODO: Support these cases.
153  break;
154  }
155 }
156 
158  const auto Kind = TA.getKind();
159  ID.AddInteger(Kind);
160 
161  switch (Kind) {
163  llvm_unreachable("Expected valid TemplateArgument");
165  AddQualType(TA.getAsType());
166  break;
168  AddDecl(TA.getAsDecl());
169  break;
172  break;
176  break;
178  AddStmt(TA.getAsExpr());
179  break;
181  ID.AddInteger(TA.pack_size());
182  for (auto SubTA : TA.pack_elements()) {
183  AddTemplateArgument(SubTA);
184  }
185  break;
186  }
187 }
188 
190  assert(TPL && "Expecting non-null pointer.");
191 
192  ID.AddInteger(TPL->size());
193  for (auto *ND : TPL->asArray()) {
194  AddSubDecl(ND);
195  }
196 }
197 
199  DeclNameMap.clear();
200  Bools.clear();
201  ID.clear();
202 }
203 
205  // Append the bools to the end of the data segment backwards. This allows
206  // for the bools data to be compressed 32 times smaller compared to using
207  // ID.AddBoolean
208  const unsigned unsigned_bits = sizeof(unsigned) * CHAR_BIT;
209  const unsigned size = Bools.size();
210  const unsigned remainder = size % unsigned_bits;
211  const unsigned loops = size / unsigned_bits;
212  auto I = Bools.rbegin();
213  unsigned value = 0;
214  for (unsigned i = 0; i < remainder; ++i) {
215  value <<= 1;
216  value |= *I;
217  ++I;
218  }
219  ID.AddInteger(value);
220 
221  for (unsigned i = 0; i < loops; ++i) {
222  value = 0;
223  for (unsigned j = 0; j < unsigned_bits; ++j) {
224  value <<= 1;
225  value |= *I;
226  ++I;
227  }
228  ID.AddInteger(value);
229  }
230 
231  assert(I == Bools.rend());
232  Bools.clear();
233  return ID.ComputeHash();
234 }
235 
236 namespace {
237 // Process a Decl pointer. Add* methods call back into ODRHash while Visit*
238 // methods process the relevant parts of the Decl.
239 class ODRDeclVisitor : public ConstDeclVisitor<ODRDeclVisitor> {
240  typedef ConstDeclVisitor<ODRDeclVisitor> Inherited;
241  llvm::FoldingSetNodeID &ID;
242  ODRHash &Hash;
243 
244 public:
245  ODRDeclVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
246  : ID(ID), Hash(Hash) {}
247 
248  void AddStmt(const Stmt *S) {
249  Hash.AddBoolean(S);
250  if (S) {
251  Hash.AddStmt(S);
252  }
253  }
254 
255  void AddIdentifierInfo(const IdentifierInfo *II) {
256  Hash.AddBoolean(II);
257  if (II) {
258  Hash.AddIdentifierInfo(II);
259  }
260  }
261 
262  void AddQualType(QualType T) {
263  Hash.AddQualType(T);
264  }
265 
266  void AddDecl(const Decl *D) {
267  Hash.AddBoolean(D);
268  if (D) {
269  Hash.AddDecl(D);
270  }
271  }
272 
274  Hash.AddTemplateArgument(TA);
275  }
276 
277  void Visit(const Decl *D) {
278  ID.AddInteger(D->getKind());
279  Inherited::Visit(D);
280  }
281 
282  void VisitNamedDecl(const NamedDecl *D) {
283  Hash.AddDeclarationName(D->getDeclName());
284  Inherited::VisitNamedDecl(D);
285  }
286 
287  void VisitValueDecl(const ValueDecl *D) {
288  if (!isa<FunctionDecl>(D)) {
289  AddQualType(D->getType());
290  }
291  Inherited::VisitValueDecl(D);
292  }
293 
294  void VisitVarDecl(const VarDecl *D) {
295  Hash.AddBoolean(D->isStaticLocal());
296  Hash.AddBoolean(D->isConstexpr());
297  const bool HasInit = D->hasInit();
298  Hash.AddBoolean(HasInit);
299  if (HasInit) {
300  AddStmt(D->getInit());
301  }
302  Inherited::VisitVarDecl(D);
303  }
304 
305  void VisitParmVarDecl(const ParmVarDecl *D) {
306  // TODO: Handle default arguments.
307  Inherited::VisitParmVarDecl(D);
308  }
309 
310  void VisitAccessSpecDecl(const AccessSpecDecl *D) {
311  ID.AddInteger(D->getAccess());
312  Inherited::VisitAccessSpecDecl(D);
313  }
314 
315  void VisitStaticAssertDecl(const StaticAssertDecl *D) {
316  AddStmt(D->getAssertExpr());
317  AddStmt(D->getMessage());
318 
319  Inherited::VisitStaticAssertDecl(D);
320  }
321 
322  void VisitFieldDecl(const FieldDecl *D) {
323  const bool IsBitfield = D->isBitField();
324  Hash.AddBoolean(IsBitfield);
325 
326  if (IsBitfield) {
327  AddStmt(D->getBitWidth());
328  }
329 
330  Hash.AddBoolean(D->isMutable());
332 
333  Inherited::VisitFieldDecl(D);
334  }
335 
336  void VisitFunctionDecl(const FunctionDecl *D) {
337  // Handled by the ODRHash for FunctionDecl
338  ID.AddInteger(D->getODRHash());
339 
340  Inherited::VisitFunctionDecl(D);
341  }
342 
343  void VisitCXXMethodDecl(const CXXMethodDecl *D) {
344  // Handled by the ODRHash for FunctionDecl
345 
346  Inherited::VisitCXXMethodDecl(D);
347  }
348 
349  void VisitTypedefNameDecl(const TypedefNameDecl *D) {
351 
352  Inherited::VisitTypedefNameDecl(D);
353  }
354 
355  void VisitTypedefDecl(const TypedefDecl *D) {
356  Inherited::VisitTypedefDecl(D);
357  }
358 
359  void VisitTypeAliasDecl(const TypeAliasDecl *D) {
360  Inherited::VisitTypeAliasDecl(D);
361  }
362 
363  void VisitFriendDecl(const FriendDecl *D) {
364  TypeSourceInfo *TSI = D->getFriendType();
365  Hash.AddBoolean(TSI);
366  if (TSI) {
367  AddQualType(TSI->getType());
368  } else {
369  AddDecl(D->getFriendDecl());
370  }
371  }
372 
373  void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
374  // Only care about default arguments as part of the definition.
375  const bool hasDefaultArgument =
377  Hash.AddBoolean(hasDefaultArgument);
378  if (hasDefaultArgument) {
380  }
381  Hash.AddBoolean(D->isParameterPack());
382 
383  Inherited::VisitTemplateTypeParmDecl(D);
384  }
385 
386  void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) {
387  // Only care about default arguments as part of the definition.
388  const bool hasDefaultArgument =
390  Hash.AddBoolean(hasDefaultArgument);
391  if (hasDefaultArgument) {
393  }
394  Hash.AddBoolean(D->isParameterPack());
395 
396  Inherited::VisitNonTypeTemplateParmDecl(D);
397  }
398 
399  void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) {
400  // Only care about default arguments as part of the definition.
401  const bool hasDefaultArgument =
403  Hash.AddBoolean(hasDefaultArgument);
404  if (hasDefaultArgument) {
406  }
407  Hash.AddBoolean(D->isParameterPack());
408 
409  Inherited::VisitTemplateTemplateParmDecl(D);
410  }
411 
412  void VisitTemplateDecl(const TemplateDecl *D) {
414 
415  Inherited::VisitTemplateDecl(D);
416  }
417 
418  void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *D) {
420  Inherited::VisitRedeclarableTemplateDecl(D);
421  }
422 
423  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
425  ID.AddInteger(D->getTemplatedDecl()->getODRHash());
426  Inherited::VisitFunctionTemplateDecl(D);
427  }
428 
429  void VisitEnumConstantDecl(const EnumConstantDecl *D) {
430  AddStmt(D->getInitExpr());
431  Inherited::VisitEnumConstantDecl(D);
432  }
433 };
434 } // namespace
435 
436 // Only allow a small portion of Decl's to be processed. Remove this once
437 // all Decl's can be handled.
439  if (D->isImplicit()) return false;
440  if (D->getDeclContext() != Parent) return false;
441 
442  switch (D->getKind()) {
443  default:
444  return false;
445  case Decl::AccessSpec:
446  case Decl::CXXConstructor:
447  case Decl::CXXDestructor:
448  case Decl::CXXMethod:
449  case Decl::EnumConstant: // Only found in EnumDecl's.
450  case Decl::Field:
451  case Decl::Friend:
452  case Decl::FunctionTemplate:
453  case Decl::StaticAssert:
454  case Decl::TypeAlias:
455  case Decl::Typedef:
456  case Decl::Var:
457  return true;
458  }
459 }
460 
461 void ODRHash::AddSubDecl(const Decl *D) {
462  assert(D && "Expecting non-null pointer.");
463 
464  ODRDeclVisitor(ID, *this).Visit(D);
465 }
466 
468  assert(Record && Record->hasDefinition() &&
469  "Expected non-null record to be a definition.");
470 
471  const DeclContext *DC = Record;
472  while (DC) {
473  if (isa<ClassTemplateSpecializationDecl>(DC)) {
474  return;
475  }
476  DC = DC->getParent();
477  }
478 
479  AddDecl(Record);
480 
481  // Filter out sub-Decls which will not be processed in order to get an
482  // accurate count of Decl's.
484  for (Decl *SubDecl : Record->decls()) {
485  if (isWhitelistedDecl(SubDecl, Record)) {
486  Decls.push_back(SubDecl);
487  if (auto *Function = dyn_cast<FunctionDecl>(SubDecl)) {
488  // Compute/Preload ODRHash into FunctionDecl.
489  Function->getODRHash();
490  }
491  }
492  }
493 
494  ID.AddInteger(Decls.size());
495  for (auto SubDecl : Decls) {
496  AddSubDecl(SubDecl);
497  }
498 
499  const ClassTemplateDecl *TD = Record->getDescribedClassTemplate();
500  AddBoolean(TD);
501  if (TD) {
503  }
504 
505  ID.AddInteger(Record->getNumBases());
506  auto Bases = Record->bases();
507  for (auto Base : Bases) {
508  AddQualType(Base.getType());
509  ID.AddInteger(Base.isVirtual());
510  ID.AddInteger(Base.getAccessSpecifierAsWritten());
511  }
512 }
513 
515  bool SkipBody) {
516  assert(Function && "Expecting non-null pointer.");
517 
518  // Skip functions that are specializations or in specialization context.
519  const DeclContext *DC = Function;
520  while (DC) {
521  if (isa<ClassTemplateSpecializationDecl>(DC)) return;
522  if (auto *F = dyn_cast<FunctionDecl>(DC)) {
523  if (F->isFunctionTemplateSpecialization()) {
524  if (!isa<CXXMethodDecl>(DC)) return;
525  if (DC->getLexicalParent()->isFileContext()) return;
526  // Inline method specializations are the only supported
527  // specialization for now.
528  }
529  }
530  DC = DC->getParent();
531  }
532 
533  ID.AddInteger(Function->getDeclKind());
534 
535  const auto *SpecializationArgs = Function->getTemplateSpecializationArgs();
536  AddBoolean(SpecializationArgs);
537  if (SpecializationArgs) {
538  ID.AddInteger(SpecializationArgs->size());
539  for (const TemplateArgument &TA : SpecializationArgs->asArray()) {
541  }
542  }
543 
544  if (const auto *Method = dyn_cast<CXXMethodDecl>(Function)) {
545  AddBoolean(Method->isConst());
546  AddBoolean(Method->isVolatile());
547  }
548 
549  ID.AddInteger(Function->getStorageClass());
550  AddBoolean(Function->isInlineSpecified());
551  AddBoolean(Function->isVirtualAsWritten());
552  AddBoolean(Function->isPure());
553  AddBoolean(Function->isDeletedAsWritten());
554  AddBoolean(Function->isExplicitlyDefaulted());
555 
556  AddDecl(Function);
557 
558  AddQualType(Function->getReturnType());
559 
560  ID.AddInteger(Function->param_size());
561  for (auto Param : Function->parameters())
562  AddSubDecl(Param);
563 
564  if (SkipBody) {
565  AddBoolean(false);
566  return;
567  }
568 
569  const bool HasBody = Function->isThisDeclarationADefinition() &&
570  !Function->isDefaulted() && !Function->isDeleted() &&
571  !Function->isLateTemplateParsed();
572  AddBoolean(HasBody);
573  if (!HasBody) {
574  return;
575  }
576 
577  auto *Body = Function->getBody();
578  AddBoolean(Body);
579  if (Body)
580  AddStmt(Body);
581 
582  // Filter out sub-Decls which will not be processed in order to get an
583  // accurate count of Decl's.
585  for (Decl *SubDecl : Function->decls()) {
586  if (isWhitelistedDecl(SubDecl, Function)) {
587  Decls.push_back(SubDecl);
588  }
589  }
590 
591  ID.AddInteger(Decls.size());
592  for (auto SubDecl : Decls) {
593  AddSubDecl(SubDecl);
594  }
595 }
596 
597 void ODRHash::AddEnumDecl(const EnumDecl *Enum) {
598  assert(Enum);
600 
601  AddBoolean(Enum->isScoped());
602  if (Enum->isScoped())
604 
605  if (Enum->getIntegerTypeSourceInfo())
606  AddQualType(Enum->getIntegerType());
607 
608  // Filter out sub-Decls which will not be processed in order to get an
609  // accurate count of Decl's.
611  for (Decl *SubDecl : Enum->decls()) {
612  if (isWhitelistedDecl(SubDecl, Enum)) {
613  assert(isa<EnumConstantDecl>(SubDecl) && "Unexpected Decl");
614  Decls.push_back(SubDecl);
615  }
616  }
617 
618  ID.AddInteger(Decls.size());
619  for (auto SubDecl : Decls) {
620  AddSubDecl(SubDecl);
621  }
622 
623 }
624 
625 void ODRHash::AddDecl(const Decl *D) {
626  assert(D && "Expecting non-null pointer.");
627  D = D->getCanonicalDecl();
628 
629  const NamedDecl *ND = dyn_cast<NamedDecl>(D);
630  AddBoolean(ND);
631  if (!ND) {
632  ID.AddInteger(D->getKind());
633  return;
634  }
635 
637 
638  const auto *Specialization =
639  dyn_cast<ClassTemplateSpecializationDecl>(D);
640  AddBoolean(Specialization);
641  if (Specialization) {
642  const TemplateArgumentList &List = Specialization->getTemplateArgs();
643  ID.AddInteger(List.size());
644  for (const TemplateArgument &TA : List.asArray())
646  }
647 }
648 
649 namespace {
650 // Process a Type pointer. Add* methods call back into ODRHash while Visit*
651 // methods process the relevant parts of the Type.
652 class ODRTypeVisitor : public TypeVisitor<ODRTypeVisitor> {
653  typedef TypeVisitor<ODRTypeVisitor> Inherited;
654  llvm::FoldingSetNodeID &ID;
655  ODRHash &Hash;
656 
657 public:
658  ODRTypeVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
659  : ID(ID), Hash(Hash) {}
660 
661  void AddStmt(Stmt *S) {
662  Hash.AddBoolean(S);
663  if (S) {
664  Hash.AddStmt(S);
665  }
666  }
667 
668  void AddDecl(Decl *D) {
669  Hash.AddBoolean(D);
670  if (D) {
671  Hash.AddDecl(D);
672  }
673  }
674 
675  void AddQualType(QualType T) {
676  Hash.AddQualType(T);
677  }
678 
679  void AddType(const Type *T) {
680  Hash.AddBoolean(T);
681  if (T) {
682  Hash.AddType(T);
683  }
684  }
685 
687  Hash.AddBoolean(NNS);
688  if (NNS) {
689  Hash.AddNestedNameSpecifier(NNS);
690  }
691  }
692 
693  void AddIdentifierInfo(const IdentifierInfo *II) {
694  Hash.AddBoolean(II);
695  if (II) {
696  Hash.AddIdentifierInfo(II);
697  }
698  }
699 
700  void VisitQualifiers(Qualifiers Quals) {
701  ID.AddInteger(Quals.getAsOpaqueValue());
702  }
703 
704  // Return the RecordType if the typedef only strips away a keyword.
705  // Otherwise, return the original type.
706  static const Type *RemoveTypedef(const Type *T) {
707  const auto *TypedefT = dyn_cast<TypedefType>(T);
708  if (!TypedefT) {
709  return T;
710  }
711 
712  const TypedefNameDecl *D = TypedefT->getDecl();
713  QualType UnderlyingType = D->getUnderlyingType();
714 
715  if (UnderlyingType.hasLocalQualifiers()) {
716  return T;
717  }
718 
719  const auto *ElaboratedT = dyn_cast<ElaboratedType>(UnderlyingType);
720  if (!ElaboratedT) {
721  return T;
722  }
723 
724  if (ElaboratedT->getQualifier() != nullptr) {
725  return T;
726  }
727 
728  QualType NamedType = ElaboratedT->getNamedType();
729  if (NamedType.hasLocalQualifiers()) {
730  return T;
731  }
732 
733  const auto *RecordT = dyn_cast<RecordType>(NamedType);
734  if (!RecordT) {
735  return T;
736  }
737 
738  const IdentifierInfo *TypedefII = TypedefT->getDecl()->getIdentifier();
739  const IdentifierInfo *RecordII = RecordT->getDecl()->getIdentifier();
740  if (!TypedefII || !RecordII ||
741  TypedefII->getName() != RecordII->getName()) {
742  return T;
743  }
744 
745  return RecordT;
746  }
747 
748  void Visit(const Type *T) {
749  T = RemoveTypedef(T);
750  ID.AddInteger(T->getTypeClass());
751  Inherited::Visit(T);
752  }
753 
754  void VisitType(const Type *T) {}
755 
756  void VisitAdjustedType(const AdjustedType *T) {
757  QualType Original = T->getOriginalType();
758  QualType Adjusted = T->getAdjustedType();
759 
760  // The original type and pointee type can be the same, as in the case of
761  // function pointers decaying to themselves. Set a bool and only process
762  // the type once, to prevent doubling the work.
763  SplitQualType split = Adjusted.split();
764  if (auto Pointer = dyn_cast<PointerType>(split.Ty)) {
765  if (Pointer->getPointeeType() == Original) {
766  Hash.AddBoolean(true);
767  ID.AddInteger(split.Quals.getAsOpaqueValue());
768  AddQualType(Original);
769  VisitType(T);
770  return;
771  }
772  }
773 
774  // The original type and pointee type are different, such as in the case
775  // of a array decaying to an element pointer. Set a bool to false and
776  // process both types.
777  Hash.AddBoolean(false);
778  AddQualType(Original);
779  AddQualType(Adjusted);
780 
781  VisitType(T);
782  }
783 
784  void VisitDecayedType(const DecayedType *T) {
785  // getDecayedType and getPointeeType are derived from getAdjustedType
786  // and don't need to be separately processed.
787  VisitAdjustedType(T);
788  }
789 
790  void VisitArrayType(const ArrayType *T) {
792  ID.AddInteger(T->getSizeModifier());
793  VisitQualifiers(T->getIndexTypeQualifiers());
794  VisitType(T);
795  }
796  void VisitConstantArrayType(const ConstantArrayType *T) {
797  T->getSize().Profile(ID);
798  VisitArrayType(T);
799  }
800 
801  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
802  AddStmt(T->getSizeExpr());
803  VisitArrayType(T);
804  }
805 
806  void VisitIncompleteArrayType(const IncompleteArrayType *T) {
807  VisitArrayType(T);
808  }
809 
810  void VisitVariableArrayType(const VariableArrayType *T) {
811  AddStmt(T->getSizeExpr());
812  VisitArrayType(T);
813  }
814 
815  void VisitAttributedType(const AttributedType *T) {
816  ID.AddInteger(T->getAttrKind());
819 
820  VisitType(T);
821  }
822 
823  void VisitBlockPointerType(const BlockPointerType *T) {
825  VisitType(T);
826  }
827 
828  void VisitBuiltinType(const BuiltinType *T) {
829  ID.AddInteger(T->getKind());
830  VisitType(T);
831  }
832 
833  void VisitComplexType(const ComplexType *T) {
835  VisitType(T);
836  }
837 
838  void VisitDecltypeType(const DecltypeType *T) {
841  VisitType(T);
842  }
843 
844  void VisitDependentDecltypeType(const DependentDecltypeType *T) {
845  VisitDecltypeType(T);
846  }
847 
848  void VisitDeducedType(const DeducedType *T) {
850  VisitType(T);
851  }
852 
853  void VisitAutoType(const AutoType *T) {
854  ID.AddInteger((unsigned)T->getKeyword());
855  VisitDeducedType(T);
856  }
857 
858  void VisitDeducedTemplateSpecializationType(
860  Hash.AddTemplateName(T->getTemplateName());
861  VisitDeducedType(T);
862  }
863 
864  void VisitDependentAddressSpaceType(const DependentAddressSpaceType *T) {
867  VisitType(T);
868  }
869 
870  void VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T) {
872  AddStmt(T->getSizeExpr());
873  VisitType(T);
874  }
875 
876  void VisitFunctionType(const FunctionType *T) {
878  T->getExtInfo().Profile(ID);
879  Hash.AddBoolean(T->isConst());
880  Hash.AddBoolean(T->isVolatile());
881  Hash.AddBoolean(T->isRestrict());
882  VisitType(T);
883  }
884 
885  void VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
886  VisitFunctionType(T);
887  }
888 
889  void VisitFunctionProtoType(const FunctionProtoType *T) {
890  ID.AddInteger(T->getNumParams());
891  for (auto ParamType : T->getParamTypes())
892  AddQualType(ParamType);
893 
894  VisitFunctionType(T);
895  }
896 
897  void VisitInjectedClassNameType(const InjectedClassNameType *T) {
898  AddDecl(T->getDecl());
899  VisitType(T);
900  }
901 
902  void VisitMemberPointerType(const MemberPointerType *T) {
904  AddType(T->getClass());
905  VisitType(T);
906  }
907 
908  void VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
910  VisitType(T);
911  }
912 
913  void VisitObjCObjectType(const ObjCObjectType *T) {
914  AddDecl(T->getInterface());
915 
916  auto TypeArgs = T->getTypeArgsAsWritten();
917  ID.AddInteger(TypeArgs.size());
918  for (auto Arg : TypeArgs) {
919  AddQualType(Arg);
920  }
921 
922  auto Protocols = T->getProtocols();
923  ID.AddInteger(Protocols.size());
924  for (auto Protocol : Protocols) {
925  AddDecl(Protocol);
926  }
927 
928  Hash.AddBoolean(T->isKindOfType());
929 
930  VisitType(T);
931  }
932 
933  void VisitObjCInterfaceType(const ObjCInterfaceType *T) {
934  // This type is handled by the parent type ObjCObjectType.
935  VisitObjCObjectType(T);
936  }
937 
938  void VisitObjCTypeParamType(const ObjCTypeParamType *T) {
939  AddDecl(T->getDecl());
940  auto Protocols = T->getProtocols();
941  ID.AddInteger(Protocols.size());
942  for (auto Protocol : Protocols) {
943  AddDecl(Protocol);
944  }
945 
946  VisitType(T);
947  }
948 
949  void VisitPackExpansionType(const PackExpansionType *T) {
950  AddQualType(T->getPattern());
951  VisitType(T);
952  }
953 
954  void VisitParenType(const ParenType *T) {
956  VisitType(T);
957  }
958 
959  void VisitPipeType(const PipeType *T) {
961  Hash.AddBoolean(T->isReadOnly());
962  VisitType(T);
963  }
964 
965  void VisitPointerType(const PointerType *T) {
967  VisitType(T);
968  }
969 
970  void VisitReferenceType(const ReferenceType *T) {
972  VisitType(T);
973  }
974 
975  void VisitLValueReferenceType(const LValueReferenceType *T) {
976  VisitReferenceType(T);
977  }
978 
979  void VisitRValueReferenceType(const RValueReferenceType *T) {
980  VisitReferenceType(T);
981  }
982 
983  void
984  VisitSubstTemplateTypeParmPackType(const SubstTemplateTypeParmPackType *T) {
987  VisitType(T);
988  }
989 
990  void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
993  VisitType(T);
994  }
995 
996  void VisitTagType(const TagType *T) {
997  AddDecl(T->getDecl());
998  VisitType(T);
999  }
1000 
1001  void VisitRecordType(const RecordType *T) { VisitTagType(T); }
1002  void VisitEnumType(const EnumType *T) { VisitTagType(T); }
1003 
1004  void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
1005  ID.AddInteger(T->getNumArgs());
1006  for (const auto &TA : T->template_arguments()) {
1007  Hash.AddTemplateArgument(TA);
1008  }
1009  Hash.AddTemplateName(T->getTemplateName());
1010  VisitType(T);
1011  }
1012 
1013  void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
1014  ID.AddInteger(T->getDepth());
1015  ID.AddInteger(T->getIndex());
1016  Hash.AddBoolean(T->isParameterPack());
1017  AddDecl(T->getDecl());
1018  }
1019 
1020  void VisitTypedefType(const TypedefType *T) {
1021  AddDecl(T->getDecl());
1022  QualType UnderlyingType = T->getDecl()->getUnderlyingType();
1023  VisitQualifiers(UnderlyingType.getQualifiers());
1024  while (true) {
1025  if (const TypedefType *Underlying =
1026  dyn_cast<TypedefType>(UnderlyingType.getTypePtr())) {
1027  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
1028  continue;
1029  }
1030  if (const ElaboratedType *Underlying =
1031  dyn_cast<ElaboratedType>(UnderlyingType.getTypePtr())) {
1032  UnderlyingType = Underlying->getNamedType();
1033  continue;
1034  }
1035 
1036  break;
1037  }
1038  AddType(UnderlyingType.getTypePtr());
1039  VisitType(T);
1040  }
1041 
1042  void VisitTypeOfExprType(const TypeOfExprType *T) {
1043  AddStmt(T->getUnderlyingExpr());
1044  Hash.AddBoolean(T->isSugared());
1045  if (T->isSugared())
1046  AddQualType(T->desugar());
1047 
1048  VisitType(T);
1049  }
1050  void VisitTypeOfType(const TypeOfType *T) {
1052  VisitType(T);
1053  }
1054 
1055  void VisitTypeWithKeyword(const TypeWithKeyword *T) {
1056  ID.AddInteger(T->getKeyword());
1057  VisitType(T);
1058  };
1059 
1060  void VisitDependentNameType(const DependentNameType *T) {
1063  VisitTypeWithKeyword(T);
1064  }
1065 
1066  void VisitDependentTemplateSpecializationType(
1070  ID.AddInteger(T->getNumArgs());
1071  for (const auto &TA : T->template_arguments()) {
1072  Hash.AddTemplateArgument(TA);
1073  }
1074  VisitTypeWithKeyword(T);
1075  }
1076 
1077  void VisitElaboratedType(const ElaboratedType *T) {
1079  AddQualType(T->getNamedType());
1080  VisitTypeWithKeyword(T);
1081  }
1082 
1083  void VisitUnaryTransformType(const UnaryTransformType *T) {
1085  AddQualType(T->getBaseType());
1086  VisitType(T);
1087  }
1088 
1089  void VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
1090  AddDecl(T->getDecl());
1091  VisitType(T);
1092  }
1093 
1094  void VisitVectorType(const VectorType *T) {
1096  ID.AddInteger(T->getNumElements());
1097  ID.AddInteger(T->getVectorKind());
1098  VisitType(T);
1099  }
1100 
1101  void VisitExtVectorType(const ExtVectorType * T) {
1102  VisitVectorType(T);
1103  }
1104 };
1105 } // namespace
1106 
1107 void ODRHash::AddType(const Type *T) {
1108  assert(T && "Expecting non-null pointer.");
1109  ODRTypeVisitor(ID, *this).Visit(T);
1110 }
1111 
1113  AddBoolean(T.isNull());
1114  if (T.isNull())
1115  return;
1116  SplitQualType split = T.split();
1117  ID.AddInteger(split.Quals.getAsOpaqueValue());
1118  AddType(split.Ty);
1119 }
1120 
1122  Bools.push_back(Value);
1123 }
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:5452
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it&#39;s either not been deduced or was deduce...
Definition: Type.h:4809
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:5205
const Type * Ty
The locally-unqualified type.
Definition: Type.h:584
Represents a function declaration or definition.
Definition: Decl.h:1784
Smart pointer class that efficiently represents Objective-C method names.
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2585
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
Definition: Type.h:5725
QualType getElementType() const
Definition: Type.h:6092
QualType getPointeeType() const
Definition: Type.h:2598
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:4160
A (possibly-)qualified type.
Definition: Type.h:643
base_class_range bases()
Definition: DeclCXX.h:589
void AddBoolean(bool value)
Definition: ODRHash.cpp:1121
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:583
void AddDeclarationName(DeclarationName Name, bool TreatAsDecl=false)
Definition: ODRHash.cpp:34
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes...
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: Type.h:3613
Expr * getUnderlyingExpr() const
Definition: Type.h:4330
Stmt - This represents one statement.
Definition: Stmt.h:66
Expr * getBitWidth() const
Definition: Decl.h:2732
void AddQualType(QualType T)
Definition: ODRHash.cpp:1112
Kind getKind() const
Definition: Type.h:2466
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3393
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2855
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:3087
Microsoft&#39;s &#39;__super&#39; specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
Definition: Type.h:5288
The template argument is an expression, and we&#39;ve not resolved it to one of the other forms yet...
Definition: TemplateBase.h:86
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:284
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5307
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
TagDecl * getDecl() const
Definition: Type.cpp:3293
ArrayRef< NamedDecl * > asArray()
Definition: DeclTemplate.h:125
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4823
The base class of the type hierarchy.
Definition: Type.h:1436
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2860
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:63
A container of type source information.
Definition: Decl.h:86
bool isEmpty() const
Evaluates true when this declaration name is empty.
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:4643
A template template parameter that has been substituted for some other template name.
Definition: TemplateName.h:219
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:2050
size_t param_size() const
Definition: Decl.h:2341
QualType getElementType() const
Definition: Type.h:2881
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
Definition: Type.h:4879
An identifier, stored as an IdentifierInfo*.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:53
Represents a variable declaration or definition.
Definition: Decl.h:827
Declaration of a redeclarable template.
Definition: DeclTemplate.h:736
ArrayRef< ObjCProtocolDecl * > getProtocols() const
Retrieve all of the protocol qualifiers.
Definition: Type.h:5533
QualType getReturnType() const
Definition: Decl.h:2365
unsigned getNumParams() const
Definition: Type.h:3927
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:56
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2028
Represents a C++17 deduced template specialization type.
Definition: Type.h:4861
A namespace, stored as a NamespaceDecl*.
bool isConst() const
Definition: Type.h:3668
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:67
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
void AddTemplateArgument(TemplateArgument TA)
Definition: ODRHash.cpp:157
bool hasDefinition() const
Definition: DeclCXX.h:542
Represents a parameter to a function.
Definition: Decl.h:1600
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4677
The collection of all-type qualifiers we support.
Definition: Type.h:137
void clear()
Definition: ODRHash.cpp:198
PipeType - OpenCL20.
Definition: Type.h:6078
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:297
QualType getOriginalType() const
Definition: Type.h:2649
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
Definition: Decl.h:3565
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:123
StringLiteral * getMessage()
Definition: DeclCXX.h:3695
Represents a class type in Objective C.
Definition: Type.h:5614
QualType getPointeeType() const
Definition: Type.h:2702
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:329
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3934
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:71
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
Definition: Decl.h:2643
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4980
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
An operation on a type.
Definition: TypeVisitor.h:64
NamedDecl * getFriendDecl() const
If this friend declaration doesn&#39;t name a type, return the inner declaration.
Definition: DeclFriend.h:138
Represents the result of substituting a set of types for a template type parameter pack...
Definition: Type.h:4733
void AddTemplateParameterList(const TemplateParameterList *TPL)
Definition: ODRHash.cpp:189
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:87
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2325
bool isUnarySelector() const
An rvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2786
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:4171
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2721
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
A qualified template name, where the qualification is kept to describe the source code as written...
Definition: TemplateName.h:211
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:2849
void AddDecl(const Decl *D)
Definition: ODRHash.cpp:625
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
Definition: ODRHash.cpp:514
An unqualified-id that has been assumed to name a function template that will be found by ADL...
Definition: TemplateName.h:207
#define CHAR_BIT
Definition: limits.h:63
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:872
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
Represents a typeof (or typeof) expression (a GCC extension).
Definition: Type.h:4250
const Type * getClass() const
Definition: Type.h:2838
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3383
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1417
#define remainder(__x, __y)
Definition: tgmath.h:1090
Expr * getSizeExpr() const
Definition: Type.h:3029
const Expr * getInitExpr() const
Definition: Decl.h:2874
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
Definition: Type.h:5849
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
Expr * getSizeExpr() const
Definition: Type.h:3086
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2740
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:877
QualType getElementType() const
Definition: Type.h:3182
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3166
void AddTemplateName(TemplateName Name)
Definition: ODRHash.cpp:138
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3688
Expr * getAddrSpaceExpr() const
Definition: Type.h:3137
NodeId Parent
Definition: ASTDiff.cpp:191
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3107
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3725
A dependent template name that has not been resolved to a template (or set of templates).
Definition: TemplateName.h:215
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
ObjCTypeParamDecl * getDecl() const
Definition: Type.h:5583
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:263
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:3064
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:406
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
Definition: DeclBase.h:1795
QualType getElementType() const
Definition: Type.h:2538
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2413
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:5375
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:644
bool isDefaulted() const
Whether this function is defaulted per C++0x.
Definition: Decl.h:2084
unsigned getAsOpaqueValue() const
Definition: Type.h:250
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3592
Declaration of a template type parameter.
unsigned getIndex() const
Definition: Type.h:4640
Internal representation of canonical, dependent decltype(expr) types.
Definition: Type.h:4348
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:67
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition: Decl.h:2033
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:558
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Definition: Decl.cpp:3594
bool isFileContext() const
Definition: DeclBase.h:1849
DeclContext * getDeclContext()
Definition: DeclBase.h:438
QualType getBaseType() const
Definition: Type.h:4389
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:5314
void ProcessODRHash(llvm::FoldingSetNodeID &ID, ODRHash &Hash) const
Calculate a unique representation for a statement that is stable across compiler invocations.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2402
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Definition: DeclTemplate.h:278
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Definition: TemplateName.h:187
Represents the type decltype(expr) (C++11).
Definition: Type.h:4320
A namespace alias, stored as a NamespaceAliasDecl*.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn&#39;t...
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:582
QualType desugar() const
Remove a single level of sugar.
Definition: Type.cpp:3223
A unary type transform, which is a type constructed from another.
Definition: Type.h:4363
Qualifiers Quals
The local qualifiers.
Definition: Type.h:587
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1779
A helper class for Type nodes having an ElaboratedTypeKeyword.
Definition: Type.h:5154
Represents a GCC generic vector type.
Definition: Type.h:3206
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2883
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2768
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
unsigned getNumArgs() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
Definition: Type.h:4783
The result type of a method or function.
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:708
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Expr * getUnderlyingExpr() const
Definition: Type.h:4259
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:6156
A template template parameter pack that has been substituted for a template template argument pack...
Definition: TemplateName.h:224
Decl::Kind getDeclKind() const
Definition: DeclBase.h:1772
Kind
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:5166
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
bool isParameterPack() const
Returns whether this is a parameter pack.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Sugar for parentheses used when specifying types.
Definition: Type.h:2555
QualType getAdjustedType() const
Definition: Type.h:2650
QualType getReturnType() const
Definition: Type.h:3651
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:2059
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4470
Represents typeof(type), a GCC extension.
Definition: Type.h:4293
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:5814
void AddType(const Type *T)
Definition: ODRHash.cpp:1107
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3400
void AddIdentifierInfo(const IdentifierInfo *II)
Definition: ODRHash.cpp:29
QualType getElementType() const
Definition: Type.h:3241
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2790
bool isRestrict() const
Definition: Type.h:3670
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1905
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isParameterPack() const
Definition: Type.h:4641
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:359
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4751
QualType getEquivalentType() const
Definition: Type.h:4525
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3589
QualType getInnerType() const
Definition: Type.h:2568
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5242
unsigned getODRHash()
Returns ODRHash of the function.
Definition: Decl.cpp:3903
AutoTypeKeyword getKeyword() const
Definition: Type.h:4838
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:2887
TypeClass getTypeClass() const
Definition: Type.h:1851
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
Definition: ODRHash.cpp:109
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:5381
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
Definition: Decl.h:2089
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3669
void AddSubDecl(const Decl *D)
Definition: ODRHash.cpp:461
void AddEnumDecl(const EnumDecl *Enum)
Definition: ODRHash.cpp:597
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2670
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:5054
QualType getPointeeType() const
Definition: Type.h:3138
Represents a pack expansion of types.
Definition: Type.h:5431
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:353
StringRef getName() const
Return the actual identifier string.
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2985
Represents a template argument.
Definition: TemplateBase.h:50
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
Definition: Type.h:2633
Dataflow Directional Tag Classes.
ExtInfo getExtInfo() const
Definition: Type.h:3662
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:498
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
Definition: Decl.h:2063
NestedNameSpecifier * getQualifier() const
Definition: Type.h:5366
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1271
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:387
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:79
QualType getUnderlyingType() const
Definition: Decl.h:3040
AccessSpecifier getAccess() const
Definition: DeclBase.h:473
const Expr * getInit() const
Definition: Decl.h:1234
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:745
QualType getUnderlyingType() const
Definition: Type.h:4331
void AddCXXRecordDecl(const CXXRecordDecl *Record)
Definition: ODRHash.cpp:467
The name of a declaration.
VectorKind getVectorKind() const
Definition: Type.h:3251
Kind getKind() const
Definition: DeclBase.h:432
bool isKeywordSelector() const
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
Definition: Type.cpp:738
Represents an enum.
Definition: Decl.h:3395
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2804
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
A type that was preceded by the &#39;template&#39; keyword, stored as a Type*.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4692
QualType getUnderlyingType() const
Definition: Type.h:4388
QualType getModifiedType() const
Definition: Type.h:4524
Represents a pointer to an Objective C object.
Definition: Type.h:5870
Pointer to a block type.
Definition: Type.h:2687
bool isSugared() const
Returns whether this type directly provides sugar.
Definition: Type.cpp:3219
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4444
Complex values, per C99 6.2.5p11.
Definition: Type.h:2525
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4988
const llvm::APInt & getSize() const
Definition: Type.h:2929
Kind getAttrKind() const
Definition: Type.h:4520
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
Definition: Decl.h:1074
ExtVectorType - Extended vector type.
Definition: Type.h:3325
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2721
bool isVolatile() const
Definition: Type.h:3669
unsigned CalculateHash()
Definition: ODRHash.cpp:204
The template argument is a type.
Definition: TemplateBase.h:59
QualType getUnderlyingType() const
Definition: Type.h:4308
The template argument is actually a parameter pack.
Definition: TemplateBase.h:90
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
A template argument list.
Definition: DeclTemplate.h:224
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1687
TypedefNameDecl * getDecl() const
Definition: Type.h:4206
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:234
unsigned getDepth() const
Definition: Type.h:4639
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4499
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
Represents a type parameter type in Objective C.
Definition: Type.h:5540
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:2718
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:5340
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:4996
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:75
Represents a C array with an unspecified size.
Definition: Type.h:2966
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:5245
bool isNull() const
Determine whether this is the empty selector.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Definition: Type.h:4698
Declaration of a class template.
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2436
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3549
void AddStmt(const Stmt *S)
Definition: ODRHash.cpp:24
NameKind getKind() const
unsigned getNumElements() const
Definition: Type.h:3242
bool isReadOnly() const
Definition: Type.h:6111
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:256
Represents an extended address space qualifier where the input address space value is dependent...
Definition: Type.h:3124
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4917
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:2199
static bool isWhitelistedDecl(const Decl *D, const DeclContext *Parent)
Definition: ODRHash.cpp:438
QualType getDefaultArgument() const
Retrieve the default argument, if any.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
QualType getType() const
Definition: Decl.h:655
A set of overloaded template declarations.
Definition: TemplateName.h:203
This represents a decl that may have a name.
Definition: Decl.h:248
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:3010
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:73
The global specifier &#39;::&#39;. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
Definition: TemplateBase.h:287
bool hasInit() const
Definition: Decl.cpp:2211
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2906
Declaration of a template function.
Definition: DeclTemplate.h:961
bool isDeletedAsWritten() const
Definition: Decl.h:2203
QualType getPointeeType() const
Definition: Type.h:2824
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:97
A single template declaration.
Definition: TemplateName.h:200
const IdentifierInfo * getIdentifier() const
Definition: Type.h:5367
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:5886