clang  9.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  for (unsigned i = 0; i < NumArgs; ++i) {
76  }
77  break;
78  }
82  break;
84  ID.AddInteger(Name.getCXXOverloadedOperator());
85  break;
88  break;
91  break;
93  break;
95  auto *Template = Name.getCXXDeductionGuideTemplate();
96  AddBoolean(Template);
97  if (Template) {
98  AddDecl(Template);
99  }
100  }
101  }
102 }
103 
105  assert(NNS && "Expecting non-null pointer.");
106  const auto *Prefix = NNS->getPrefix();
107  AddBoolean(Prefix);
108  if (Prefix) {
109  AddNestedNameSpecifier(Prefix);
110  }
111  auto Kind = NNS->getKind();
112  ID.AddInteger(Kind);
113  switch (Kind) {
116  break;
118  AddDecl(NNS->getAsNamespace());
119  break;
122  break;
125  AddType(NNS->getAsType());
126  break;
129  break;
130  }
131 }
132 
134  auto Kind = Name.getKind();
135  ID.AddInteger(Kind);
136 
137  switch (Kind) {
139  AddDecl(Name.getAsTemplateDecl());
140  break;
141  // TODO: Support these cases.
147  break;
148  }
149 }
150 
152  const auto Kind = TA.getKind();
153  ID.AddInteger(Kind);
154 
155  switch (Kind) {
157  llvm_unreachable("Expected valid TemplateArgument");
159  AddQualType(TA.getAsType());
160  break;
162  AddDecl(TA.getAsDecl());
163  break;
166  break;
170  break;
172  AddStmt(TA.getAsExpr());
173  break;
175  ID.AddInteger(TA.pack_size());
176  for (auto SubTA : TA.pack_elements()) {
177  AddTemplateArgument(SubTA);
178  }
179  break;
180  }
181 }
182 
184  assert(TPL && "Expecting non-null pointer.");
185 
186  ID.AddInteger(TPL->size());
187  for (auto *ND : TPL->asArray()) {
188  AddSubDecl(ND);
189  }
190 }
191 
193  DeclNameMap.clear();
194  Bools.clear();
195  ID.clear();
196 }
197 
199  // Append the bools to the end of the data segment backwards. This allows
200  // for the bools data to be compressed 32 times smaller compared to using
201  // ID.AddBoolean
202  const unsigned unsigned_bits = sizeof(unsigned) * CHAR_BIT;
203  const unsigned size = Bools.size();
204  const unsigned remainder = size % unsigned_bits;
205  const unsigned loops = size / unsigned_bits;
206  auto I = Bools.rbegin();
207  unsigned value = 0;
208  for (unsigned i = 0; i < remainder; ++i) {
209  value <<= 1;
210  value |= *I;
211  ++I;
212  }
213  ID.AddInteger(value);
214 
215  for (unsigned i = 0; i < loops; ++i) {
216  value = 0;
217  for (unsigned j = 0; j < unsigned_bits; ++j) {
218  value <<= 1;
219  value |= *I;
220  ++I;
221  }
222  ID.AddInteger(value);
223  }
224 
225  assert(I == Bools.rend());
226  Bools.clear();
227  return ID.ComputeHash();
228 }
229 
230 namespace {
231 // Process a Decl pointer. Add* methods call back into ODRHash while Visit*
232 // methods process the relevant parts of the Decl.
233 class ODRDeclVisitor : public ConstDeclVisitor<ODRDeclVisitor> {
234  typedef ConstDeclVisitor<ODRDeclVisitor> Inherited;
235  llvm::FoldingSetNodeID &ID;
236  ODRHash &Hash;
237 
238 public:
239  ODRDeclVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
240  : ID(ID), Hash(Hash) {}
241 
242  void AddStmt(const Stmt *S) {
243  Hash.AddBoolean(S);
244  if (S) {
245  Hash.AddStmt(S);
246  }
247  }
248 
249  void AddIdentifierInfo(const IdentifierInfo *II) {
250  Hash.AddBoolean(II);
251  if (II) {
252  Hash.AddIdentifierInfo(II);
253  }
254  }
255 
256  void AddQualType(QualType T) {
257  Hash.AddQualType(T);
258  }
259 
260  void AddDecl(const Decl *D) {
261  Hash.AddBoolean(D);
262  if (D) {
263  Hash.AddDecl(D);
264  }
265  }
266 
268  Hash.AddTemplateArgument(TA);
269  }
270 
271  void Visit(const Decl *D) {
272  ID.AddInteger(D->getKind());
273  Inherited::Visit(D);
274  }
275 
276  void VisitNamedDecl(const NamedDecl *D) {
277  Hash.AddDeclarationName(D->getDeclName());
278  Inherited::VisitNamedDecl(D);
279  }
280 
281  void VisitValueDecl(const ValueDecl *D) {
282  if (!isa<FunctionDecl>(D)) {
283  AddQualType(D->getType());
284  }
285  Inherited::VisitValueDecl(D);
286  }
287 
288  void VisitVarDecl(const VarDecl *D) {
289  Hash.AddBoolean(D->isStaticLocal());
290  Hash.AddBoolean(D->isConstexpr());
291  const bool HasInit = D->hasInit();
292  Hash.AddBoolean(HasInit);
293  if (HasInit) {
294  AddStmt(D->getInit());
295  }
296  Inherited::VisitVarDecl(D);
297  }
298 
299  void VisitParmVarDecl(const ParmVarDecl *D) {
300  // TODO: Handle default arguments.
301  Inherited::VisitParmVarDecl(D);
302  }
303 
304  void VisitAccessSpecDecl(const AccessSpecDecl *D) {
305  ID.AddInteger(D->getAccess());
306  Inherited::VisitAccessSpecDecl(D);
307  }
308 
309  void VisitStaticAssertDecl(const StaticAssertDecl *D) {
310  AddStmt(D->getAssertExpr());
311  AddStmt(D->getMessage());
312 
313  Inherited::VisitStaticAssertDecl(D);
314  }
315 
316  void VisitFieldDecl(const FieldDecl *D) {
317  const bool IsBitfield = D->isBitField();
318  Hash.AddBoolean(IsBitfield);
319 
320  if (IsBitfield) {
321  AddStmt(D->getBitWidth());
322  }
323 
324  Hash.AddBoolean(D->isMutable());
326 
327  Inherited::VisitFieldDecl(D);
328  }
329 
330  void VisitFunctionDecl(const FunctionDecl *D) {
331  // Handled by the ODRHash for FunctionDecl
332  ID.AddInteger(D->getODRHash());
333 
334  Inherited::VisitFunctionDecl(D);
335  }
336 
337  void VisitCXXMethodDecl(const CXXMethodDecl *D) {
338  // Handled by the ODRHash for FunctionDecl
339 
340  Inherited::VisitCXXMethodDecl(D);
341  }
342 
343  void VisitTypedefNameDecl(const TypedefNameDecl *D) {
345 
346  Inherited::VisitTypedefNameDecl(D);
347  }
348 
349  void VisitTypedefDecl(const TypedefDecl *D) {
350  Inherited::VisitTypedefDecl(D);
351  }
352 
353  void VisitTypeAliasDecl(const TypeAliasDecl *D) {
354  Inherited::VisitTypeAliasDecl(D);
355  }
356 
357  void VisitFriendDecl(const FriendDecl *D) {
358  TypeSourceInfo *TSI = D->getFriendType();
359  Hash.AddBoolean(TSI);
360  if (TSI) {
361  AddQualType(TSI->getType());
362  } else {
363  AddDecl(D->getFriendDecl());
364  }
365  }
366 
367  void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
368  // Only care about default arguments as part of the definition.
369  const bool hasDefaultArgument =
371  Hash.AddBoolean(hasDefaultArgument);
372  if (hasDefaultArgument) {
374  }
375  Hash.AddBoolean(D->isParameterPack());
376 
377  Inherited::VisitTemplateTypeParmDecl(D);
378  }
379 
380  void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) {
381  // Only care about default arguments as part of the definition.
382  const bool hasDefaultArgument =
384  Hash.AddBoolean(hasDefaultArgument);
385  if (hasDefaultArgument) {
387  }
388  Hash.AddBoolean(D->isParameterPack());
389 
390  Inherited::VisitNonTypeTemplateParmDecl(D);
391  }
392 
393  void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) {
394  // Only care about default arguments as part of the definition.
395  const bool hasDefaultArgument =
397  Hash.AddBoolean(hasDefaultArgument);
398  if (hasDefaultArgument) {
400  }
401  Hash.AddBoolean(D->isParameterPack());
402 
403  Inherited::VisitTemplateTemplateParmDecl(D);
404  }
405 
406  void VisitTemplateDecl(const TemplateDecl *D) {
408 
409  Inherited::VisitTemplateDecl(D);
410  }
411 
412  void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *D) {
414  Inherited::VisitRedeclarableTemplateDecl(D);
415  }
416 
417  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
419  ID.AddInteger(D->getTemplatedDecl()->getODRHash());
420  Inherited::VisitFunctionTemplateDecl(D);
421  }
422 
423  void VisitEnumConstantDecl(const EnumConstantDecl *D) {
424  AddStmt(D->getInitExpr());
425  Inherited::VisitEnumConstantDecl(D);
426  }
427 };
428 } // namespace
429 
430 // Only allow a small portion of Decl's to be processed. Remove this once
431 // all Decl's can be handled.
433  if (D->isImplicit()) return false;
434  if (D->getDeclContext() != Parent) return false;
435 
436  switch (D->getKind()) {
437  default:
438  return false;
439  case Decl::AccessSpec:
440  case Decl::CXXConstructor:
441  case Decl::CXXDestructor:
442  case Decl::CXXMethod:
443  case Decl::EnumConstant: // Only found in EnumDecl's.
444  case Decl::Field:
445  case Decl::Friend:
446  case Decl::FunctionTemplate:
447  case Decl::StaticAssert:
448  case Decl::TypeAlias:
449  case Decl::Typedef:
450  case Decl::Var:
451  return true;
452  }
453 }
454 
455 void ODRHash::AddSubDecl(const Decl *D) {
456  assert(D && "Expecting non-null pointer.");
457 
458  ODRDeclVisitor(ID, *this).Visit(D);
459 }
460 
462  assert(Record && Record->hasDefinition() &&
463  "Expected non-null record to be a definition.");
464 
465  const DeclContext *DC = Record;
466  while (DC) {
467  if (isa<ClassTemplateSpecializationDecl>(DC)) {
468  return;
469  }
470  DC = DC->getParent();
471  }
472 
473  AddDecl(Record);
474 
475  // Filter out sub-Decls which will not be processed in order to get an
476  // accurate count of Decl's.
478  for (Decl *SubDecl : Record->decls()) {
479  if (isWhitelistedDecl(SubDecl, Record)) {
480  Decls.push_back(SubDecl);
481  if (auto *Function = dyn_cast<FunctionDecl>(SubDecl)) {
482  // Compute/Preload ODRHash into FunctionDecl.
483  Function->getODRHash();
484  }
485  }
486  }
487 
488  ID.AddInteger(Decls.size());
489  for (auto SubDecl : Decls) {
490  AddSubDecl(SubDecl);
491  }
492 
493  const ClassTemplateDecl *TD = Record->getDescribedClassTemplate();
494  AddBoolean(TD);
495  if (TD) {
497  }
498 
499  ID.AddInteger(Record->getNumBases());
500  auto Bases = Record->bases();
501  for (auto Base : Bases) {
502  AddQualType(Base.getType());
503  ID.AddInteger(Base.isVirtual());
504  ID.AddInteger(Base.getAccessSpecifierAsWritten());
505  }
506 }
507 
509  bool SkipBody) {
510  assert(Function && "Expecting non-null pointer.");
511 
512  // Skip functions that are specializations or in specialization context.
513  const DeclContext *DC = Function;
514  while (DC) {
515  if (isa<ClassTemplateSpecializationDecl>(DC)) return;
516  if (auto *F = dyn_cast<FunctionDecl>(DC)) {
517  if (F->isFunctionTemplateSpecialization()) {
518  if (!isa<CXXMethodDecl>(DC)) return;
519  if (DC->getLexicalParent()->isFileContext()) return;
520  // Inline method specializations are the only supported
521  // specialization for now.
522  }
523  }
524  DC = DC->getParent();
525  }
526 
527  ID.AddInteger(Function->getDeclKind());
528 
529  const auto *SpecializationArgs = Function->getTemplateSpecializationArgs();
530  AddBoolean(SpecializationArgs);
531  if (SpecializationArgs) {
532  ID.AddInteger(SpecializationArgs->size());
533  for (const TemplateArgument &TA : SpecializationArgs->asArray()) {
535  }
536  }
537 
538  if (const auto *Method = dyn_cast<CXXMethodDecl>(Function)) {
539  AddBoolean(Method->isConst());
540  AddBoolean(Method->isVolatile());
541  }
542 
543  ID.AddInteger(Function->getStorageClass());
544  AddBoolean(Function->isInlineSpecified());
545  AddBoolean(Function->isVirtualAsWritten());
546  AddBoolean(Function->isPure());
547  AddBoolean(Function->isDeletedAsWritten());
548  AddBoolean(Function->isExplicitlyDefaulted());
549 
550  AddDecl(Function);
551 
552  AddQualType(Function->getReturnType());
553 
554  ID.AddInteger(Function->param_size());
555  for (auto Param : Function->parameters())
556  AddSubDecl(Param);
557 
558  if (SkipBody) {
559  AddBoolean(false);
560  return;
561  }
562 
563  const bool HasBody = Function->isThisDeclarationADefinition() &&
564  !Function->isDefaulted() && !Function->isDeleted() &&
565  !Function->isLateTemplateParsed();
566  AddBoolean(HasBody);
567  if (!HasBody) {
568  return;
569  }
570 
571  auto *Body = Function->getBody();
572  AddBoolean(Body);
573  if (Body)
574  AddStmt(Body);
575 
576  // Filter out sub-Decls which will not be processed in order to get an
577  // accurate count of Decl's.
579  for (Decl *SubDecl : Function->decls()) {
580  if (isWhitelistedDecl(SubDecl, Function)) {
581  Decls.push_back(SubDecl);
582  }
583  }
584 
585  ID.AddInteger(Decls.size());
586  for (auto SubDecl : Decls) {
587  AddSubDecl(SubDecl);
588  }
589 }
590 
591 void ODRHash::AddEnumDecl(const EnumDecl *Enum) {
592  assert(Enum);
594 
595  AddBoolean(Enum->isScoped());
596  if (Enum->isScoped())
598 
599  if (Enum->getIntegerTypeSourceInfo())
600  AddQualType(Enum->getIntegerType());
601 
602  // Filter out sub-Decls which will not be processed in order to get an
603  // accurate count of Decl's.
605  for (Decl *SubDecl : Enum->decls()) {
606  if (isWhitelistedDecl(SubDecl, Enum)) {
607  assert(isa<EnumConstantDecl>(SubDecl) && "Unexpected Decl");
608  Decls.push_back(SubDecl);
609  }
610  }
611 
612  ID.AddInteger(Decls.size());
613  for (auto SubDecl : Decls) {
614  AddSubDecl(SubDecl);
615  }
616 
617 }
618 
619 void ODRHash::AddDecl(const Decl *D) {
620  assert(D && "Expecting non-null pointer.");
621  D = D->getCanonicalDecl();
622 
623  const NamedDecl *ND = dyn_cast<NamedDecl>(D);
624  AddBoolean(ND);
625  if (!ND) {
626  ID.AddInteger(D->getKind());
627  return;
628  }
629 
631 
632  const auto *Specialization =
633  dyn_cast<ClassTemplateSpecializationDecl>(D);
634  AddBoolean(Specialization);
635  if (Specialization) {
636  const TemplateArgumentList &List = Specialization->getTemplateArgs();
637  ID.AddInteger(List.size());
638  for (const TemplateArgument &TA : List.asArray())
640  }
641 }
642 
643 namespace {
644 // Process a Type pointer. Add* methods call back into ODRHash while Visit*
645 // methods process the relevant parts of the Type.
646 class ODRTypeVisitor : public TypeVisitor<ODRTypeVisitor> {
647  typedef TypeVisitor<ODRTypeVisitor> Inherited;
648  llvm::FoldingSetNodeID &ID;
649  ODRHash &Hash;
650 
651 public:
652  ODRTypeVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
653  : ID(ID), Hash(Hash) {}
654 
655  void AddStmt(Stmt *S) {
656  Hash.AddBoolean(S);
657  if (S) {
658  Hash.AddStmt(S);
659  }
660  }
661 
662  void AddDecl(Decl *D) {
663  Hash.AddBoolean(D);
664  if (D) {
665  Hash.AddDecl(D);
666  }
667  }
668 
669  void AddQualType(QualType T) {
670  Hash.AddQualType(T);
671  }
672 
673  void AddType(const Type *T) {
674  Hash.AddBoolean(T);
675  if (T) {
676  Hash.AddType(T);
677  }
678  }
679 
681  Hash.AddBoolean(NNS);
682  if (NNS) {
683  Hash.AddNestedNameSpecifier(NNS);
684  }
685  }
686 
687  void AddIdentifierInfo(const IdentifierInfo *II) {
688  Hash.AddBoolean(II);
689  if (II) {
690  Hash.AddIdentifierInfo(II);
691  }
692  }
693 
694  void VisitQualifiers(Qualifiers Quals) {
695  ID.AddInteger(Quals.getAsOpaqueValue());
696  }
697 
698  void Visit(const Type *T) {
699  ID.AddInteger(T->getTypeClass());
700  Inherited::Visit(T);
701  }
702 
703  void VisitType(const Type *T) {}
704 
705  void VisitAdjustedType(const AdjustedType *T) {
708  VisitType(T);
709  }
710 
711  void VisitDecayedType(const DecayedType *T) {
714  VisitAdjustedType(T);
715  }
716 
717  void VisitArrayType(const ArrayType *T) {
719  ID.AddInteger(T->getSizeModifier());
720  VisitQualifiers(T->getIndexTypeQualifiers());
721  VisitType(T);
722  }
723  void VisitConstantArrayType(const ConstantArrayType *T) {
724  T->getSize().Profile(ID);
725  VisitArrayType(T);
726  }
727 
728  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
729  AddStmt(T->getSizeExpr());
730  VisitArrayType(T);
731  }
732 
733  void VisitIncompleteArrayType(const IncompleteArrayType *T) {
734  VisitArrayType(T);
735  }
736 
737  void VisitVariableArrayType(const VariableArrayType *T) {
738  AddStmt(T->getSizeExpr());
739  VisitArrayType(T);
740  }
741 
742  void VisitAttributedType(const AttributedType *T) {
743  ID.AddInteger(T->getAttrKind());
746 
747  VisitType(T);
748  }
749 
750  void VisitBlockPointerType(const BlockPointerType *T) {
752  VisitType(T);
753  }
754 
755  void VisitBuiltinType(const BuiltinType *T) {
756  ID.AddInteger(T->getKind());
757  VisitType(T);
758  }
759 
760  void VisitComplexType(const ComplexType *T) {
762  VisitType(T);
763  }
764 
765  void VisitDecltypeType(const DecltypeType *T) {
768  VisitType(T);
769  }
770 
771  void VisitDependentDecltypeType(const DependentDecltypeType *T) {
772  VisitDecltypeType(T);
773  }
774 
775  void VisitDeducedType(const DeducedType *T) {
777  VisitType(T);
778  }
779 
780  void VisitAutoType(const AutoType *T) {
781  ID.AddInteger((unsigned)T->getKeyword());
782  VisitDeducedType(T);
783  }
784 
785  void VisitDeducedTemplateSpecializationType(
787  Hash.AddTemplateName(T->getTemplateName());
788  VisitDeducedType(T);
789  }
790 
791  void VisitDependentAddressSpaceType(const DependentAddressSpaceType *T) {
794  VisitType(T);
795  }
796 
797  void VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T) {
799  AddStmt(T->getSizeExpr());
800  VisitType(T);
801  }
802 
803  void VisitFunctionType(const FunctionType *T) {
805  T->getExtInfo().Profile(ID);
806  Hash.AddBoolean(T->isConst());
807  Hash.AddBoolean(T->isVolatile());
808  Hash.AddBoolean(T->isRestrict());
809  VisitType(T);
810  }
811 
812  void VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
813  VisitFunctionType(T);
814  }
815 
816  void VisitFunctionProtoType(const FunctionProtoType *T) {
817  ID.AddInteger(T->getNumParams());
818  for (auto ParamType : T->getParamTypes())
819  AddQualType(ParamType);
820 
821  VisitFunctionType(T);
822  }
823 
824  void VisitInjectedClassNameType(const InjectedClassNameType *T) {
825  AddDecl(T->getDecl());
826  VisitType(T);
827  }
828 
829  void VisitMemberPointerType(const MemberPointerType *T) {
831  AddType(T->getClass());
832  VisitType(T);
833  }
834 
835  void VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
837  VisitType(T);
838  }
839 
840  void VisitObjCObjectType(const ObjCObjectType *T) {
841  AddDecl(T->getInterface());
842 
843  auto TypeArgs = T->getTypeArgsAsWritten();
844  ID.AddInteger(TypeArgs.size());
845  for (auto Arg : TypeArgs) {
846  AddQualType(Arg);
847  }
848 
849  auto Protocols = T->getProtocols();
850  ID.AddInteger(Protocols.size());
851  for (auto Protocol : Protocols) {
852  AddDecl(Protocol);
853  }
854 
855  Hash.AddBoolean(T->isKindOfType());
856 
857  VisitType(T);
858  }
859 
860  void VisitObjCInterfaceType(const ObjCInterfaceType *T) {
861  // This type is handled by the parent type ObjCObjectType.
862  VisitObjCObjectType(T);
863  }
864 
865  void VisitObjCTypeParamType(const ObjCTypeParamType *T) {
866  AddDecl(T->getDecl());
867  auto Protocols = T->getProtocols();
868  ID.AddInteger(Protocols.size());
869  for (auto Protocol : Protocols) {
870  AddDecl(Protocol);
871  }
872 
873  VisitType(T);
874  }
875 
876  void VisitPackExpansionType(const PackExpansionType *T) {
877  AddQualType(T->getPattern());
878  VisitType(T);
879  }
880 
881  void VisitParenType(const ParenType *T) {
883  VisitType(T);
884  }
885 
886  void VisitPipeType(const PipeType *T) {
888  Hash.AddBoolean(T->isReadOnly());
889  VisitType(T);
890  }
891 
892  void VisitPointerType(const PointerType *T) {
894  VisitType(T);
895  }
896 
897  void VisitReferenceType(const ReferenceType *T) {
899  VisitType(T);
900  }
901 
902  void VisitLValueReferenceType(const LValueReferenceType *T) {
903  VisitReferenceType(T);
904  }
905 
906  void VisitRValueReferenceType(const RValueReferenceType *T) {
907  VisitReferenceType(T);
908  }
909 
910  void
911  VisitSubstTemplateTypeParmPackType(const SubstTemplateTypeParmPackType *T) {
914  VisitType(T);
915  }
916 
917  void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
920  VisitType(T);
921  }
922 
923  void VisitTagType(const TagType *T) {
924  AddDecl(T->getDecl());
925  VisitType(T);
926  }
927 
928  void VisitRecordType(const RecordType *T) { VisitTagType(T); }
929  void VisitEnumType(const EnumType *T) { VisitTagType(T); }
930 
931  void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
932  ID.AddInteger(T->getNumArgs());
933  for (const auto &TA : T->template_arguments()) {
934  Hash.AddTemplateArgument(TA);
935  }
936  Hash.AddTemplateName(T->getTemplateName());
937  VisitType(T);
938  }
939 
940  void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
941  ID.AddInteger(T->getDepth());
942  ID.AddInteger(T->getIndex());
943  Hash.AddBoolean(T->isParameterPack());
944  AddDecl(T->getDecl());
945  }
946 
947  void VisitTypedefType(const TypedefType *T) {
948  AddDecl(T->getDecl());
949  QualType UnderlyingType = T->getDecl()->getUnderlyingType();
950  VisitQualifiers(UnderlyingType.getQualifiers());
951  while (true) {
952  if (const TypedefType *Underlying =
953  dyn_cast<TypedefType>(UnderlyingType.getTypePtr())) {
954  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
955  continue;
956  }
957  if (const ElaboratedType *Underlying =
958  dyn_cast<ElaboratedType>(UnderlyingType.getTypePtr())) {
959  UnderlyingType = Underlying->getNamedType();
960  continue;
961  }
962 
963  break;
964  }
965  AddType(UnderlyingType.getTypePtr());
966  VisitType(T);
967  }
968 
969  void VisitTypeOfExprType(const TypeOfExprType *T) {
971  Hash.AddBoolean(T->isSugared());
972  if (T->isSugared())
973  AddQualType(T->desugar());
974 
975  VisitType(T);
976  }
977  void VisitTypeOfType(const TypeOfType *T) {
979  VisitType(T);
980  }
981 
982  void VisitTypeWithKeyword(const TypeWithKeyword *T) {
983  ID.AddInteger(T->getKeyword());
984  VisitType(T);
985  };
986 
987  void VisitDependentNameType(const DependentNameType *T) {
990  VisitTypeWithKeyword(T);
991  }
992 
993  void VisitDependentTemplateSpecializationType(
997  ID.AddInteger(T->getNumArgs());
998  for (const auto &TA : T->template_arguments()) {
999  Hash.AddTemplateArgument(TA);
1000  }
1001  VisitTypeWithKeyword(T);
1002  }
1003 
1004  void VisitElaboratedType(const ElaboratedType *T) {
1006  AddQualType(T->getNamedType());
1007  VisitTypeWithKeyword(T);
1008  }
1009 
1010  void VisitUnaryTransformType(const UnaryTransformType *T) {
1012  AddQualType(T->getBaseType());
1013  VisitType(T);
1014  }
1015 
1016  void VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
1017  AddDecl(T->getDecl());
1018  VisitType(T);
1019  }
1020 
1021  void VisitVectorType(const VectorType *T) {
1023  ID.AddInteger(T->getNumElements());
1024  ID.AddInteger(T->getVectorKind());
1025  VisitType(T);
1026  }
1027 
1028  void VisitExtVectorType(const ExtVectorType * T) {
1029  VisitVectorType(T);
1030  }
1031 };
1032 } // namespace
1033 
1034 void ODRHash::AddType(const Type *T) {
1035  assert(T && "Expecting non-null pointer.");
1036  ODRTypeVisitor(ID, *this).Visit(T);
1037 }
1038 
1040  AddBoolean(T.isNull());
1041  if (T.isNull())
1042  return;
1043  SplitQualType split = T.split();
1044  ID.AddInteger(split.Quals.getAsOpaqueValue());
1045  AddType(split.Ty);
1046 }
1047 
1049  Bools.push_back(Value);
1050 }
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:5386
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:4745
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:5139
const Type * Ty
The locally-unqualified type.
Definition: Type.h:580
Represents a function declaration or definition.
Definition: Decl.h:1737
Smart pointer class that efficiently represents Objective-C method names.
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2547
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
Definition: Type.h:5659
QualType getElementType() const
Definition: Type.h:6026
QualType getPointeeType() const
Definition: Type.h:2560
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:4131
A (possibly-)qualified type.
Definition: Type.h:639
base_class_range bases()
Definition: DeclCXX.h:822
void AddBoolean(bool value)
Definition: ODRHash.cpp:1048
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:816
void AddDeclarationName(DeclarationName Name, bool TreatAsDecl=false)
Definition: ODRHash.cpp:34
QualType getDecayedType() const
Definition: Type.h:2639
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:3585
Expr * getUnderlyingExpr() const
Definition: Type.h:4266
Stmt - This represents one statement.
Definition: Stmt.h:65
Expr * getBitWidth() const
Definition: Decl.h:2667
void AddQualType(QualType T)
Definition: ODRHash.cpp:1039
Kind getKind() const
Definition: Type.h:2428
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3365
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2785
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:3017
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:5222
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:269
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5241
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
TagDecl * getDecl() const
Definition: Type.cpp:3244
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:4759
The base class of the type hierarchy.
Definition: Type.h:1414
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2822
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:4579
A template template parameter that has been substituted for some other template name.
Definition: TemplateName.h:206
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:1999
size_t param_size() const
Definition: Decl.h:2277
QualType getElementType() const
Definition: Type.h:2857
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:4813
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:812
Declaration of a redeclarable template.
Definition: DeclTemplate.h:736
ArrayRef< ObjCProtocolDecl * > getProtocols() const
Retrieve all of the protocol qualifiers.
Definition: Type.h:5467
QualType getReturnType() const
Definition: Decl.h:2301
unsigned getNumParams() const
Definition: Type.h:3898
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:2005
Represents a C++17 deduced template specialization type.
Definition: Type.h:4795
A namespace, stored as a NamespaceDecl*.
bool isConst() const
Definition: Type.h:3640
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:151
bool hasDefinition() const
Definition: DeclCXX.h:775
Represents a parameter to a function.
Definition: Decl.h:1549
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4613
The collection of all-type qualifiers we support.
Definition: Type.h:137
void clear()
Definition: ODRHash.cpp:192
PipeType - OpenCL20.
Definition: Type.h:6012
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:2611
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
Definition: Decl.h:3495
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:3779
Represents a class type in Objective C.
Definition: Type.h:5548
QualType getPointeeType() const
Definition: Type.h:2664
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:329
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3905
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:2578
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4914
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:4669
void AddTemplateParameterList(const TemplateParameterList *TPL)
Definition: ODRHash.cpp:183
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:131
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2261
bool isUnarySelector() const
An rvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2748
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:4142
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2656
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:198
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:2730
void AddDecl(const Decl *D)
Definition: ODRHash.cpp:619
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
Definition: ODRHash.cpp:508
#define CHAR_BIT
Definition: limits.h:79
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:879
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:4186
const Type * getClass() const
Definition: Type.h:2800
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3334
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1381
#define remainder(__x, __y)
Definition: tgmath.h:1106
QualType getPointeeType() const
Definition: Type.h:6854
Expr * getSizeExpr() const
Definition: Type.h:3001
const Expr * getInitExpr() const
Definition: Decl.h:2804
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:5783
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
Expr * getSizeExpr() const
Definition: Type.h:3058
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2702
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:872
QualType getElementType() const
Definition: Type.h:3154
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3138
void AddTemplateName(TemplateName Name)
Definition: ODRHash.cpp:133
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3660
Expr * getAddrSpaceExpr() const
Definition: Type.h:3109
NodeId Parent
Definition: ASTDiff.cpp:191
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3037
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3697
A dependent template name that has not been resolved to a template (or set of templates).
Definition: TemplateName.h:202
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
ObjCTypeParamDecl * getDecl() const
Definition: Type.h:5517
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:3036
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:431
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
Definition: DeclBase.h:1776
QualType getElementType() const
Definition: Type.h:2500
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2341
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:5309
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:636
bool isDefaulted() const
Whether this function is defaulted per C++0x.
Definition: Decl.h:2033
unsigned getAsOpaqueValue() const
Definition: Type.h:250
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3522
Declaration of a template type parameter.
unsigned getIndex() const
Definition: Type.h:4576
Internal representation of canonical, dependent decltype(expr) types.
Definition: Type.h:4284
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:1982
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:549
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Definition: Decl.cpp:3478
bool isFileContext() const
Definition: DeclBase.h:1826
DeclContext * getDeclContext()
Definition: DeclBase.h:429
QualType getBaseType() const
Definition: Type.h:4325
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:5248
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:2330
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Definition: DeclTemplate.h:263
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Represents the type decltype(expr) (C++11).
Definition: Type.h:4256
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:578
QualType desugar() const
Remove a single level of sugar.
Definition: Type.cpp:3174
A unary type transform, which is a type constructed from another.
Definition: Type.h:4299
Qualifiers Quals
The local qualifiers.
Definition: Type.h:583
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1760
A helper class for Type nodes having an ElaboratedTypeKeyword.
Definition: Type.h:5088
Represents a GCC generic vector type.
Definition: Type.h:3178
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2859
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2730
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:4719
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:704
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Expr * getUnderlyingExpr() const
Definition: Type.h:4195
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:6090
A template template parameter pack that has been substituted for a template template argument pack...
Definition: TemplateName.h:211
Decl::Kind getDeclKind() const
Definition: DeclBase.h:1753
Kind
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:5100
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:2517
QualType getAdjustedType() const
Definition: Type.h:2612
QualType getReturnType() const
Definition: Type.h:3623
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:2008
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4406
Represents typeof(type), a GCC extension.
Definition: Type.h:4229
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:5748
void AddType(const Type *T)
Definition: ODRHash.cpp:1034
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3351
void AddIdentifierInfo(const IdentifierInfo *II)
Definition: ODRHash.cpp:29
QualType getElementType() const
Definition: Type.h:3213
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2720
bool isRestrict() const
Definition: Type.h:3642
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2048
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isParameterPack() const
Definition: Type.h:4577
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:4687
QualType getEquivalentType() const
Definition: Type.h:4461
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3519
QualType getInnerType() const
Definition: Type.h:2530
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5176
unsigned getODRHash()
Returns ODRHash of the function.
Definition: Decl.cpp:3750
AutoTypeKeyword getKeyword() const
Definition: Type.h:4774
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:2863
TypeClass getTypeClass() const
Definition: Type.h:1818
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
Definition: ODRHash.cpp:104
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:5315
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
Definition: Decl.h:2038
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3753
void AddSubDecl(const Decl *D)
Definition: ODRHash.cpp:455
void AddEnumDecl(const EnumDecl *Enum)
Definition: ODRHash.cpp:591
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2632
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:4988
QualType getPointeeType() const
Definition: Type.h:3110
Represents a pack expansion of types.
Definition: Type.h:5365
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:2915
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:2595
Dataflow Directional Tag Classes.
ExtInfo getExtInfo() const
Definition: Type.h:3634
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:498
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
Definition: Decl.h:2012
NestedNameSpecifier * getQualifier() const
Definition: Type.h:5300
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1265
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:398
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:2970
AccessSpecifier getAccess() const
Definition: DeclBase.h:464
const Expr * getInit() const
Definition: Decl.h:1219
QualType getUnderlyingType() const
Definition: Type.h:4267
void AddCXXRecordDecl(const CXXRecordDecl *Record)
Definition: ODRHash.cpp:461
The name of a declaration.
VectorKind getVectorKind() const
Definition: Type.h:3223
Kind getKind() const
Definition: DeclBase.h:423
bool isKeywordSelector() const
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
Definition: Type.cpp:682
Represents an enum.
Definition: Decl.h:3325
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2766
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:4628
QualType getUnderlyingType() const
Definition: Type.h:4324
QualType getModifiedType() const
Definition: Type.h:4460
Represents a pointer to an Objective C object.
Definition: Type.h:5804
Pointer to a block type.
Definition: Type.h:2649
bool isSugared() const
Returns whether this type directly provides sugar.
Definition: Type.cpp:3170
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4380
Complex values, per C99 6.2.5p11.
Definition: Type.h:2487
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4922
const llvm::APInt & getSize() const
Definition: Type.h:2900
Kind getAttrKind() const
Definition: Type.h:4456
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
Definition: Decl.h:1059
ExtVectorType - Extended vector type.
Definition: Type.h:3297
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2683
bool isVolatile() const
Definition: Type.h:3641
unsigned CalculateHash()
Definition: ODRHash.cpp:198
The template argument is a type.
Definition: TemplateBase.h:59
QualType getUnderlyingType() const
Definition: Type.h:4244
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:209
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1629
TypedefNameDecl * getDecl() const
Definition: Type.h:4177
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:234
unsigned getDepth() const
Definition: Type.h:4575
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4435
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:5474
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:2653
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:5274
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:4930
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:2936
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:5179
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:4634
Declaration of a class template.
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2401
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3479
void AddStmt(const Stmt *S)
Definition: ODRHash.cpp:24
NameKind getKind() const
unsigned getNumElements() const
Definition: Type.h:3214
bool isReadOnly() const
Definition: Type.h:6045
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:3096
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4851
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:2135
static bool isWhitelistedDecl(const Decl *D, const DeclContext *Parent)
Definition: ODRHash.cpp:432
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:647
A set of overloaded template declarations.
Definition: TemplateName.h:194
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:2981
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:2163
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2882
Declaration of a template function.
Definition: DeclTemplate.h:968
bool isDeletedAsWritten() const
Definition: Decl.h:2139
QualType getPointeeType() const
Definition: Type.h:2786
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:97
A single template declaration.
Definition: TemplateName.h:191
const IdentifierInfo * getIdentifier() const
Definition: Type.h:5301
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:5820