clang 8.0.0

Classes | Namespaces | Macros | Functions
ASTReaderDecl.cpp File Reference
`#include "ASTCommon.h"`
`#include "ASTReaderInternals.h"`
`#include "clang/AST/ASTContext.h"`
`#include "clang/AST/Attr.h"`
`#include "clang/AST/AttrIterator.h"`
`#include "clang/AST/Decl.h"`
`#include "clang/AST/DeclBase.h"`
`#include "clang/AST/DeclCXX.h"`
`#include "clang/AST/DeclFriend.h"`
`#include "clang/AST/DeclObjC.h"`
`#include "clang/AST/DeclOpenMP.h"`
`#include "clang/AST/DeclTemplate.h"`
`#include "clang/AST/DeclVisitor.h"`
`#include "clang/AST/DeclarationName.h"`
`#include "clang/AST/Expr.h"`
`#include "clang/AST/ExternalASTSource.h"`
`#include "clang/AST/LambdaCapture.h"`
`#include "clang/AST/NestedNameSpecifier.h"`
`#include "clang/AST/OpenMPClause.h"`
`#include "clang/AST/Redeclarable.h"`
`#include "clang/AST/Stmt.h"`
`#include "clang/AST/TemplateBase.h"`
`#include "clang/AST/Type.h"`
`#include "clang/AST/UnresolvedSet.h"`
`#include "clang/Basic/AttrKinds.h"`
`#include "clang/Basic/ExceptionSpecificationType.h"`
`#include "clang/Basic/IdentifierTable.h"`
`#include "clang/Basic/LLVM.h"`
`#include "clang/Basic/Lambda.h"`
`#include "clang/Basic/LangOptions.h"`
`#include "clang/Basic/Linkage.h"`
`#include "clang/Basic/Module.h"`
`#include "clang/Basic/PragmaKinds.h"`
`#include "clang/Basic/SourceLocation.h"`
`#include "clang/Basic/Specifiers.h"`
`#include "clang/Sema/IdentifierResolver.h"`
`#include "clang/Serialization/ASTBitCodes.h"`
`#include "clang/Serialization/ASTReader.h"`
`#include "clang/Serialization/ContinuousRangeMap.h"`
`#include "clang/Serialization/Module.h"`
`#include "llvm/ADT/DenseMap.h"`
`#include "llvm/ADT/FoldingSet.h"`
`#include "llvm/ADT/STLExtras.h"`
`#include "llvm/ADT/SmallPtrSet.h"`
`#include "llvm/ADT/SmallVector.h"`
`#include "llvm/ADT/iterator_range.h"`
`#include "llvm/Bitcode/BitstreamReader.h"`
`#include "llvm/Support/Casting.h"`
`#include "llvm/Support/ErrorHandling.h"`
`#include "llvm/Support/SaveAndRestore.h"`
`#include <algorithm>`
`#include <cassert>`
`#include <cstdint>`
`#include <cstring>`
`#include <string>`
`#include <utility>`
`#include "clang/Serialization/AttrPCHRead.inc"`
`#include "clang/AST/DeclNodes.inc"`

Go to the source code of this file.

## Classes
class | clang::ASTDeclReader

## Namespaces
| clang
| Dataflow Directional Tag Classes.

## Macros
#define | OR_FIELD(Field) DD.Field |= MergeDD.Field;
#define | MATCH_FIELD(Field)
#define | ABSTRACT_DECL(TYPE)
#define | DECL(TYPE, BASE)
#define | ABSTRACT_DECL(TYPE)
#define | DECL(TYPE, BASE)
#define | ABSTRACT_DECL(TYPE)
#define | DECL(TYPE, BASE)
#define | ABSTRACT_DECL(TYPE)
#define | DECL(TYPE, BASE)

## Functions
template<typename DeclT >
static llvm::iterator_range< MergedRedeclIterator< DeclT > > | merged_redecls (DeclT *D)
template<typename T >
static T | assert_cast (T t)
| "Cast" to type T, asserting if we don't have an implicit conversion. More...
template<typename T >
static T | assert_cast (...)
static bool | allowODRLikeMergeInC (NamedDecl *ND)
| ODR-like semantics for C/ObjC allow us to merge tag types and a structural check in Sema guarantees the types can be merged (see C11 6.2.7/1 or C89 6.1.2.6/1). More...
static bool | isConsumerInterestedIn (ASTContext &Ctx, Decl *D, bool HasBody)
| Determine whether the consumer will be interested in seeing this declaration (via HandleTopLevelDecl). More...
static bool | isSameTemplateParameterList (const TemplateParameterList *X, const TemplateParameterList *Y)
| Determine whether two template parameter lists are similar enough that they may be used in declarations of the same template. More...
static bool | isSameTemplateParameter (const NamedDecl *X, const NamedDecl *Y)
| Determine whether two template parameters are similar enough that they may be used in declarations of the same template. More...
static NamespaceDecl * | getNamespace (const NestedNameSpecifier *X)
static bool | isSameQualifier (const NestedNameSpecifier *X, const NestedNameSpecifier *Y)
static bool | hasSameOverloadableAttrs (const FunctionDecl *A, const FunctionDecl *B)
| Determine whether the attributes we can overload on are identical for A and B. More...
static bool | isSameEntity (NamedDecl *X, NamedDecl *Y)
| Determine whether the two declarations refer to the same entity. More...
static NamedDecl * | getDeclForMerging (NamedDecl *Found, bool IsTypedefNameForLinkage)
| Find the declaration that should be merged into, given the declaration found by name lookup. More...
static bool | clang::isUndeducedReturnType (QualType T)
template<typename ParmDecl >
static bool | inheritDefaultTemplateArgument (ASTContext &Context, ParmDecl *From, Decl *ToD)
| Inherit the default template argument from `From` to `To`. More...
static void | inheritDefaultTemplateArguments (ASTContext &Context, TemplateDecl *From, TemplateDecl *To)
template<typename DeclT , typename Fn >
static void | forAllLaterRedecls (DeclT *D, Fn F)

## Macro Definition Documentation

## ◆ ABSTRACT_DECL [1/4]

#define ABSTRACT_DECL | ( |  | TYPE | ) |

## ◆ ABSTRACT_DECL [2/4]

#define ABSTRACT_DECL | ( |  | TYPE | ) |

## ◆ ABSTRACT_DECL [3/4]

#define ABSTRACT_DECL | ( |  | TYPE | ) |

## ◆ ABSTRACT_DECL [4/4]

#define ABSTRACT_DECL | ( |  | TYPE | ) |

## ◆ DECL [1/4]

#define DECL | ( |  | TYPE,
|  |  | BASE
| ) |  |

Value:
case Decl::TYPE: \
return getMostRecentDeclImpl(cast<TYPE##Decl>(D));
TYPE
#define TYPE(DERIVED, BASE)
Definition: ASTFwd.h:27

## ◆ DECL [2/4]

#define DECL | ( |  | TYPE,
|  |  | BASE
| ) |  |

Value:
case Decl::TYPE: \
attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \
break;
TYPE
#define TYPE(DERIVED, BASE)
Definition: ASTFwd.h:27
Previous
StateNode * Previous
Definition: UnwrappedLineFormatter.cpp:879

## ◆ DECL [3/4]

#define DECL | ( |  | TYPE,
|  |  | BASE
| ) |  |

Value:
case Decl::TYPE: \
attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \
break;
TYPE
#define TYPE(DERIVED, BASE)
Definition: ASTFwd.h:27

## ◆ DECL [4/4]

#define DECL | ( |  | TYPE,
|  |  | BASE
| ) |  |

Value:
case Decl::TYPE: \
ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \
break;
TYPE
#define TYPE(DERIVED, BASE)
Definition: ASTFwd.h:27

## ◆ MATCH_FIELD

#define MATCH_FIELD | ( |  | Field | ) |

Value:
DetectedOdrViolation |= DD.Field != MergeDD.Field; \
OR_FIELD(Field)

Referenced by clang::ASTDeclReader::VisitUnresolvedUsingTypenameDecl().

## ◆ OR_FIELD

#define OR_FIELD | ( |  | Field | ) | DD.Field |= MergeDD.Field;

Referenced by clang::ASTDeclReader::VisitUnresolvedUsingTypenameDecl().

## Function Documentation

## ◆ allowODRLikeMergeInC()

static bool allowODRLikeMergeInC | ( | NamedDecl * | ND | ) |
| static

ODR-like semantics for C/ObjC allow us to merge tag types and a structural check in Sema guarantees the types can be merged (see C11 6.2.7/1 or C89 6.1.2.6/1).

Although most merging is done in Sema, we need to guarantee that some types are mergeable during deserialization, otherwise name lookup fails. This is the case for EnumConstantDecl.

Definition at line 2591 of file ASTReaderDecl.cpp.

Referenced by clang::ASTDeclReader::mergeMergeable().

## ◆ assert_cast() [1/2]

template<typename T >

static T assert_cast | ( | T | t | ) |
| static

"Cast" to type T, asserting if we don't have an implicit conversion.

We use this to put code in a template that will only be valid for certain instantiations.

Definition at line 2499 of file ASTReaderDecl.cpp.

## ◆ assert_cast() [2/2]

template<typename T >

static T assert_cast | ( |  | ... | ) |
| static

Definition at line 2500 of file ASTReaderDecl.cpp.

## ◆ forAllLaterRedecls()

template<typename DeclT , typename Fn >

static void forAllLaterRedecls | ( | DeclT * | D,
|  | Fn | F
| ) |  |
| static

Definition at line 4177 of file ASTReaderDecl.cpp.

Referenced by clang::ASTDeclReader::UpdateDecl().

## ◆ getDeclForMerging()

static NamedDecl* getDeclForMerging | ( | NamedDecl * | Found,
|  | bool | IsTypedefNameForLinkage
| ) |  |
| static

Find the declaration that should be merged into, given the declaration found by name lookup.

If we're merging an anonymous declaration within a typedef, we need a matching typedef, and we merge with the type inside it.

Definition at line 3210 of file ASTReaderDecl.cpp.

References clang::Decl::isFromASTFile(), and merged_redecls().

## ◆ getNamespace()

static NamespaceDecl* getNamespace | ( | const NestedNameSpecifier * | X | ) |
| static

Definition at line 2847 of file ASTReaderDecl.cpp.

References clang::NestedNameSpecifier::getAsNamespace(), and clang::NestedNameSpecifier::getAsNamespaceAlias().

Referenced by clang::NamespaceAliasDecl::getNamespace(), and isSameQualifier().

## ◆ hasSameOverloadableAttrs()

static bool hasSameOverloadableAttrs | ( | const FunctionDecl * | A,
|  | const FunctionDecl * | B
| ) |  |
| static

Determine whether the attributes we can overload on are identical for A and B.

Will ignore any overloadable attrs represented in the type of A and B.

Definition at line 2910 of file ASTReaderDecl.cpp.

References clang::Decl::getASTContext(), and clang::Decl::specific_attrs().

Referenced by isSameEntity().

## ◆ inheritDefaultTemplateArgument()

template<typename ParmDecl >

static bool inheritDefaultTemplateArgument | ( | ASTContext & | Context,
|  | ParmDecl * | From,
|  | Decl * | ToD
| ) |  |
| static

Inherit the default template argument from `From` to `To`.

Returns `false` if there is no default template for `From`.

Definition at line 3513 of file ASTReaderDecl.cpp.

## ◆ inheritDefaultTemplateArguments()

static void inheritDefaultTemplateArguments | ( | ASTContext & | Context,
|  | TemplateDecl * | From,
|  | TemplateDecl * | To
| ) |  |
| static

Definition at line 3522 of file ASTReaderDecl.cpp.

Referenced by clang::ASTDeclReader::attachPreviousDecl().

## ◆ isConsumerInterestedIn()

static bool isConsumerInterestedIn | ( | ASTContext & | Ctx,
|  | Decl * | D,
|  | bool | HasBody
| ) |  |
| static

Determine whether the consumer will be interested in seeing this declaration (via HandleTopLevelDecl).

This routine should return true for anything that might affect code generation, e.g., inline function definitions, Objective-C declarations with metadata, etc.

Definition at line 2760 of file ASTReaderDecl.cpp.

References clang::serialization::DeclOffset::BitOffset, clang::ASTContext::DeclMustBeEmitted(), clang::VarDecl::Definition, clang::ExternalASTSource::EK_Never, clang::Decl::getASTContext(), clang::Decl::getDeclContext(), clang::ASTContext::getExternalSource(), clang::Decl::getImportedOwningModule(), clang::serialization::DeclOffset::getLocation(), clang::serialization::ModuleFile::GlobalBitOffset, clang::DeclContext::isFunctionOrMethod(), isSameTemplateParameterList(), clang::Module::ModuleMapModule, clang::serialization::NUM_PREDEF_DECL_IDS, and X.

## ◆ isSameEntity()

static bool isSameEntity | ( | NamedDecl * | X,
|  | NamedDecl * | Y
| ) |  |
| static

Determine whether the two declarations refer to the same entity.

Definition at line 2942 of file ASTReaderDecl.cpp.

References clang::declaresSameEntity(), clang::Type::getAs(), clang::ASTContext::getAsArrayType(), clang::Decl::getASTContext(), clang::ASTReader::getContext(), clang::Decl::getDeclContext(), clang::NamedDecl::getDeclName(), clang::ArrayType::getElementType(), clang::FunctionProtoType::getExceptionSpecType(), clang::Decl::getKind(), clang::ASTContext::getLangOpts(), clang::DeclContext::getRedeclContext(), clang::ASTContext::hasSameFunctionTypeIgnoringExceptionSpec(), hasSameOverloadableAttrs(), clang::ASTContext::hasSameType(), clang::Type::isIncompleteArrayType(), isSameQualifier(), isSameTemplateParameterList(), clang::isUnresolvedExceptionSpec(), clang::TTK_Class, clang::TTK_Interface, clang::TTK_Struct, and X.

## ◆ isSameQualifier()

static bool isSameQualifier | ( | const NestedNameSpecifier * | X,
|  | const NestedNameSpecifier * | Y
| ) |  |
| static

Definition at line 2855 of file ASTReaderDecl.cpp.

References clang::NestedNameSpecifier::getAsIdentifier(), clang::NestedNameSpecifier::getAsType(), clang::Type::getCanonicalTypeInternal(), clang::NestedNameSpecifier::getKind(), getNamespace(), clang::NestedNameSpecifier::getPrefix(), clang::NestedNameSpecifier::Global, clang::NestedNameSpecifier::Identifier, clang::NestedNameSpecifier::Namespace, clang::NestedNameSpecifier::NamespaceAlias, clang::NestedNameSpecifier::Super, clang::NestedNameSpecifier::TypeSpec, and clang::NestedNameSpecifier::TypeSpecWithTemplate.

Referenced by isSameEntity().

## ◆ isSameTemplateParameter()

static bool isSameTemplateParameter | ( | const NamedDecl * | X,
|  | const NamedDecl * | Y
| ) |  |
| static

Determine whether two template parameters are similar enough that they may be used in declarations of the same template.

Definition at line 2824 of file ASTReaderDecl.cpp.

References clang::Decl::getKind(), isSameTemplateParameterList(), and X.

Referenced by isSameTemplateParameterList().

## ◆ isSameTemplateParameterList()

static bool isSameTemplateParameterList | ( | const TemplateParameterList * | X,
|  | const TemplateParameterList * | Y
| ) |  |
| static

Determine whether two template parameter lists are similar enough that they may be used in declarations of the same template.

Definition at line 2896 of file ASTReaderDecl.cpp.

References clang::TemplateParameterList::getParam(), isSameTemplateParameter(), and clang::TemplateParameterList::size().

Referenced by isConsumerInterestedIn(), isSameEntity(), and isSameTemplateParameter().

## ◆ merged_redecls()

template<typename DeclT >

static llvm::iterator_range<MergedRedeclIterator<DeclT> > merged_redecls | ( | DeclT * | D | ) |
| static

Definition at line 497 of file ASTReaderDecl.cpp.

Referenced by getDeclForMerging(), and clang::ASTDeclReader::VisitEnumDecl().