clang  5.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 
164  DeclMap.clear();
165  TypeMap.clear();
166  Bools.clear();
167  ID.clear();
168 }
169 
171  // Append the bools to the end of the data segment backwards. This allows
172  // for the bools data to be compressed 32 times smaller compared to using
173  // ID.AddBoolean
174  const unsigned unsigned_bits = sizeof(unsigned) * CHAR_BIT;
175  const unsigned size = Bools.size();
176  const unsigned remainder = size % unsigned_bits;
177  const unsigned loops = size / unsigned_bits;
178  auto I = Bools.rbegin();
179  unsigned value = 0;
180  for (unsigned i = 0; i < remainder; ++i) {
181  value <<= 1;
182  value |= *I;
183  ++I;
184  }
185  ID.AddInteger(value);
186 
187  for (unsigned i = 0; i < loops; ++i) {
188  value = 0;
189  for (unsigned j = 0; j < unsigned_bits; ++j) {
190  value <<= 1;
191  value |= *I;
192  ++I;
193  }
194  ID.AddInteger(value);
195  }
196 
197  assert(I == Bools.rend());
198  Bools.clear();
199  return ID.ComputeHash();
200 }
201 
202 // Process a Decl pointer. Add* methods call back into ODRHash while Visit*
203 // methods process the relevant parts of the Decl.
204 class ODRDeclVisitor : public ConstDeclVisitor<ODRDeclVisitor> {
206  llvm::FoldingSetNodeID &ID;
207  ODRHash &Hash;
208 
209 public:
210  ODRDeclVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
211  : ID(ID), Hash(Hash) {}
212 
213  void AddStmt(const Stmt *S) {
214  Hash.AddBoolean(S);
215  if (S) {
216  Hash.AddStmt(S);
217  }
218  }
219 
221  Hash.AddBoolean(II);
222  if (II) {
223  Hash.AddIdentifierInfo(II);
224  }
225  }
226 
228  Hash.AddQualType(T);
229  }
230 
231  void AddDecl(const Decl *D) {
232  Hash.AddBoolean(D);
233  if (D) {
234  Hash.AddDecl(D);
235  }
236  }
237 
238  void Visit(const Decl *D) {
239  ID.AddInteger(D->getKind());
240  Inherited::Visit(D);
241  }
242 
243  void VisitNamedDecl(const NamedDecl *D) {
244  Hash.AddDeclarationName(D->getDeclName());
245  Inherited::VisitNamedDecl(D);
246  }
247 
248  void VisitValueDecl(const ValueDecl *D) {
249  if (!isa<FunctionDecl>(D)) {
250  AddQualType(D->getType());
251  }
252  Inherited::VisitValueDecl(D);
253  }
254 
255  void VisitVarDecl(const VarDecl *D) {
256  Hash.AddBoolean(D->isStaticLocal());
257  Hash.AddBoolean(D->isConstexpr());
258  const bool HasInit = D->hasInit();
259  Hash.AddBoolean(HasInit);
260  if (HasInit) {
261  AddStmt(D->getInit());
262  }
263  Inherited::VisitVarDecl(D);
264  }
265 
266  void VisitParmVarDecl(const ParmVarDecl *D) {
267  // TODO: Handle default arguments.
268  Inherited::VisitParmVarDecl(D);
269  }
270 
272  ID.AddInteger(D->getAccess());
273  Inherited::VisitAccessSpecDecl(D);
274  }
275 
277  AddStmt(D->getAssertExpr());
278  AddStmt(D->getMessage());
279 
280  Inherited::VisitStaticAssertDecl(D);
281  }
282 
283  void VisitFieldDecl(const FieldDecl *D) {
284  const bool IsBitfield = D->isBitField();
285  Hash.AddBoolean(IsBitfield);
286 
287  if (IsBitfield) {
288  AddStmt(D->getBitWidth());
289  }
290 
291  Hash.AddBoolean(D->isMutable());
292  AddStmt(D->getInClassInitializer());
293 
294  Inherited::VisitFieldDecl(D);
295  }
296 
298  ID.AddInteger(D->getStorageClass());
299  Hash.AddBoolean(D->isInlineSpecified());
300  Hash.AddBoolean(D->isVirtualAsWritten());
301  Hash.AddBoolean(D->isPure());
302  Hash.AddBoolean(D->isDeletedAsWritten());
303 
304  ID.AddInteger(D->param_size());
305 
306  for (auto *Param : D->parameters()) {
307  Hash.AddSubDecl(Param);
308  }
309 
310  AddQualType(D->getReturnType());
311 
312  Inherited::VisitFunctionDecl(D);
313  }
314 
316  Hash.AddBoolean(D->isConst());
317  Hash.AddBoolean(D->isVolatile());
318 
319  Inherited::VisitCXXMethodDecl(D);
320  }
321 
323  AddQualType(D->getUnderlyingType());
324 
325  Inherited::VisitTypedefNameDecl(D);
326  }
327 
328  void VisitTypedefDecl(const TypedefDecl *D) {
329  Inherited::VisitTypedefDecl(D);
330  }
331 
333  Inherited::VisitTypeAliasDecl(D);
334  }
335 
336  void VisitFriendDecl(const FriendDecl *D) {
337  TypeSourceInfo *TSI = D->getFriendType();
338  Hash.AddBoolean(TSI);
339  if (TSI) {
340  AddQualType(TSI->getType());
341  } else {
342  AddDecl(D->getFriendDecl());
343  }
344  }
345 };
346 
347 // Only allow a small portion of Decl's to be processed. Remove this once
348 // all Decl's can be handled.
349 bool ODRHash::isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Parent) {
350  if (D->isImplicit()) return false;
351  if (D->getDeclContext() != Parent) return false;
352 
353  switch (D->getKind()) {
354  default:
355  return false;
356  case Decl::AccessSpec:
357  case Decl::CXXConstructor:
358  case Decl::CXXDestructor:
359  case Decl::CXXMethod:
360  case Decl::Field:
361  case Decl::Friend:
362  case Decl::StaticAssert:
363  case Decl::TypeAlias:
364  case Decl::Typedef:
365  case Decl::Var:
366  return true;
367  }
368 }
369 
370 void ODRHash::AddSubDecl(const Decl *D) {
371  assert(D && "Expecting non-null pointer.");
372  AddDecl(D);
373 
374  ODRDeclVisitor(ID, *this).Visit(D);
375 }
376 
378  assert(Record && Record->hasDefinition() &&
379  "Expected non-null record to be a definition.");
380 
381  const DeclContext *DC = Record;
382  while (DC) {
383  if (isa<ClassTemplateSpecializationDecl>(DC)) {
384  return;
385  }
386  DC = DC->getParent();
387  }
388 
389  AddDecl(Record);
390 
391  // Filter out sub-Decls which will not be processed in order to get an
392  // accurate count of Decl's.
394  for (const Decl *SubDecl : Record->decls()) {
395  if (isWhitelistedDecl(SubDecl, Record)) {
396  Decls.push_back(SubDecl);
397  }
398  }
399 
400  ID.AddInteger(Decls.size());
401  for (auto SubDecl : Decls) {
402  AddSubDecl(SubDecl);
403  }
404 }
405 
406 void ODRHash::AddDecl(const Decl *D) {
407  assert(D && "Expecting non-null pointer.");
408  auto Result = DeclMap.insert(std::make_pair(D, DeclMap.size()));
409  ID.AddInteger(Result.first->second);
410  // On first encounter of a Decl pointer, process it. Every time afterwards,
411  // only the index value is needed.
412  if (!Result.second) {
413  return;
414  }
415 
416  ID.AddInteger(D->getKind());
417 
418  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
419  AddDeclarationName(ND->getDeclName());
420  }
421 }
422 
423 // Process a Type pointer. Add* methods call back into ODRHash while Visit*
424 // methods process the relevant parts of the Type.
425 class ODRTypeVisitor : public TypeVisitor<ODRTypeVisitor> {
427  llvm::FoldingSetNodeID &ID;
428  ODRHash &Hash;
429 
430 public:
431  ODRTypeVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
432  : ID(ID), Hash(Hash) {}
433 
434  void AddStmt(Stmt *S) {
435  Hash.AddBoolean(S);
436  if (S) {
437  Hash.AddStmt(S);
438  }
439  }
440 
441  void AddDecl(Decl *D) {
442  Hash.AddBoolean(D);
443  if (D) {
444  Hash.AddDecl(D);
445  }
446  }
447 
449  Hash.AddQualType(T);
450  }
451 
452  void AddType(const Type *T) {
453  Hash.AddBoolean(T);
454  if (T) {
455  Hash.AddType(T);
456  }
457  }
458 
460  Hash.AddBoolean(NNS);
461  if (NNS) {
462  Hash.AddNestedNameSpecifier(NNS);
463  }
464  }
465 
467  Hash.AddBoolean(II);
468  if (II) {
469  Hash.AddIdentifierInfo(II);
470  }
471  }
472 
474  ID.AddInteger(Quals.getAsOpaqueValue());
475  }
476 
477  void Visit(const Type *T) {
478  ID.AddInteger(T->getTypeClass());
479  Inherited::Visit(T);
480  }
481 
482  void VisitType(const Type *T) {}
483 
485  AddQualType(T->getOriginalType());
486  AddQualType(T->getAdjustedType());
487  VisitType(T);
488  }
489 
490  void VisitDecayedType(const DecayedType *T) {
491  AddQualType(T->getDecayedType());
492  AddQualType(T->getPointeeType());
493  VisitAdjustedType(T);
494  }
495 
496  void VisitArrayType(const ArrayType *T) {
497  AddQualType(T->getElementType());
498  ID.AddInteger(T->getSizeModifier());
499  VisitQualifiers(T->getIndexTypeQualifiers());
500  VisitType(T);
501  }
503  T->getSize().Profile(ID);
504  VisitArrayType(T);
505  }
506 
508  AddStmt(T->getSizeExpr());
509  VisitArrayType(T);
510  }
511 
513  VisitArrayType(T);
514  }
515 
517  AddStmt(T->getSizeExpr());
518  VisitArrayType(T);
519  }
520 
521  void VisitBuiltinType(const BuiltinType *T) {
522  ID.AddInteger(T->getKind());
523  VisitType(T);
524  }
525 
527  AddQualType(T->getReturnType());
528  T->getExtInfo().Profile(ID);
529  Hash.AddBoolean(T->isConst());
530  Hash.AddBoolean(T->isVolatile());
531  Hash.AddBoolean(T->isRestrict());
532  VisitType(T);
533  }
534 
536  VisitFunctionType(T);
537  }
538 
540  ID.AddInteger(T->getNumParams());
541  for (auto ParamType : T->getParamTypes())
542  AddQualType(ParamType);
543 
544  VisitFunctionType(T);
545  }
546 
547  void VisitTypedefType(const TypedefType *T) {
548  AddDecl(T->getDecl());
549  QualType UnderlyingType = T->getDecl()->getUnderlyingType();
550  VisitQualifiers(UnderlyingType.getQualifiers());
551  while (const TypedefType *Underlying =
552  dyn_cast<TypedefType>(UnderlyingType.getTypePtr())) {
553  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
554  }
555  AddType(UnderlyingType.getTypePtr());
556  VisitType(T);
557  }
558 
559  void VisitTagType(const TagType *T) {
560  AddDecl(T->getDecl());
561  VisitType(T);
562  }
563 
564  void VisitRecordType(const RecordType *T) { VisitTagType(T); }
565  void VisitEnumType(const EnumType *T) { VisitTagType(T); }
566 
568  ID.AddInteger(T->getKeyword());
569  VisitType(T);
570  };
571 
573  AddNestedNameSpecifier(T->getQualifier());
574  AddIdentifierInfo(T->getIdentifier());
575  VisitTypeWithKeyword(T);
576  }
577 
580  AddIdentifierInfo(T->getIdentifier());
581  AddNestedNameSpecifier(T->getQualifier());
582  ID.AddInteger(T->getNumArgs());
583  for (const auto &TA : T->template_arguments()) {
584  Hash.AddTemplateArgument(TA);
585  }
586  VisitTypeWithKeyword(T);
587  }
588 
590  AddNestedNameSpecifier(T->getQualifier());
591  AddQualType(T->getNamedType());
592  VisitTypeWithKeyword(T);
593  }
594 
596  ID.AddInteger(T->getNumArgs());
597  for (const auto &TA : T->template_arguments()) {
598  Hash.AddTemplateArgument(TA);
599  }
600  Hash.AddTemplateName(T->getTemplateName());
601  VisitType(T);
602  }
603 
605  ID.AddInteger(T->getDepth());
606  ID.AddInteger(T->getIndex());
607  Hash.AddBoolean(T->isParameterPack());
608  AddDecl(T->getDecl());
609  }
610 };
611 
612 void ODRHash::AddType(const Type *T) {
613  assert(T && "Expecting non-null pointer.");
614  auto Result = TypeMap.insert(std::make_pair(T, TypeMap.size()));
615  ID.AddInteger(Result.first->second);
616  // On first encounter of a Type pointer, process it. Every time afterwards,
617  // only the index value is needed.
618  if (!Result.second) {
619  return;
620  }
621 
622  ODRTypeVisitor(ID, *this).Visit(T);
623 }
624 
626  AddBoolean(T.isNull());
627  if (T.isNull())
628  return;
629  SplitQualType split = T.split();
630  ID.AddInteger(split.Quals.getAsOpaqueValue());
631  AddType(split.Ty);
632 }
633 
635  Bools.push_back(Value);
636 }
Kind getKind() const
Definition: Type.h:2105
void VisitTypeAliasDecl(const TypeAliasDecl *D)
Definition: ODRHash.cpp:332
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:4576
void VisitFunctionNoProtoType(const FunctionNoProtoType *T)
Definition: ODRHash.cpp:535
const Type * Ty
The locally-unqualified type.
Definition: Type.h:561
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1618
unsigned getDepth() const
Definition: Type.h:4024
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Definition: Type.h:616
void AddBoolean(bool value)
Definition: ODRHash.cpp:634
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2434
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes...
Stmt - This represents one statement.
Definition: Stmt.h:60
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:1537
void AddQualType(QualType T)
Definition: ODRHash.cpp:625
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:2923
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4734
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Definition: Decl.h:2770
Microsoft's '__super' 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:4642
The template argument is an expression, and we've not resolved it to one of the other forms yet...
Definition: TemplateBase.h:69
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:330
QualType getUnderlyingType() const
Definition: Decl.h:2727
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
void VisitCXXMethodDecl(const CXXMethodDecl *D)
Definition: ODRHash.cpp:315
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: Type.h:3046
void VisitDependentNameType(const DependentNameType *T)
Definition: ODRHash.cpp:572
bool hasDefinition() const
Definition: DeclCXX.h:702
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
Definition: Type.h:1303
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2497
const Expr * getInit() const
Definition: Decl.h:1146
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:51
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
A container of type source information.
Definition: Decl.h:62
unsigned getIndex() const
Definition: Type.h:4025
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:306
A template template parameter that has been substituted for some other template name.
Definition: TemplateName.h:201
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
Definition: Decl.h:2489
const llvm::APInt & getSize() const
Definition: Type.h:2568
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:40
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:758
void VisitFriendDecl(const FriendDecl *D)
Definition: ODRHash.cpp:336
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:46
AccessSpecifier getAccess() const
Definition: DeclBase.h:451
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:4028
bool isVolatile() const
Definition: DeclCXX.h:1945
A namespace, stored as a NamespaceDecl*.
QualType getOriginalType() const
Definition: Type.h:2288
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:50
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:2535
void AddTemplateArgument(TemplateArgument TA)
Definition: ODRHash.cpp:131
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1434
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4390
void AddIdentifierInfo(const IdentifierInfo *II)
Definition: ODRHash.cpp:220
The collection of all-type qualifiers we support.
Definition: Type.h:118
void clear()
Definition: ODRHash.cpp:163
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:108
void VisitDecayedType(const DecayedType *T)
Definition: ODRHash.cpp:490
QualType getPointeeType() const
Definition: Type.h:6130
unsigned getNumParams() const
Definition: Type.h:3338
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:4669
static bool isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Record)
Definition: ODRHash.cpp:349
bool isConst() const
Definition: DeclCXX.h:1944
One of these records is kept for each identifier that is lexed.
void VisitVariableArrayType(const VariableArrayType *T)
Definition: ODRHash.cpp:516
StringLiteral * getMessage()
Definition: DeclCXX.h:3599
void VisitNamedDecl(const NamedDecl *D)
Definition: ODRHash.cpp:243
Expr * getSizeExpr() const
Definition: Type.h:2664
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3343
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:57
QualType getReturnType() const
Definition: Decl.h:2106
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2366
bool isKeywordSelector() const
An operation on a type.
Definition: TypeVisitor.h:65
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:1898
NameKind getKind() const
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:4662
void AddTemplateParameterList(const TemplateParameterList *TPL)
Definition: ODRHash.cpp:161
void VisitRecordType(const RecordType *T)
Definition: ODRHash.cpp:564
unsigned getAsOpaqueValue() const
Definition: Type.h:233
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:103
void VisitIncompleteArrayType(const IncompleteArrayType *T)
Definition: ODRHash.cpp:512
bool isNull() const
Determine whether this is the empty selector.
void Visit(const Decl *D)
Definition: ODRHash.cpp:238
A qualified template name, where the qualification is kept to describe the source code as written...
Definition: TemplateName.h:195
void AddDecl(const Decl *D)
Definition: ODRHash.cpp:406
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:537
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4382
#define CHAR_BIT
Definition: limits.h:79
QualType getReturnType() const
Definition: Type.h:3065
void VisitDependentSizedArrayType(const DependentSizedArrayType *T)
Definition: ODRHash.cpp:507
void VisitTagType(const TagType *T)
Definition: ODRHash.cpp:559
#define remainder(__x, __y)
Definition: tgmath.h:1106
void AddStmt(Stmt *S)
Definition: ODRHash.cpp:434
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:4603
TypeClass getTypeClass() const
Definition: Type.h:1555
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
Definition: Decl.h:987
void VisitTypedefDecl(const TypedefDecl *D)
Definition: ODRHash.cpp:328
detail::InMemoryDirectory::const_iterator I
QualType getType() const
Definition: Decl.h:589
void VisitFunctionDecl(const FunctionDecl *D)
Definition: ODRHash.cpp:297
void AddTemplateName(TemplateName Name)
Definition: ODRHash.cpp:113
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
Definition: Type.h:3095
void VisitEnumType(const EnumType *T)
Definition: ODRHash.cpp:565
ExtInfo getExtInfo() const
Definition: Type.h:3074
ODRDeclVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
Definition: ODRHash.cpp:210
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2790
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3129
ODRTypeVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
Definition: ODRHash.cpp:431
void VisitFunctionType(const FunctionType *T)
Definition: ODRHash.cpp:526
void VisitFunctionProtoType(const FunctionProtoType *T)
Definition: ODRHash.cpp:539
A dependent template name that has not been resolved to a template (or set of templates).
Definition: TemplateName.h:198
void Visit(const Type *T)
Definition: ODRHash.cpp:477
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2136
bool isUnarySelector() const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:2700
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:5497
void VisitDependentTemplateSpecializationType(const DependentTemplateSpecializationType *T)
Definition: ODRHash.cpp:578
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:580
StringRef getName() const
Return the actual identifier string.
unsigned getNumArgs() const
bool isDeletedAsWritten() const
Definition: Decl.h:1980
bool isEmpty() const
Evaluates true when this declaration name is empty.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:54
Expr * getBitWidth() const
Definition: Decl.h:2448
void AddStmt(const Stmt *S)
Definition: ODRHash.cpp:213
void AddDeclarationName(DeclarationName Name)
Definition: ODRHash.cpp:35
Kind getKind() const
Definition: DeclBase.h:410
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:4606
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:213
DeclContext * getDeclContext()
Definition: DeclBase.h:416
Represents a C++ template name within the type system.
Definition: TemplateName.h:176
A namespace alias, stored as a NamespaceAliasDecl*.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:559
Qualifiers Quals
The local qualifiers.
Definition: Type.h:564
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1294
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.
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:266
A helper class for Type nodes having an ElaboratedTypeKeyword.
Definition: Type.h:4525
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:258
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
The result type of a method or function.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:1893
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const IdentifierInfo * getIdentifier() const
Definition: Type.h:4726
A template template parameter pack that has been substituted for a template template argument pack...
Definition: TemplateName.h:205
void AddDecl(const Decl *D)
Definition: ODRHash.cpp:231
Kind
void AddType(const Type *T)
Definition: ODRHash.cpp:452
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
Definition: ODRHash.cpp:459
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:3810
void VisitArrayType(const ArrayType *T)
Definition: ODRHash.cpp:496
void AddType(const Type *T)
Definition: ODRHash.cpp:612
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
const std::string ID
void AddIdentifierInfo(const IdentifierInfo *II)
Definition: ODRHash.cpp:30
bool isRestrict() const
Definition: Type.h:3077
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1903
void VisitTypedefNameDecl(const TypedefNameDecl *D)
Definition: ODRHash.cpp:322
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2066
void VisitStaticAssertDecl(const StaticAssertDecl *D)
Definition: ODRHash.cpp:276
void VisitTypedefType(const TypedefType *T)
Definition: ODRHash.cpp:547
TypedefNameDecl * getDecl() const
Definition: Type.h:3593
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
void VisitElaboratedType(const ElaboratedType *T)
Definition: ODRHash.cpp:589
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
Definition: ODRHash.cpp:84
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3576
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:4396
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2140
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:70
void AddSubDecl(const Decl *D)
Definition: ODRHash.cpp:370
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2308
Expr * getSizeExpr() const
Definition: Type.h:2720
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2682
Represents a template argument.
Definition: TemplateBase.h:40
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
Definition: Type.h:2272
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:235
void AddIdentifierInfo(const IdentifierInfo *II)
Definition: ODRHash.cpp:466
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1215
StringRef Name
Definition: USRFinder.cpp:123
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:63
void VisitQualifiers(Qualifiers Quals)
Definition: ODRHash.cpp:473
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
bool isParameterPack() const
Definition: Type.h:4026
void AddCXXRecordDecl(const CXXRecordDecl *Record)
Definition: ODRHash.cpp:377
void VisitAdjustedType(const AdjustedType *T)
Definition: ODRHash.cpp:484
DeclarationName - The name of a declaration.
void VisitValueDecl(const ValueDecl *D)
Definition: ODRHash.cpp:248
size_t param_size() const
Definition: Decl.h:2081
void VisitVarDecl(const VarDecl *D)
Definition: ODRHash.cpp:255
A type that was preceded by the 'template' keyword, stored as a Type*.
void VisitConstantArrayType(const ConstantArrayType *T)
Definition: ODRHash.cpp:502
void VisitFieldDecl(const FieldDecl *D)
Definition: ODRHash.cpp:283
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3784
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition: DeclFriend.h:121
void VisitTemplateTypeParmType(const TemplateTypeParmType *T)
Definition: ODRHash.cpp:604
void AddDecl(Decl *D)
Definition: ODRHash.cpp:441
void AddQualType(QualType T)
Definition: ODRHash.cpp:227
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:4738
unsigned CalculateHash()
Definition: ODRHash.cpp:170
The template argument is a type.
Definition: TemplateBase.h:48
NestedNameSpecifier * getQualifier() const
Definition: Type.h:4725
The template argument is actually a parameter pack.
Definition: TemplateBase.h:72
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:336
Represents a C++ struct/union/class.
Definition: DeclCXX.h:267
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4695
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:60
Represents a C array with an unspecified size.
Definition: Type.h:2603
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2532
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:4537
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1299
This class is used for builtin types like 'int'.
Definition: Type.h:2084
QualType getAdjustedType() const
Definition: Type.h:2289
QualType getDecayedType() const
Definition: Type.h:2316
TagDecl * getDecl() const
Definition: Type.cpp:2986
void AddStmt(const Stmt *S)
Definition: ODRHash.cpp:25
void VisitType(const Type *T)
Definition: ODRHash.cpp:482
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4297
void VisitBuiltinType(const BuiltinType *T)
Definition: ODRHash.cpp:521
QualType getElementType() const
Definition: Type.h:2531
void VisitTemplateSpecializationType(const TemplateSpecializationType *T)
Definition: ODRHash.cpp:595
A set of overloaded template declarations.
Definition: TemplateName.h:192
bool isVolatile() const
Definition: Type.h:3076
void AddQualType(QualType T)
Definition: ODRHash.cpp:448
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2648
void VisitTypeWithKeyword(const TypeWithKeyword *T)
Definition: ODRHash.cpp:567
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:683
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:74
The global specifier '::'. There is no stored value.
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2553
void VisitParmVarDecl(const ParmVarDecl *D)
Definition: ODRHash.cpp:266
A single template declaration.
Definition: TemplateName.h:190
void VisitAccessSpecDecl(const AccessSpecDecl *D)
Definition: ODRHash.cpp:271
void ProcessODRHash(llvm::FoldingSetNodeID &ID, ODRHash &Hash) const
Calculate a unique representation for a statement that is stable across compiler invocations.
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2431
bool isConst() const
Definition: Type.h:3075
bool hasInit() const
Definition: Decl.cpp:2101