clang  6.0.0
ODRHash.cpp
Go to the documentation of this file.
1 //===-- ODRHash.cpp - Hashing to diagnose ODR failures ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file implements the ODRHash class, which calculates a hash based
12 /// on AST nodes, which is stable across different runs.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #include "clang/AST/ODRHash.h"
17 
18 #include "clang/AST/DeclVisitor.h"
20 #include "clang/AST/StmtVisitor.h"
21 #include "clang/AST/TypeVisitor.h"
22 
23 using namespace clang;
24 
25 void ODRHash::AddStmt(const Stmt *S) {
26  assert(S && "Expecting non-null pointer.");
27  S->ProcessODRHash(ID, *this);
28 }
29 
31  assert(II && "Expecting non-null pointer.");
32  ID.AddString(II->getName());
33 }
34 
36  AddBoolean(Name.isEmpty());
37  if (Name.isEmpty())
38  return;
39 
40  auto Kind = Name.getNameKind();
41  ID.AddInteger(Kind);
42  switch (Kind) {
45  break;
49  Selector S = Name.getObjCSelector();
50  AddBoolean(S.isNull());
53  unsigned NumArgs = S.getNumArgs();
54  for (unsigned i = 0; i < NumArgs; ++i) {
56  }
57  break;
58  }
62  break;
64  ID.AddInteger(Name.getCXXOverloadedOperator());
65  break;
68  break;
71  break;
73  break;
75  auto *Template = Name.getCXXDeductionGuideTemplate();
76  AddBoolean(Template);
77  if (Template) {
78  AddDecl(Template);
79  }
80  }
81  }
82 }
83 
85  assert(NNS && "Expecting non-null pointer.");
86  const auto *Prefix = NNS->getPrefix();
87  AddBoolean(Prefix);
88  if (Prefix) {
89  AddNestedNameSpecifier(Prefix);
90  }
91  auto Kind = NNS->getKind();
92  ID.AddInteger(Kind);
93  switch (Kind) {
96  break;
98  AddDecl(NNS->getAsNamespace());
99  break;
102  break;
105  AddType(NNS->getAsType());
106  break;
109  break;
110  }
111 }
112 
114  auto Kind = Name.getKind();
115  ID.AddInteger(Kind);
116 
117  switch (Kind) {
119  AddDecl(Name.getAsTemplateDecl());
120  break;
121  // TODO: Support these cases.
127  break;
128  }
129 }
130 
132  const auto Kind = TA.getKind();
133  ID.AddInteger(Kind);
134 
135  switch (Kind) {
137  llvm_unreachable("Expected valid TemplateArgument");
139  AddQualType(TA.getAsType());
140  break;
144  break;
148  break;
150  AddStmt(TA.getAsExpr());
151  break;
153  ID.AddInteger(TA.pack_size());
154  for (auto SubTA : TA.pack_elements()) {
155  AddTemplateArgument(SubTA);
156  }
157  break;
158  }
159 }
160 
162  assert(TPL && "Expecting non-null pointer.");
163 
164  ID.AddInteger(TPL->size());
165  for (auto *ND : TPL->asArray()) {
166  AddSubDecl(ND);
167  }
168 }
169 
171  DeclMap.clear();
172  TypeMap.clear();
173  Bools.clear();
174  ID.clear();
175 }
176 
178  // Append the bools to the end of the data segment backwards. This allows
179  // for the bools data to be compressed 32 times smaller compared to using
180  // ID.AddBoolean
181  const unsigned unsigned_bits = sizeof(unsigned) * CHAR_BIT;
182  const unsigned size = Bools.size();
183  const unsigned remainder = size % unsigned_bits;
184  const unsigned loops = size / unsigned_bits;
185  auto I = Bools.rbegin();
186  unsigned value = 0;
187  for (unsigned i = 0; i < remainder; ++i) {
188  value <<= 1;
189  value |= *I;
190  ++I;
191  }
192  ID.AddInteger(value);
193 
194  for (unsigned i = 0; i < loops; ++i) {
195  value = 0;
196  for (unsigned j = 0; j < unsigned_bits; ++j) {
197  value <<= 1;
198  value |= *I;
199  ++I;
200  }
201  ID.AddInteger(value);
202  }
203 
204  assert(I == Bools.rend());
205  Bools.clear();
206  return ID.ComputeHash();
207 }
208 
209 namespace {
210 // Process a Decl pointer. Add* methods call back into ODRHash while Visit*
211 // methods process the relevant parts of the Decl.
212 class ODRDeclVisitor : public ConstDeclVisitor<ODRDeclVisitor> {
213  typedef ConstDeclVisitor<ODRDeclVisitor> Inherited;
214  llvm::FoldingSetNodeID &ID;
215  ODRHash &Hash;
216 
217 public:
218  ODRDeclVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
219  : ID(ID), Hash(Hash) {}
220 
221  void AddStmt(const Stmt *S) {
222  Hash.AddBoolean(S);
223  if (S) {
224  Hash.AddStmt(S);
225  }
226  }
227 
228  void AddIdentifierInfo(const IdentifierInfo *II) {
229  Hash.AddBoolean(II);
230  if (II) {
231  Hash.AddIdentifierInfo(II);
232  }
233  }
234 
235  void AddQualType(QualType T) {
236  Hash.AddQualType(T);
237  }
238 
239  void AddDecl(const Decl *D) {
240  Hash.AddBoolean(D);
241  if (D) {
242  Hash.AddDecl(D);
243  }
244  }
245 
247  Hash.AddTemplateArgument(TA);
248  }
249 
250  void Visit(const Decl *D) {
251  ID.AddInteger(D->getKind());
252  Inherited::Visit(D);
253  }
254 
255  void VisitNamedDecl(const NamedDecl *D) {
256  Hash.AddDeclarationName(D->getDeclName());
257  Inherited::VisitNamedDecl(D);
258  }
259 
260  void VisitValueDecl(const ValueDecl *D) {
261  if (!isa<FunctionDecl>(D)) {
262  AddQualType(D->getType());
263  }
264  Inherited::VisitValueDecl(D);
265  }
266 
267  void VisitVarDecl(const VarDecl *D) {
268  Hash.AddBoolean(D->isStaticLocal());
269  Hash.AddBoolean(D->isConstexpr());
270  const bool HasInit = D->hasInit();
271  Hash.AddBoolean(HasInit);
272  if (HasInit) {
273  AddStmt(D->getInit());
274  }
275  Inherited::VisitVarDecl(D);
276  }
277 
278  void VisitParmVarDecl(const ParmVarDecl *D) {
279  // TODO: Handle default arguments.
280  Inherited::VisitParmVarDecl(D);
281  }
282 
283  void VisitAccessSpecDecl(const AccessSpecDecl *D) {
284  ID.AddInteger(D->getAccess());
285  Inherited::VisitAccessSpecDecl(D);
286  }
287 
288  void VisitStaticAssertDecl(const StaticAssertDecl *D) {
289  AddStmt(D->getAssertExpr());
290  AddStmt(D->getMessage());
291 
292  Inherited::VisitStaticAssertDecl(D);
293  }
294 
295  void VisitFieldDecl(const FieldDecl *D) {
296  const bool IsBitfield = D->isBitField();
297  Hash.AddBoolean(IsBitfield);
298 
299  if (IsBitfield) {
300  AddStmt(D->getBitWidth());
301  }
302 
303  Hash.AddBoolean(D->isMutable());
305 
306  Inherited::VisitFieldDecl(D);
307  }
308 
309  void VisitFunctionDecl(const FunctionDecl *D) {
310  ID.AddInteger(D->getStorageClass());
311  Hash.AddBoolean(D->isInlineSpecified());
312  Hash.AddBoolean(D->isVirtualAsWritten());
313  Hash.AddBoolean(D->isPure());
314  Hash.AddBoolean(D->isDeletedAsWritten());
315 
316  ID.AddInteger(D->param_size());
317 
318  for (auto *Param : D->parameters()) {
319  Hash.AddSubDecl(Param);
320  }
321 
323 
324  Inherited::VisitFunctionDecl(D);
325  }
326 
327  void VisitCXXMethodDecl(const CXXMethodDecl *D) {
328  Hash.AddBoolean(D->isConst());
329  Hash.AddBoolean(D->isVolatile());
330 
331  Inherited::VisitCXXMethodDecl(D);
332  }
333 
334  void VisitTypedefNameDecl(const TypedefNameDecl *D) {
336 
337  Inherited::VisitTypedefNameDecl(D);
338  }
339 
340  void VisitTypedefDecl(const TypedefDecl *D) {
341  Inherited::VisitTypedefDecl(D);
342  }
343 
344  void VisitTypeAliasDecl(const TypeAliasDecl *D) {
345  Inherited::VisitTypeAliasDecl(D);
346  }
347 
348  void VisitFriendDecl(const FriendDecl *D) {
349  TypeSourceInfo *TSI = D->getFriendType();
350  Hash.AddBoolean(TSI);
351  if (TSI) {
352  AddQualType(TSI->getType());
353  } else {
354  AddDecl(D->getFriendDecl());
355  }
356  }
357 
358  void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
359  // Only care about default arguments as part of the definition.
360  const bool hasDefaultArgument =
362  Hash.AddBoolean(hasDefaultArgument);
363  if (hasDefaultArgument) {
365  }
366 
367  Inherited::VisitTemplateTypeParmDecl(D);
368  }
369 
370  void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) {
371  // Only care about default arguments as part of the definition.
372  const bool hasDefaultArgument =
374  Hash.AddBoolean(hasDefaultArgument);
375  if (hasDefaultArgument) {
377  }
378 
379  Inherited::VisitNonTypeTemplateParmDecl(D);
380  }
381 
382  void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) {
383  // Only care about default arguments as part of the definition.
384  const bool hasDefaultArgument =
386  Hash.AddBoolean(hasDefaultArgument);
387  if (hasDefaultArgument) {
389  }
390 
391  Inherited::VisitTemplateTemplateParmDecl(D);
392  }
393 };
394 } // namespace
395 
396 // Only allow a small portion of Decl's to be processed. Remove this once
397 // all Decl's can be handled.
399  if (D->isImplicit()) return false;
400  if (D->getDeclContext() != Parent) return false;
401 
402  switch (D->getKind()) {
403  default:
404  return false;
405  case Decl::AccessSpec:
406  case Decl::CXXConstructor:
407  case Decl::CXXDestructor:
408  case Decl::CXXMethod:
409  case Decl::Field:
410  case Decl::Friend:
411  case Decl::StaticAssert:
412  case Decl::TypeAlias:
413  case Decl::Typedef:
414  case Decl::Var:
415  return true;
416  }
417 }
418 
419 void ODRHash::AddSubDecl(const Decl *D) {
420  assert(D && "Expecting non-null pointer.");
421  AddDecl(D);
422 
423  ODRDeclVisitor(ID, *this).Visit(D);
424 }
425 
427  assert(Record && Record->hasDefinition() &&
428  "Expected non-null record to be a definition.");
429 
430  const DeclContext *DC = Record;
431  while (DC) {
432  if (isa<ClassTemplateSpecializationDecl>(DC)) {
433  return;
434  }
435  DC = DC->getParent();
436  }
437 
438  AddDecl(Record);
439 
440  // Filter out sub-Decls which will not be processed in order to get an
441  // accurate count of Decl's.
443  for (const Decl *SubDecl : Record->decls()) {
444  if (isWhitelistedDecl(SubDecl, Record)) {
445  Decls.push_back(SubDecl);
446  }
447  }
448 
449  ID.AddInteger(Decls.size());
450  for (auto SubDecl : Decls) {
451  AddSubDecl(SubDecl);
452  }
453 
454  const ClassTemplateDecl *TD = Record->getDescribedClassTemplate();
455  AddBoolean(TD);
456  if (TD) {
458  }
459 
460  ID.AddInteger(Record->getNumBases());
461  auto Bases = Record->bases();
462  for (auto Base : Bases) {
463  AddQualType(Base.getType());
464  ID.AddInteger(Base.isVirtual());
465  ID.AddInteger(Base.getAccessSpecifierAsWritten());
466  }
467 }
468 
469 void ODRHash::AddFunctionDecl(const FunctionDecl *Function) {
470  assert(Function && "Expecting non-null pointer.");
471 
472  // Skip hashing these kinds of function.
473  if (Function->isImplicit()) return;
474  if (Function->isDefaulted()) return;
475  if (Function->isDeleted()) return;
476  if (!Function->hasBody()) return;
477  if (!Function->getBody()) return;
478 
479  // TODO: Fix hashing for class methods.
480  if (isa<CXXMethodDecl>(Function)) return;
481  // And friend functions.
482  if (Function->getFriendObjectKind()) return;
483 
484  // Skip functions that are specializations or in specialization context.
485  const DeclContext *DC = Function;
486  while (DC) {
487  if (isa<ClassTemplateSpecializationDecl>(DC)) return;
488  if (auto *F = dyn_cast<FunctionDecl>(DC))
489  if (F->isFunctionTemplateSpecialization()) return;
490  DC = DC->getParent();
491  }
492 
493  AddDecl(Function);
494 
495  AddQualType(Function->getReturnType());
496 
497  ID.AddInteger(Function->param_size());
498  for (auto Param : Function->parameters())
499  AddSubDecl(Param);
500 
501  AddStmt(Function->getBody());
502 }
503 
504 void ODRHash::AddDecl(const Decl *D) {
505  assert(D && "Expecting non-null pointer.");
506  D = D->getCanonicalDecl();
507  auto Result = DeclMap.insert(std::make_pair(D, DeclMap.size()));
508  ID.AddInteger(Result.first->second);
509  // On first encounter of a Decl pointer, process it. Every time afterwards,
510  // only the index value is needed.
511  if (!Result.second) {
512  return;
513  }
514 
515  ID.AddInteger(D->getKind());
516 
517  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
518  AddDeclarationName(ND->getDeclName());
519  }
520 }
521 
522 namespace {
523 // Process a Type pointer. Add* methods call back into ODRHash while Visit*
524 // methods process the relevant parts of the Type.
525 class ODRTypeVisitor : public TypeVisitor<ODRTypeVisitor> {
526  typedef TypeVisitor<ODRTypeVisitor> Inherited;
527  llvm::FoldingSetNodeID &ID;
528  ODRHash &Hash;
529 
530 public:
531  ODRTypeVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
532  : ID(ID), Hash(Hash) {}
533 
534  void AddStmt(Stmt *S) {
535  Hash.AddBoolean(S);
536  if (S) {
537  Hash.AddStmt(S);
538  }
539  }
540 
541  void AddDecl(Decl *D) {
542  Hash.AddBoolean(D);
543  if (D) {
544  Hash.AddDecl(D);
545  }
546  }
547 
548  void AddQualType(QualType T) {
549  Hash.AddQualType(T);
550  }
551 
552  void AddType(const Type *T) {
553  Hash.AddBoolean(T);
554  if (T) {
555  Hash.AddType(T);
556  }
557  }
558 
560  Hash.AddBoolean(NNS);
561  if (NNS) {
562  Hash.AddNestedNameSpecifier(NNS);
563  }
564  }
565 
566  void AddIdentifierInfo(const IdentifierInfo *II) {
567  Hash.AddBoolean(II);
568  if (II) {
569  Hash.AddIdentifierInfo(II);
570  }
571  }
572 
573  void VisitQualifiers(Qualifiers Quals) {
574  ID.AddInteger(Quals.getAsOpaqueValue());
575  }
576 
577  void Visit(const Type *T) {
578  ID.AddInteger(T->getTypeClass());
579  Inherited::Visit(T);
580  }
581 
582  void VisitType(const Type *T) {}
583 
584  void VisitAdjustedType(const AdjustedType *T) {
587  VisitType(T);
588  }
589 
590  void VisitDecayedType(const DecayedType *T) {
593  VisitAdjustedType(T);
594  }
595 
596  void VisitArrayType(const ArrayType *T) {
598  ID.AddInteger(T->getSizeModifier());
599  VisitQualifiers(T->getIndexTypeQualifiers());
600  VisitType(T);
601  }
602  void VisitConstantArrayType(const ConstantArrayType *T) {
603  T->getSize().Profile(ID);
604  VisitArrayType(T);
605  }
606 
607  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
608  AddStmt(T->getSizeExpr());
609  VisitArrayType(T);
610  }
611 
612  void VisitIncompleteArrayType(const IncompleteArrayType *T) {
613  VisitArrayType(T);
614  }
615 
616  void VisitVariableArrayType(const VariableArrayType *T) {
617  AddStmt(T->getSizeExpr());
618  VisitArrayType(T);
619  }
620 
621  void VisitBuiltinType(const BuiltinType *T) {
622  ID.AddInteger(T->getKind());
623  VisitType(T);
624  }
625 
626  void VisitFunctionType(const FunctionType *T) {
628  T->getExtInfo().Profile(ID);
629  Hash.AddBoolean(T->isConst());
630  Hash.AddBoolean(T->isVolatile());
631  Hash.AddBoolean(T->isRestrict());
632  VisitType(T);
633  }
634 
635  void VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
636  VisitFunctionType(T);
637  }
638 
639  void VisitFunctionProtoType(const FunctionProtoType *T) {
640  ID.AddInteger(T->getNumParams());
641  for (auto ParamType : T->getParamTypes())
642  AddQualType(ParamType);
643 
644  VisitFunctionType(T);
645  }
646 
647  void VisitTypedefType(const TypedefType *T) {
648  AddDecl(T->getDecl());
649  QualType UnderlyingType = T->getDecl()->getUnderlyingType();
650  VisitQualifiers(UnderlyingType.getQualifiers());
651  while (const TypedefType *Underlying =
652  dyn_cast<TypedefType>(UnderlyingType.getTypePtr())) {
653  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
654  }
655  AddType(UnderlyingType.getTypePtr());
656  VisitType(T);
657  }
658 
659  void VisitTagType(const TagType *T) {
660  AddDecl(T->getDecl());
661  VisitType(T);
662  }
663 
664  void VisitRecordType(const RecordType *T) { VisitTagType(T); }
665  void VisitEnumType(const EnumType *T) { VisitTagType(T); }
666 
667  void VisitTypeWithKeyword(const TypeWithKeyword *T) {
668  ID.AddInteger(T->getKeyword());
669  VisitType(T);
670  };
671 
672  void VisitDependentNameType(const DependentNameType *T) {
675  VisitTypeWithKeyword(T);
676  }
677 
678  void VisitDependentTemplateSpecializationType(
682  ID.AddInteger(T->getNumArgs());
683  for (const auto &TA : T->template_arguments()) {
684  Hash.AddTemplateArgument(TA);
685  }
686  VisitTypeWithKeyword(T);
687  }
688 
689  void VisitElaboratedType(const ElaboratedType *T) {
692  VisitTypeWithKeyword(T);
693  }
694 
695  void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
696  ID.AddInteger(T->getNumArgs());
697  for (const auto &TA : T->template_arguments()) {
698  Hash.AddTemplateArgument(TA);
699  }
700  Hash.AddTemplateName(T->getTemplateName());
701  VisitType(T);
702  }
703 
704  void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
705  ID.AddInteger(T->getDepth());
706  ID.AddInteger(T->getIndex());
707  Hash.AddBoolean(T->isParameterPack());
708  AddDecl(T->getDecl());
709  }
710 };
711 } // namespace
712 
713 void ODRHash::AddType(const Type *T) {
714  assert(T && "Expecting non-null pointer.");
715  auto Result = TypeMap.insert(std::make_pair(T, TypeMap.size()));
716  ID.AddInteger(Result.first->second);
717  // On first encounter of a Type pointer, process it. Every time afterwards,
718  // only the index value is needed.
719  if (!Result.second) {
720  return;
721  }
722 
723  ODRTypeVisitor(ID, *this).Visit(T);
724 }
725 
727  AddBoolean(T.isNull());
728  if (T.isNull())
729  return;
730  SplitQualType split = T.split();
731  ID.AddInteger(split.Quals.getAsOpaqueValue());
732  AddType(split.Ty);
733 }
734 
736  Bools.push_back(Value);
737 }
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:4784
const Type * Ty
The locally-unqualified type.
Definition: Type.h:594
An instance of this class is created to represent a function declaration or definition.
Definition: Decl.h:1697
Smart pointer class that efficiently represents Objective-C method names.
void AddFunctionDecl(const FunctionDecl *Function)
Definition: ODRHash.cpp:469
A (possibly-)qualified type.
Definition: Type.h:653
base_class_range bases()
Definition: DeclCXX.h:773
void AddBoolean(bool value)
Definition: ODRHash.cpp:735
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:767
QualType getDecayedType() const
Definition: Type.h:2375
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:3181
Stmt - This represents one statement.
Definition: Stmt.h:66
Expr * getBitWidth() const
Definition: Decl.h:2556
void AddQualType(QualType T)
Definition: ODRHash.cpp:726
Kind getKind() const
Definition: Type.h:2164
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3056
TypedefDecl - Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier...
Definition: Decl.h:2898
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:4849
The template argument is an expression, and we&#39;ve not resolved it to one of the other forms yet...
Definition: TemplateBase.h:87
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:4868
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
TagDecl * getDecl() const
Definition: Type.cpp:3037
ArrayRef< NamedDecl * > asArray()
Definition: DeclTemplate.h:126
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
The base class of the type hierarchy.
Definition: Type.h:1351
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2558
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:64
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:4222
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:1991
size_t param_size() const
Definition: Decl.h:2183
QualType getElementType() const
Definition: Type.h:2593
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
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:54
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:806
QualType getReturnType() const
Definition: Decl.h:2207
unsigned getNumParams() const
Definition: Type.h:3489
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
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:57
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:1580
A namespace, stored as a NamespaceDecl*.
bool isConst() const
Definition: Type.h:3213
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
void AddTemplateArgument(TemplateArgument TA)
Definition: ODRHash.cpp:131
bool hasDefinition() const
Definition: DeclCXX.h:738
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1513
The collection of all-type qualifiers we support.
Definition: Type.h:152
void clear()
Definition: ODRHash.cpp:170
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:291
QualType getOriginalType() const
Definition: Type.h:2347
static bool isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Record)
Definition: ODRHash.cpp:398
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:124
bool isConst() const
Definition: DeclCXX.h:2006
StringLiteral * getMessage()
Definition: DeclCXX.h:3695
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:330
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3496
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:72
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2467
bool isVolatile() const
Definition: DeclCXX.h:2007
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4563
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
An operation on a type.
Definition: TypeVisitor.h:65
NamedDecl * getFriendDecl() const
If this friend declaration doesn&#39;t name a type, return the inner declaration.
Definition: DeclFriend.h:139
void AddTemplateParameterList(const TemplateParameterList *TPL)
Definition: ODRHash.cpp:161
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:131
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2167
bool isUnarySelector() const
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2545
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:2616
void AddDecl(const Decl *D)
Definition: ODRHash.cpp:504
#define CHAR_BIT
Definition: limits.h:79
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1366
#define remainder(__x, __y)
Definition: tgmath.h:1106
QualType getPointeeType() const
Definition: Type.h:6393
Expr * getSizeExpr() const
Definition: Type.h:2737
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Expr * getSizeExpr() const
Definition: Type.h:2794
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:869
void AddTemplateName(TemplateName Name)
Definition: ODRHash.cpp:113
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3233
NodeId Parent
Definition: ASTDiff.cpp:192
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2918
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3268
A dependent template name that has not been resolved to a template (or set of templates).
Definition: TemplateName.h:202
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:2772
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:432
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2241
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4940
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:627
bool isDefaulted() const
Whether this function is defaulted per C++0x.
Definition: Decl.h:2012
unsigned getAsOpaqueValue() const
Definition: Type.h:265
const FunctionProtoType * T
Declaration of a template type parameter.
unsigned getIndex() const
Definition: Type.h:4219
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:68
void AddDeclarationName(DeclarationName Name)
Definition: ODRHash.cpp:35
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:551
DeclContext * getDeclContext()
Definition: DeclBase.h:425
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:4875
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:2237
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
A namespace alias, stored as a NamespaceAliasDecl*.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn&#39;t a simple identifier.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:592
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
Definition: Decl.cpp:2580
Qualifiers Quals
The local qualifiers.
Definition: Type.h:597
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1335
A helper class for Type nodes having an ElaboratedTypeKeyword.
Definition: Type.h:4733
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2595
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
unsigned getNumArgs() const
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:719
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
Definition: DeclBase.h:1102
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:5726
A template template parameter pack that has been substituted for a template template argument pack...
Definition: TemplateName.h:211
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
Kind
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:4745
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
QualType getAdjustedType() const
Definition: Type.h:2348
QualType getReturnType() const
Definition: Type.h:3201
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:1996
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4002
void AddType(const Type *T)
Definition: ODRHash.cpp:713
void AddIdentifierInfo(const IdentifierInfo *II)
Definition: ODRHash.cpp:30
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2604
bool isRestrict() const
Definition: Type.h:3215
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1964
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isParameterPack() const
Definition: Type.h:4220
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:360
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:4810
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:2599
TypeClass getTypeClass() const
Definition: Type.h:1613
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
Definition: ODRHash.cpp:84
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:4944
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3669
void AddSubDecl(const Decl *D)
Definition: ODRHash.cpp:419
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2368
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:354
StringRef getName() const
Return the actual identifier string.
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2802
Represents a template argument.
Definition: TemplateBase.h:51
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
Definition: Type.h:2331
Dataflow Directional Tag Classes.
ExtInfo getExtInfo() const
Definition: Type.h:3212
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:493
NestedNameSpecifier * getQualifier() const
Definition: Type.h:4931
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1256
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:80
QualType getUnderlyingType() const
Definition: Decl.h:2853
AccessSpecifier getAccess() const
Definition: DeclBase.h:460
const Expr * getInit() const
Definition: Decl.h:1212
void AddCXXRecordDecl(const CXXRecordDecl *Record)
Definition: ODRHash.cpp:426
DeclarationName - The name of a declaration.
Kind getKind() const
Definition: DeclBase.h:419
bool isKeywordSelector() const
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*.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3976
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4571
const llvm::APInt & getSize() const
Definition: Type.h:2636
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
Definition: Decl.h:1049
bool isVolatile() const
Definition: Type.h:3214
unsigned CalculateHash()
Definition: ODRHash.cpp:177
The template argument is a type.
Definition: TemplateBase.h:60
The template argument is actually a parameter pack.
Definition: TemplateBase.h:91
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1378
TypedefNameDecl * getDecl() const
Definition: Type.h:3773
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:235
unsigned getDepth() const
Definition: Type.h:4218
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2542
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:4901
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:4577
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:76
Represents a C array with an unspecified size.
Definition: Type.h:2672
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:4813
bool isNull() const
Determine whether this is the empty selector.
Declaration of a class template.
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2143
void AddStmt(const Stmt *S)
Definition: ODRHash.cpp:25
NameKind getKind() const
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:257
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4493
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:2077
QualType getDefaultArgument() const
Retrieve the default argument, if any.
QualType getType() const
Definition: Decl.h:638
A set of overloaded template declarations.
Definition: TemplateName.h:194
NamedDecl - This represents a decl with a name.
Definition: Decl.h:245
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2717
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:77
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:288
bool hasInit() const
Definition: Decl.cpp:2115
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2618
bool isDeletedAsWritten() const
Definition: Decl.h:2078
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:4932