clang  6.0.0svn
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::AddDecl(const Decl *D) {
470  assert(D && "Expecting non-null pointer.");
471  auto Result = DeclMap.insert(std::make_pair(D, DeclMap.size()));
472  ID.AddInteger(Result.first->second);
473  // On first encounter of a Decl pointer, process it. Every time afterwards,
474  // only the index value is needed.
475  if (!Result.second) {
476  return;
477  }
478 
479  ID.AddInteger(D->getKind());
480 
481  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
482  AddDeclarationName(ND->getDeclName());
483  }
484 }
485 
486 namespace {
487 // Process a Type pointer. Add* methods call back into ODRHash while Visit*
488 // methods process the relevant parts of the Type.
489 class ODRTypeVisitor : public TypeVisitor<ODRTypeVisitor> {
490  typedef TypeVisitor<ODRTypeVisitor> Inherited;
491  llvm::FoldingSetNodeID &ID;
492  ODRHash &Hash;
493 
494 public:
495  ODRTypeVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
496  : ID(ID), Hash(Hash) {}
497 
498  void AddStmt(Stmt *S) {
499  Hash.AddBoolean(S);
500  if (S) {
501  Hash.AddStmt(S);
502  }
503  }
504 
505  void AddDecl(Decl *D) {
506  Hash.AddBoolean(D);
507  if (D) {
508  Hash.AddDecl(D);
509  }
510  }
511 
512  void AddQualType(QualType T) {
513  Hash.AddQualType(T);
514  }
515 
516  void AddType(const Type *T) {
517  Hash.AddBoolean(T);
518  if (T) {
519  Hash.AddType(T);
520  }
521  }
522 
524  Hash.AddBoolean(NNS);
525  if (NNS) {
526  Hash.AddNestedNameSpecifier(NNS);
527  }
528  }
529 
530  void AddIdentifierInfo(const IdentifierInfo *II) {
531  Hash.AddBoolean(II);
532  if (II) {
533  Hash.AddIdentifierInfo(II);
534  }
535  }
536 
537  void VisitQualifiers(Qualifiers Quals) {
538  ID.AddInteger(Quals.getAsOpaqueValue());
539  }
540 
541  void Visit(const Type *T) {
542  ID.AddInteger(T->getTypeClass());
543  Inherited::Visit(T);
544  }
545 
546  void VisitType(const Type *T) {}
547 
548  void VisitAdjustedType(const AdjustedType *T) {
551  VisitType(T);
552  }
553 
554  void VisitDecayedType(const DecayedType *T) {
557  VisitAdjustedType(T);
558  }
559 
560  void VisitArrayType(const ArrayType *T) {
562  ID.AddInteger(T->getSizeModifier());
563  VisitQualifiers(T->getIndexTypeQualifiers());
564  VisitType(T);
565  }
566  void VisitConstantArrayType(const ConstantArrayType *T) {
567  T->getSize().Profile(ID);
568  VisitArrayType(T);
569  }
570 
571  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
572  AddStmt(T->getSizeExpr());
573  VisitArrayType(T);
574  }
575 
576  void VisitIncompleteArrayType(const IncompleteArrayType *T) {
577  VisitArrayType(T);
578  }
579 
580  void VisitVariableArrayType(const VariableArrayType *T) {
581  AddStmt(T->getSizeExpr());
582  VisitArrayType(T);
583  }
584 
585  void VisitBuiltinType(const BuiltinType *T) {
586  ID.AddInteger(T->getKind());
587  VisitType(T);
588  }
589 
590  void VisitFunctionType(const FunctionType *T) {
592  T->getExtInfo().Profile(ID);
593  Hash.AddBoolean(T->isConst());
594  Hash.AddBoolean(T->isVolatile());
595  Hash.AddBoolean(T->isRestrict());
596  VisitType(T);
597  }
598 
599  void VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
600  VisitFunctionType(T);
601  }
602 
603  void VisitFunctionProtoType(const FunctionProtoType *T) {
604  ID.AddInteger(T->getNumParams());
605  for (auto ParamType : T->getParamTypes())
606  AddQualType(ParamType);
607 
608  VisitFunctionType(T);
609  }
610 
611  void VisitTypedefType(const TypedefType *T) {
612  AddDecl(T->getDecl());
613  QualType UnderlyingType = T->getDecl()->getUnderlyingType();
614  VisitQualifiers(UnderlyingType.getQualifiers());
615  while (const TypedefType *Underlying =
616  dyn_cast<TypedefType>(UnderlyingType.getTypePtr())) {
617  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
618  }
619  AddType(UnderlyingType.getTypePtr());
620  VisitType(T);
621  }
622 
623  void VisitTagType(const TagType *T) {
624  AddDecl(T->getDecl());
625  VisitType(T);
626  }
627 
628  void VisitRecordType(const RecordType *T) { VisitTagType(T); }
629  void VisitEnumType(const EnumType *T) { VisitTagType(T); }
630 
631  void VisitTypeWithKeyword(const TypeWithKeyword *T) {
632  ID.AddInteger(T->getKeyword());
633  VisitType(T);
634  };
635 
636  void VisitDependentNameType(const DependentNameType *T) {
639  VisitTypeWithKeyword(T);
640  }
641 
642  void VisitDependentTemplateSpecializationType(
646  ID.AddInteger(T->getNumArgs());
647  for (const auto &TA : T->template_arguments()) {
648  Hash.AddTemplateArgument(TA);
649  }
650  VisitTypeWithKeyword(T);
651  }
652 
653  void VisitElaboratedType(const ElaboratedType *T) {
656  VisitTypeWithKeyword(T);
657  }
658 
659  void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
660  ID.AddInteger(T->getNumArgs());
661  for (const auto &TA : T->template_arguments()) {
662  Hash.AddTemplateArgument(TA);
663  }
664  Hash.AddTemplateName(T->getTemplateName());
665  VisitType(T);
666  }
667 
668  void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
669  ID.AddInteger(T->getDepth());
670  ID.AddInteger(T->getIndex());
671  Hash.AddBoolean(T->isParameterPack());
672  AddDecl(T->getDecl());
673  }
674 };
675 } // namespace
676 
677 void ODRHash::AddType(const Type *T) {
678  assert(T && "Expecting non-null pointer.");
679  auto Result = TypeMap.insert(std::make_pair(T, TypeMap.size()));
680  ID.AddInteger(Result.first->second);
681  // On first encounter of a Type pointer, process it. Every time afterwards,
682  // only the index value is needed.
683  if (!Result.second) {
684  return;
685  }
686 
687  ODRTypeVisitor(ID, *this).Visit(T);
688 }
689 
691  AddBoolean(T.isNull());
692  if (T.isNull())
693  return;
694  SplitQualType split = T.split();
695  ID.AddInteger(split.Quals.getAsOpaqueValue());
696  AddType(split.Ty);
697 }
698 
700  Bools.push_back(Value);
701 }
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:4786
const Type * Ty
The locally-unqualified type.
Definition: Type.h:594
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1698
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Definition: Type.h:653
base_class_range bases()
Definition: DeclCXX.h:773
void AddBoolean(bool value)
Definition: ODRHash.cpp:699
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:767
QualType getDecayedType() const
Definition: Type.h:2377
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:3183
Stmt - This represents one statement.
Definition: Stmt.h:66
Expr * getBitWidth() const
Definition: Decl.h:2550
void AddQualType(QualType T)
Definition: ODRHash.cpp:690
Kind getKind() const
Definition: Type.h:2166
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3058
TypedefDecl - Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier...
Definition: Decl.h:2892
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:4851
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:4870
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:1353
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2560
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:4224
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:1988
size_t param_size() const
Definition: Decl.h:2180
QualType getElementType() const
Definition: Type.h:2595
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:807
QualType getReturnType() const
Definition: Decl.h:2205
unsigned getNumParams() const
Definition: Type.h:3491
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:1576
A namespace, stored as a NamespaceDecl*.
bool isConst() const
Definition: Type.h:3215
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:1514
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:2349
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:3498
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:2461
bool isVolatile() const
Definition: DeclCXX.h:2007
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4565
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:2164
bool isUnarySelector() const
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2539
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
void AddDecl(const Decl *D)
Definition: ODRHash.cpp:469
#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:1367
#define remainder(__x, __y)
Definition: tgmath.h:1106
QualType getPointeeType() const
Definition: Type.h:6395
Expr * getSizeExpr() const
Definition: Type.h:2739
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:2796
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:3235
NodeId Parent
Definition: ASTDiff.cpp:192
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2912
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3270
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:2774
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:2239
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4942
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:628
unsigned getAsOpaqueValue() const
Definition: Type.h:265
const FunctionProtoType * T
Declaration of a template type parameter.
unsigned getIndex() const
Definition: Type.h:4221
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:4877
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:2235
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
Qualifiers Quals
The local qualifiers.
Definition: Type.h:597
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1331
A helper class for Type nodes having an ElaboratedTypeKeyword.
Definition: Type.h:4735
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2597
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...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:5728
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:4747
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
QualType getAdjustedType() const
Definition: Type.h:2350
QualType getReturnType() const
Definition: Type.h:3203
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:1993
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4004
void AddType(const Type *T)
Definition: ODRHash.cpp:677
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:2598
bool isRestrict() const
Definition: Type.h:3217
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:4222
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:4812
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:2601
TypeClass getTypeClass() const
Definition: Type.h:1615
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
Definition: ODRHash.cpp:84
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:4946
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:2370
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:2796
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:2333
Dataflow Directional Tag Classes.
ExtInfo getExtInfo() const
Definition: Type.h:3214
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:493
NestedNameSpecifier * getQualifier() const
Definition: Type.h:4933
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1252
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:2847
AccessSpecifier getAccess() const
Definition: DeclBase.h:460
const Expr * getInit() const
Definition: Decl.h:1213
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:3978
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4573
const llvm::APInt & getSize() const
Definition: Type.h:2638
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
Definition: Decl.h:1050
bool isVolatile() const
Definition: Type.h:3216
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:3775
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:235
unsigned getDepth() const
Definition: Type.h:4220
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2536
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:4903
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:4579
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:2674
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:4815
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:2145
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:4495
QualType getDefaultArgument() const
Retrieve the default argument, if any.
QualType getType() const
Definition: Decl.h:639
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:2719
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:2111
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2620
bool isDeletedAsWritten() const
Definition: Decl.h:2075
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:4934