clang  3.9.0
Enumerations | Functions | Variables
SemaDecl.cpp File Reference
#include "clang/Sema/SemaInternal.h"
#include "TypeLocBuilder.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/CommentDiagnostic.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/StmtCXX.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/PartialDiagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/ModuleLoader.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/CXXFieldCollector.h"
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/DelayedDiagnostic.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/Template.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Triple.h"
#include <algorithm>
#include <cstring>
#include <functional>
Include dependency graph for SemaDecl.cpp:

Go to the source code of this file.

Enumerations

enum  UnqualifiedTypeNameLookupResult
 
enum  ShadowedDeclKind { SDK_Local, SDK_Global, SDK_StaticMember, SDK_Field }
 Enum describing the select options in diag::warn_decl_shadow. More...
 
enum  OverrideErrorKind
 
enum  OpenCLParamType {
  ValidKernelParam, PtrPtrKernelParam, PtrKernelParam, PrivatePtrKernelParam,
  InvalidKernelParam, RecordKernelParam
}
 

Functions

static
UnqualifiedTypeNameLookupResult 
lookupUnqualifiedTypeNameInBase (Sema &S, const IdentifierInfo &II, SourceLocation NameLoc, const CXXRecordDecl *RD)
 Tries to perform unqualified lookup of the type decls in bases for dependent class. More...
 
static ParsedType recoverFromTypeInKnownDependentBase (Sema &S, const IdentifierInfo &II, SourceLocation NameLoc)
 
static NestedNameSpecifiersynthesizeCurrentNestedNameSpecifier (ASTContext &Context, DeclContext *DC)
 
static const CXXRecordDeclfindRecordWithDependentBasesOfEnclosingMethod (const DeclContext *DC)
 Find the parent class with dependent bases of the innermost enclosing method context. More...
 
static bool isResultTypeOrTemplate (LookupResult &R, const Token &NextToken)
 Determine whether the given result set contains either a type name or. More...
 
static bool isTagTypeWithMissingTag (Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
 
static ParsedType buildNestedType (Sema &S, CXXScopeSpec &SS, QualType T, SourceLocation NameLoc)
 Build a ParsedType for a simple-type-specifier with a nested-name-specifier. More...
 
static bool AllowOverloadingOfFunction (LookupResult &Previous, ASTContext &Context)
 Determine whether we allow overloading of the function PrevDecl with another declaration. More...
 
static bool isOutOfScopePreviousDeclaration (NamedDecl *PrevDecl, DeclContext *DC, ASTContext &Context)
 Determines whether the given declaration is an out-of-scope previous declaration. More...
 
static bool isUsingDecl (NamedDecl *D)
 
static void RemoveUsingDecls (LookupResult &R)
 Removes using shadow declarations from the lookup results. More...
 
static bool IsDisallowedCopyOrAssign (const CXXMethodDecl *D)
 Check for this common pattern: More...
 
static bool isMainFileLoc (const Sema &S, SourceLocation Loc)
 
static bool ShouldDiagnoseUnusedDecl (const NamedDecl *D)
 
static void GenerateFixForUnusedDecl (const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
 
static void CheckPoppedLabel (LabelDecl *L, Sema &S)
 
static void LookupPredefedObjCSuperType (Sema &ThisSema, Scope *S, IdentifierInfo *II)
 Looks up the declaration of "struct objc_super" and saves it for later use in building builtin declaration of objc_msgSendSuper and objc_msgSendSuper_stret. More...
 
static StringRef getHeaderName (ASTContext::GetBuiltinTypeError Error)
 
static void filterNonConflictingPreviousTypedefDecls (Sema &S, TypedefNameDecl *Decl, LookupResult &Previous)
 Typedef declarations don't have linkage, but they still denote the same entity if their types are the same. More...
 
static bool DeclHasAttr (const Decl *D, const Attr *A)
 DeclhasAttr - returns true if decl Declaration already has the target attribute. More...
 
static bool isAttributeTargetADefinition (Decl *D)
 
static bool mergeAlignedAttrs (Sema &S, NamedDecl *New, Decl *Old)
 Merge alignment attributes from Old to New, taking into account the special semantics of C11's _Alignas specifier and C++11's alignas attribute. More...
 
static bool mergeDeclAttribute (Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
 
static const DeclgetDefinition (const Decl *D)
 
static bool hasAttribute (const Decl *D, attr::Kind Kind)
 
static void checkNewAttributesAfterDef (Sema &S, Decl *New, const Decl *Old)
 checkNewAttributesAfterDef - If we already have a definition, check that there are no new attributes in this declaration. More...
 
static void mergeParamDeclAttributes (ParmVarDecl *newDecl, const ParmVarDecl *oldDecl, Sema &S)
 mergeParamDeclAttributes - Copy attributes from the old parameter to the new one. More...
 
static void mergeParamDeclTypes (ParmVarDecl *NewParam, const ParmVarDecl *OldParam, Sema &S)
 
template<typename T >
static std::pair< diag::kind,
SourceLocation
getNoteDiagForInvalidRedeclaration (const T *Old, const T *New)
 
static bool canRedefineFunction (const FunctionDecl *FD, const LangOptions &LangOpts)
 canRedefineFunction - checks if a function can be redefined. More...
 
template<typename T >
static bool haveIncompatibleLanguageLinkages (const T *Old, const T *New)
 
template<typename T >
static bool isExternC (T *D)
 
static bool isExternC (VarTemplateDecl *)
 
template<typename ExpectedDecl >
static bool checkUsingShadowRedecl (Sema &S, UsingShadowDecl *OldS, ExpectedDecl *New)
 Check whether a redeclaration of an entity introduced by a using-declaration is valid, given that we know it's not an overload (nor a hidden tag declaration). More...
 
static bool hasIdenticalPassObjectSizeAttrs (const FunctionDecl *A, const FunctionDecl *B)
 
static void diagnoseVarDeclTypeMismatch (Sema &S, VarDecl *New, VarDecl *Old)
 
static bool mergeTypeWithPrevious (Sema &S, VarDecl *NewVD, VarDecl *OldVD, LookupResult &Previous)
 
static unsigned getMSManglingNumber (const LangOptions &LO, Scope *S)
 
static unsigned GetDiagnosticTypeSpecifierID (DeclSpec::TST T)
 
static bool CheckAnonMemberRedeclaration (Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, bool IsUnion)
 We are trying to inject an anonymous member into the given scope; check if there's an existing declaration that can't be overloaded. More...
 
static bool InjectAnonymousStructOrUnionMembers (Sema &SemaRef, Scope *S, DeclContext *Owner, RecordDecl *AnonRecord, AccessSpecifier AS, SmallVectorImpl< NamedDecl * > &Chaining)
 InjectAnonymousStructOrUnionMembers - Inject the members of the anonymous struct or union AnonRecord into the owning context Owner and scope S. More...
 
static StorageClass StorageClassSpecToVarDeclStorageClass (const DeclSpec &DS)
 StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to a VarDecl::StorageClass. More...
 
static SourceLocation findDefaultInitializer (const CXXRecordDecl *Record)
 
static void checkDuplicateDefaultInit (Sema &S, CXXRecordDecl *Parent, SourceLocation DefaultInitLoc)
 
static void checkDuplicateDefaultInit (Sema &S, CXXRecordDecl *Parent, CXXRecordDecl *AnonUnion)
 
static QualType getCoreType (QualType Ty)
 
static bool hasSimilarParameters (ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl< unsigned > &Params)
 hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" matching parameters. More...
 
static bool RebuildDeclaratorInCurrentInstantiation (Sema &S, Declarator &D, DeclarationName Name)
 NeedsRebuildingInCurrentInstantiation - Checks whether the given declarator needs to be rebuilt in the current instantiation. More...
 
static QualType TryToFixInvalidVariablyModifiedType (QualType T, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
 Helper method to turn variable array types into constant array types in certain situations which would otherwise be errors (for GCC compatibility). More...
 
static void FixInvalidVariablyModifiedTypeLoc (TypeLoc SrcTL, TypeLoc DstTL)
 
static TypeSourceInfoTryToFixInvalidVariablyModifiedTypeSourceInfo (TypeSourceInfo *TInfo, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
 Helper method to turn variable array types into constant array types in certain situations which would otherwise be errors (for GCC compatibility). More...
 
static void SetNestedNameSpecifier (DeclaratorDecl *DD, Declarator &D)
 
static void checkAttributesAfterMerging (Sema &S, NamedDecl &ND)
 
static void checkDLLAttributeRedeclaration (Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition)
 
static bool isFunctionDefinitionDiscarded (Sema &S, FunctionDecl *FD)
 Given that we are within the definition of the given function, will that definition behave like C99's 'inline', where the definition is discarded except for optimization purposes? More...
 
template<typename T >
static bool isIncompleteDeclExternC (Sema &S, const T *D)
 Determine whether a variable is extern "C" prior to attaching an initializer. More...
 
static bool shouldConsiderLinkage (const VarDecl *VD)
 
static bool shouldConsiderLinkage (const FunctionDecl *FD)
 
static bool hasParsedAttr (Scope *S, const AttributeList *AttrList, AttributeList::Kind Kind)
 
static bool hasParsedAttr (Scope *S, const Declarator &PD, AttributeList::Kind Kind)
 
static bool isDeclExternC (const Decl *D)
 Returns true if given declaration has external C language linkage. More...
 
static ShadowedDeclKind computeShadowedDeclKind (const NamedDecl *ShadowedDecl, const DeclContext *OldDC)
 Determine what kind of declaration we're shadowing. More...
 
template<typename T >
static bool checkGlobalOrExternCConflict (Sema &S, const T *ND, bool IsGlobal, LookupResult &Previous)
 Check for conflict between this global or extern "C" declaration and previous global or extern "C" declarations. More...
 
template<typename T >
static bool checkForConflictWithNonVisibleExternC (Sema &S, const T *ND, LookupResult &Previous)
 Apply special rules for handling extern "C" declarations. More...
 
static void ReportOverrides (Sema &S, unsigned DiagID, const CXXMethodDecl *MD, OverrideErrorKind OEK=OEK_All)
 Report an error regarding overriding, along with any relevant overriden methods. More...
 
static NamedDeclDiagnoseInvalidRedeclaration (Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs, bool IsLocalFriend, Scope *S)
 Generate diagnostics for an invalid function redeclaration. More...
 
static StorageClass getFunctionStorageClass (Sema &SemaRef, Declarator &D)
 
static FunctionDeclCreateNewFunctionDecl (Sema &SemaRef, Declarator &D, DeclContext *DC, QualType &R, TypeSourceInfo *TInfo, StorageClass SC, bool &IsVirtualOkay)
 
static OpenCLParamType getOpenCLKernelParameterType (QualType PT)
 
static void checkIsValidOpenCLKernelParameter (Sema &S, Declarator &D, ParmVarDecl *Param, llvm::SmallPtrSetImpl< const Type * > &ValidTypes)
 
static bool hasDependentAlignment (VarDecl *VD)
 Determines if a variable's alignment is dependent. More...
 
static bool ShouldWarnAboutMissingPrototype (const FunctionDecl *FD, const FunctionDecl *&PossibleZeroParamPrototype)
 
static void RebuildLambdaScopeInfo (CXXMethodDecl *CallOperator, Sema &S)
 
static unsigned getRedeclDiagFromTagKind (TagTypeKind Tag)
 Get diagnostic select index for tag kind for redeclaration diagnostic message. More...
 
static bool isClassCompatTagKind (TagTypeKind Tag)
 Determine if tag kind is a class-key compatible with class for redeclaration (class, struct, or __interface). More...
 
***static FixItHint createFriendTagNNSFixIt (Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
 
static bool isAcceptableTagRedeclContext (Sema &S, DeclContext *OldDC, DeclContext *NewDC)
 Determine whether a tag originally declared in context OldDC can be redeclared with an unqualfied name in NewDC (assuming name lookup found a declaration in OldDC as a previous decl, perhaps through a using-declaration). More...
 
static DeclContextgetTagInjectionContext (DeclContext *DC)
 Find the DeclContext in which a tag is implicitly declared if we see an elaborated type specifier in the specified context, and lookup finds nothing. More...
 
static ScopegetTagInjectionScope (Scope *S, const LangOptions &LangOpts)
 Find the Scope in which a tag is implicitly declared if we see an elaborated type specifier in the specified context, and lookup finds nothing. More...
 
static ObjCIvarDecl::AccessControl TranslateIvarVisibility (tok::ObjCKeywordKind ivarVisibility)
 TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value. More...
 
static bool isRepresentableIntegerValue (ASTContext &Context, llvm::APSInt &Value, QualType T)
 Determine whether the given integral value is representable within the given type T. More...
 
static QualType getNextLargerIntegralType (ASTContext &Context, QualType T)
 
static bool ValidDuplicateEnum (EnumConstantDecl *ECD, EnumDecl *Enum)
 
static void CheckForDuplicateEnumValues (Sema &S, ArrayRef< Decl * > Elements, EnumDecl *Enum, QualType EnumType)
 
static void checkModuleImportContext (Sema &S, Module *M, SourceLocation ImportLoc, DeclContext *DC, bool FromInclude=false)
 

Variables

 X
 Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing namespace or file scope inside a friend declaration. More...
 

Enumeration Type Documentation

Enumerator
ValidKernelParam 
PtrPtrKernelParam 
PtrKernelParam 
PrivatePtrKernelParam 
InvalidKernelParam 
RecordKernelParam 

Definition at line 7480 of file SemaDecl.cpp.

Definition at line 7037 of file SemaDecl.cpp.

Enum describing the select options in diag::warn_decl_shadow.

Enumerator
SDK_Local 
SDK_Global 
SDK_StaticMember 
SDK_Field 

Definition at line 6515 of file SemaDecl.cpp.

Definition at line 134 of file SemaDecl.cpp.

Function Documentation

static bool AllowOverloadingOfFunction ( LookupResult Previous,
ASTContext Context 
)
static

Determine whether we allow overloading of the function PrevDecl with another declaration.

This routine determines whether overloading is possible, not whether some new function is actually an overload. It will return true in C++ (where we can always provide overloads) or, as an extension, in C when the previous function is already an overloaded function declaration or has the "overloadable" attribute.

Definition at line 1231 of file SemaDecl.cpp.

References clang::LookupResult::Found, clang::LookupResult::FoundOverloaded, clang::LookupResult::getFoundDecl(), clang::ASTContext::getLangOpts(), and clang::LookupResult::getResultKind().

Referenced by clang::Sema::CheckFunctionDeclaration().

static ParsedType buildNestedType ( Sema S,
CXXScopeSpec SS,
QualType  T,
SourceLocation  NameLoc 
)
static
static bool canRedefineFunction ( const FunctionDecl FD,
const LangOptions LangOpts 
)
static

canRedefineFunction - checks if a function can be redefined.

Currently, only extern inline functions can be redefined, and even then only in GNU89 mode.

Definition at line 2642 of file SemaDecl.cpp.

References clang::FunctionDecl::getStorageClass(), clang::FunctionDecl::isInlineSpecified(), and clang::SC_Extern.

Referenced by clang::Sema::CheckForFunctionRedefinition(), and clang::Sema::MergeFunctionDecl().

static bool CheckAnonMemberRedeclaration ( Sema SemaRef,
Scope S,
DeclContext Owner,
DeclarationName  Name,
SourceLocation  NameLoc,
bool  IsUnion 
)
static

We are trying to inject an anonymous member into the given scope; check if there's an existing declaration that can't be overloaded.

Returns
true if this is a forbidden redeclaration

Definition at line 4088 of file SemaDecl.cpp.

References clang::Sema::Diag(), clang::Sema::ForRedeclaration, clang::LookupResult::getRepresentativeDecl(), clang::NamedDecl::getUnderlyingDecl(), clang::Sema::isDeclInScope(), clang::Sema::LookupMemberName, clang::Sema::LookupName(), and clang::Name.

Referenced by InjectAnonymousStructOrUnionMembers().

static void checkAttributesAfterMerging ( Sema S,
NamedDecl ND 
)
static
static void checkDLLAttributeRedeclaration ( Sema S,
NamedDecl OldDecl,
NamedDecl NewDecl,
bool  IsSpecialization,
bool  IsDefinition 
)
static
static void checkDuplicateDefaultInit ( Sema S,
CXXRecordDecl Parent,
SourceLocation  DefaultInitLoc 
)
static
static void checkDuplicateDefaultInit ( Sema S,
CXXRecordDecl Parent,
CXXRecordDecl AnonUnion 
)
static
template<typename T >
static bool checkForConflictWithNonVisibleExternC ( Sema S,
const T *  ND,
LookupResult Previous 
)
static

Apply special rules for handling extern "C" declarations.

Returns true if we have found that this is a redeclaration of some prior entity.

Per C++ [dcl.link]p6: Two declarations [for a function or variable] with C language linkage with the same name that appear in different scopes refer to the same [entity]. An entity with C language linkage shall not be declared with the same name as an entity in global scope.

Definition at line 6729 of file SemaDecl.cpp.

References clang::LookupResult::addDecl(), checkGlobalOrExternCConflict(), clang::LookupResult::clear(), clang::Sema::findLocallyScopedExternCDecl(), clang::Sema::getLangOpts(), and isIncompleteDeclExternC().

Referenced by clang::Sema::CheckFunctionDeclaration(), and clang::Sema::CheckVariableDeclaration().

static void CheckForDuplicateEnumValues ( Sema S,
ArrayRef< Decl * >  Elements,
EnumDecl Enum,
QualType  EnumType 
)
static
template<typename T >
static bool checkGlobalOrExternCConflict ( Sema S,
const T *  ND,
bool  IsGlobal,
LookupResult Previous 
)
static
static void checkIsValidOpenCLKernelParameter ( Sema S,
Declarator D,
ParmVarDecl Param,
llvm::SmallPtrSetImpl< const Type * > &  ValidTypes 
)
static
static void checkModuleImportContext ( Sema S,
Module M,
SourceLocation  ImportLoc,
DeclContext DC,
bool  FromInclude = false 
)
static
static void checkNewAttributesAfterDef ( Sema S,
Decl New,
const Decl Old 
)
static
static void CheckPoppedLabel ( LabelDecl L,
Sema S 
)
static
template<typename ExpectedDecl >
static bool checkUsingShadowRedecl ( Sema S,
UsingShadowDecl OldS,
ExpectedDecl *  New 
)
static

Check whether a redeclaration of an entity introduced by a using-declaration is valid, given that we know it's not an overload (nor a hidden tag declaration).

Definition at line 2678 of file SemaDecl.cpp.

References clang::Sema::Diag(), clang::UsingShadowDecl::getTargetDecl(), clang::UsingShadowDecl::getUsingDecl(), and isExternC().

static ShadowedDeclKind computeShadowedDeclKind ( const NamedDecl ShadowedDecl,
const DeclContext OldDC 
)
static

Determine what kind of declaration we're shadowing.

Definition at line 6518 of file SemaDecl.cpp.

References clang::DeclContext::isFileContext(), SDK_Field, SDK_Global, SDK_Local, and SDK_StaticMember.

Referenced by clang::Sema::CheckShadow().

* * * static FixItHint createFriendTagNNSFixIt ( Sema SemaRef,
NamedDecl ND,
Scope S,
SourceLocation  NameLoc 
)
static
static FunctionDecl* CreateNewFunctionDecl ( Sema SemaRef,
Declarator D,
DeclContext DC,
QualType R,
TypeSourceInfo TInfo,
StorageClass  SC,
bool IsVirtualOkay 
)
static

Definition at line 7338 of file SemaDecl.cpp.

References clang::Sema::AbstractReturnType, clang::Sema::AdjustDestructorExceptionSpec(), clang::Sema::CheckConstructorDeclarator(), clang::Sema::CheckConversionDeclarator(), clang::Sema::CheckDestructorDeclarator(), clang::Sema::Context, clang::FunctionDecl::Create(), clang::CXXMethodDecl::Create(), clang::CXXConstructorDecl::Create(), clang::CXXDestructorDecl::Create(), clang::CXXConversionDecl::Create(), clang::Sema::CurContext, clang::DeclarationName::CXXConstructorName, clang::DeclarationName::CXXConversionFunctionName, clang::DeclarationName::CXXDestructorName, clang::Sema::Diag(), clang::EST_None, clang::Type::getAs(), clang::DeclarationName::getAsIdentifierInfo(), clang::Declarator::getDeclSpec(), clang::CXXRecordDecl::getDefinition(), clang::Declarator::getFunctionTypeInfo(), clang::getIdentifier(), clang::Declarator::getIdentifierLoc(), clang::Sema::getLangOpts(), clang::Declarator::getLocStart(), clang::DeclarationNameInfo::getName(), clang::Sema::GetNameForDeclarator(), clang::DeclarationName::getNameKind(), clang::QualType::getTypePtr(), clang::DeclSpec::getTypeSpecTypeLoc(), clang::DeclaratorChunk::FunctionTypeInfo::hasPrototype, clang::TagDecl::isBeingDefined(), clang::DeclSpec::isConstexprSpecified(), clang::TagDecl::isDependentType(), clang::DeclSpec::isExplicitSpecified(), clang::DeclSpec::isFriendSpecified(), clang::Declarator::isFunctionDeclarator(), clang::Type::isFunctionProtoType(), clang::DeclSpec::isInlineSpecified(), clang::Declarator::isInvalidType(), clang::DeclContext::isRecord(), clang::CXXMethodDecl::isStatic(), clang::Name, clang::Sema::RequireNonAbstractType(), and clang::Declarator::setInvalidType().

Referenced by clang::Sema::ActOnFunctionDeclarator().

static bool DeclHasAttr ( const Decl D,
const Attr A 
)
static

DeclhasAttr - returns true if decl Declaration already has the target attribute.

Definition at line 2108 of file SemaDecl.cpp.

References clang::Attr::getKind().

Referenced by mergeDeclAttribute(), and mergeParamDeclAttributes().

static NamedDecl* DiagnoseInvalidRedeclaration ( Sema SemaRef,
LookupResult Previous,
FunctionDecl NewFD,
ActOnFDArgs &  ExtraArgs,
bool  IsLocalFriend,
Scope S 
)
static

Generate diagnostics for an invalid function redeclaration.

This routine handles generating the diagnostic messages for an invalid function redeclaration, including finding possible similar declarations or performing typo correction if there are no previous declarations with the same name.

Returns a NamedDecl iff typo correction was performed and substituting in the new declaration name does not cause new errors.

Definition at line 7163 of file SemaDecl.cpp.

References clang::Sema::ActOnFunctionDeclarator(), clang::LookupResult::addDecl(), clang::TypoCorrection::begin(), clang::LookupResult::begin(), clang::LookupResult::clear(), clang::Sema::Context, clang::Sema::CorrectTypo(), clang::Sema::CTK_ErrorRecovery, clang::Sema::Diag(), clang::Sema::diagnoseTypo(), E, clang::TypoCorrection::end(), clang::LookupResult::end(), clang::Sema::ForRedeclaration, clang::DeclarationName::getAsIdentifierInfo(), clang::TypoCorrection::getCorrection(), clang::TypoCorrection::getCorrectionAsIdentifierInfo(), clang::TypoCorrection::getCorrectionDecl(), clang::NamedDecl::getDeclName(), clang::SourceRange::getEnd(), clang::FunctionDecl::getParamDecl(), clang::DeclContext::getParent(), clang::FunctionDecl::getSourceRange(), clang::ValueDecl::getType(), clang::DeclaratorDecl::getTypeSourceInfo(), clang::DeclaratorDecl::getTypeSpecStartLoc(), clang::FunctionDecl::hasBody(), clang::Sema::SFINAETrap::hasErrorOccurred(), hasSimilarParameters(), I, clang::CXXMethodDecl::isConst(), clang::SourceLocation::isInvalid(), clang::Sema::LookupLocalFriendName, clang::Sema::LookupName(), clang::Sema::LookupOrdinaryName, clang::Sema::LookupQualifiedName(), clang::Sema::PDiag(), Previous, clang::Result, S, clang::TypoCorrection::setCorrectionDecl(), and clang::LookupResult::setLookupName().

Referenced by clang::Sema::ActOnFunctionDeclarator().

static void diagnoseVarDeclTypeMismatch ( Sema S,
VarDecl New,
VarDecl Old 
)
static
static void filterNonConflictingPreviousTypedefDecls ( Sema S,
TypedefNameDecl Decl,
LookupResult Previous 
)
static
static SourceLocation findDefaultInitializer ( const CXXRecordDecl Record)
static
static const CXXRecordDecl* findRecordWithDependentBasesOfEnclosingMethod ( const DeclContext DC)
static

Find the parent class with dependent bases of the innermost enclosing method context.

Do not look for enclosing CXXRecordDecls directly, or we will end up allowing unqualified dependent type names at class-level, which MSVC correctly rejects.

Definition at line 487 of file SemaDecl.cpp.

References clang::DeclContext::getLookupParent(), clang::DeclContext::getParent(), clang::DeclContext::getPrimaryContext(), and clang::DeclContext::isDependentContext().

Referenced by clang::Sema::ActOnMSVCUnknownTypeName().

static void FixInvalidVariablyModifiedTypeLoc ( TypeLoc  SrcTL,
TypeLoc  DstTL 
)
static
static void GenerateFixForUnusedDecl ( const NamedDecl D,
ASTContext Ctx,
FixItHint Hint 
)
static
static QualType getCoreType ( QualType  Ty)
static
static const Decl* getDefinition ( const Decl D)
static
static unsigned GetDiagnosticTypeSpecifierID ( DeclSpec::TST  T)
static
static StorageClass getFunctionStorageClass ( Sema SemaRef,
Declarator D 
)
static
static StringRef getHeaderName ( ASTContext::GetBuiltinTypeError  Error)
static
static unsigned getMSManglingNumber ( const LangOptions LO,
Scope S 
)
static
static QualType getNextLargerIntegralType ( ASTContext Context,
QualType  T 
)
static
template<typename T >
static std::pair<diag::kind, SourceLocation> getNoteDiagForInvalidRedeclaration ( const T *  Old,
const T *  New 
)
static
static OpenCLParamType getOpenCLKernelParameterType ( QualType  PT)
static
static unsigned getRedeclDiagFromTagKind ( TagTypeKind  Tag)
static

Get diagnostic select index for tag kind for redeclaration diagnostic message.

WARNING: Indexes apply to particular diagnostics only!

Returns
diagnostic select index.

Definition at line 12053 of file SemaDecl.cpp.

References clang::TTK_Class, clang::TTK_Interface, and clang::TTK_Struct.

Referenced by clang::Sema::isAcceptableTagRedeclaration().

static DeclContext* getTagInjectionContext ( DeclContext DC)
static

Find the DeclContext in which a tag is implicitly declared if we see an elaborated type specifier in the specified context, and lookup finds nothing.

Definition at line 12231 of file SemaDecl.cpp.

References clang::DeclContext::getParent(), clang::DeclContext::isFileContext(), and clang::DeclContext::isFunctionOrMethod().

Referenced by clang::Sema::ActOnTag().

static Scope* getTagInjectionScope ( Scope S,
const LangOptions LangOpts 
)
static

Find the Scope in which a tag is implicitly declared if we see an elaborated type specifier in the specified context, and lookup finds nothing.

Definition at line 12240 of file SemaDecl.cpp.

References clang::Scope::DeclScope, clang::Scope::getEntity(), clang::Scope::getFlags(), clang::Scope::getParent(), clang::Scope::isClassScope(), clang::Scope::isFunctionPrototypeScope(), clang::DeclContext::isTransparentContext(), and S.

Referenced by clang::Sema::ActOnTag().

static bool hasAttribute ( const Decl D,
attr::Kind  Kind 
)
static

Definition at line 2335 of file SemaDecl.cpp.

static bool hasDependentAlignment ( VarDecl VD)
static

Determines if a variable's alignment is dependent.

Definition at line 10479 of file SemaDecl.cpp.

References clang::ValueDecl::getType(), I, and clang::Type::isDependentType().

Referenced by clang::Sema::FinalizeDeclaration().

static bool hasIdenticalPassObjectSizeAttrs ( const FunctionDecl A,
const FunctionDecl B 
)
static
static bool hasParsedAttr ( Scope S,
const AttributeList AttrList,
AttributeList::Kind  Kind 
)
static
static bool hasParsedAttr ( Scope S,
const Declarator PD,
AttributeList::Kind  Kind 
)
static
static bool hasSimilarParameters ( ASTContext Context,
FunctionDecl Declaration,
FunctionDecl Definition,
SmallVectorImpl< unsigned > &  Params 
)
static

hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" matching parameters.

This heuristic is used to improve diagnostics in the case where an out-of-line function definition doesn't match any declaration within the class or namespace. Also sets Params to the list of indices to the parameters that differ between the declaration and the definition. If hasSimilarParameters returns true and Params is empty, then all of the parameters match.

Definition at line 4684 of file SemaDecl.cpp.

References clang::QualType::getBaseTypeIdentifier(), getCoreType(), clang::FunctionDecl::getParamDecl(), clang::ValueDecl::getType(), clang::ASTContext::hasSameType(), clang::ASTContext::hasSameUnqualifiedType(), and clang::FunctionDecl::param_size().

Referenced by DiagnoseInvalidRedeclaration().

template<typename T >
static bool haveIncompatibleLanguageLinkages ( const T *  Old,
const T *  New 
)
static
static bool InjectAnonymousStructOrUnionMembers ( Sema SemaRef,
Scope S,
DeclContext Owner,
RecordDecl AnonRecord,
AccessSpecifier  AS,
SmallVectorImpl< NamedDecl * > &  Chaining 
)
static

InjectAnonymousStructOrUnionMembers - Inject the members of the anonymous struct or union AnonRecord into the owning context Owner and scope S.

This routine will be invoked just after we realize that an unnamed union or struct is actually an anonymous union or struct, e.g.,

union {
int i;
float f;
}; // InjectAnonymousStructOrUnionMembers called here to inject i and
// f into the surrounding scope.x

This routine is recursive, injecting the names of nested anonymous structs/unions into the owning context and scope as well.

Definition at line 4129 of file SemaDecl.cpp.

References clang::AS_none, CheckAnonMemberRedeclaration(), clang::Attr::clone(), clang::Sema::Context, clang::IndirectFieldDecl::Create(), clang::DeclContext::decls(), clang::NamedDecl::getDeclName(), clang::NamedDecl::getIdentifier(), clang::ValueDecl::getType(), clang::TagDecl::isUnion(), and clang::Sema::PushOnScopeChains().

Referenced by clang::Sema::BuildAnonymousStructOrUnion(), and clang::Sema::BuildMicrosoftCAnonymousStruct().

static bool isAcceptableTagRedeclContext ( Sema S,
DeclContext OldDC,
DeclContext NewDC 
)
static

Determine whether a tag originally declared in context OldDC can be redeclared with an unqualfied name in NewDC (assuming name lookup found a declaration in OldDC as a previous decl, perhaps through a using-declaration).

Definition at line 12211 of file SemaDecl.cpp.

References clang::DeclContext::Encloses(), clang::DeclContext::Equals(), clang::Sema::getLangOpts(), and clang::DeclContext::getRedeclContext().

Referenced by clang::Sema::ActOnTag().

static bool isAttributeTargetADefinition ( Decl D)
static

Definition at line 2127 of file SemaDecl.cpp.

Referenced by mergeAlignedAttrs().

static bool isClassCompatTagKind ( TagTypeKind  Tag)
static

Determine if tag kind is a class-key compatible with class for redeclaration (class, struct, or __interface).

Returns
true iff the tag kind is compatible.

Definition at line 12066 of file SemaDecl.cpp.

References clang::TTK_Class, clang::TTK_Interface, and clang::TTK_Struct.

Referenced by clang::Sema::isAcceptableTagRedeclaration().

static bool isDeclExternC ( const Decl D)
static

Returns true if given declaration has external C language linkage.

Definition at line 5839 of file SemaDecl.cpp.

Referenced by clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnPragmaRedefineExtname(), and clang::Sema::ActOnVariableDeclarator().

static bool IsDisallowedCopyOrAssign ( const CXXMethodDecl D)
static

Check for this common pattern:

class S {
S(const S&); // DO NOT IMPLEMENT
void operator=(const S&); // DO NOT IMPLEMENT
};

Definition at line 1373 of file SemaDecl.cpp.

References clang::FunctionDecl::doesThisDeclarationHaveABody().

Referenced by clang::Sema::ShouldWarnIfUnusedFileScopedDecl().

template<typename T >
static bool isExternC ( T *  D)
static

Definition at line 2671 of file SemaDecl.cpp.

Referenced by checkUsingShadowRedecl().

static bool isExternC ( VarTemplateDecl )
static

Definition at line 2672 of file SemaDecl.cpp.

static bool isFunctionDefinitionDiscarded ( Sema S,
FunctionDecl FD 
)
static

Given that we are within the definition of the given function, will that definition behave like C99's 'inline', where the definition is discarded except for optimization purposes?

Definition at line 5707 of file SemaDecl.cpp.

References clang::Sema::Context, clang::ASTContext::GetGVALinkageForFunction(), clang::Sema::getLangOpts(), clang::GVA_AvailableExternally, clang::FunctionDecl::isInlined(), and clang::FunctionDecl::setLazyBody().

Referenced by clang::Sema::ActOnVariableDeclarator().

template<typename T >
static bool isIncompleteDeclExternC ( Sema S,
const T *  D 
)
static

Determine whether a variable is extern "C" prior to attaching an initializer.

We can't just call isExternC() here, because that will also compute and cache whether the declaration is externally visible, which might change when we attach the initializer.

This can only be used if the declaration is known to not be a redeclaration of an internal linkage declaration.

For instance:

auto x = []{};

Attaching the initializer here makes this declaration not externally visible, because its type has internal linkage.

FIXME: This is a hack.

Definition at line 5754 of file SemaDecl.cpp.

References clang::Sema::getLangOpts().

Referenced by clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnVariableDeclarator(), checkForConflictWithNonVisibleExternC(), and checkGlobalOrExternCConflict().

static bool isMainFileLoc ( const Sema S,
SourceLocation  Loc 
)
static
static bool isOutOfScopePreviousDeclaration ( NamedDecl PrevDecl,
DeclContext DC,
ASTContext Context 
)
static

Determines whether the given declaration is an out-of-scope previous declaration.

This routine should be invoked when name lookup has found a previous declaration (PrevDecl) that is not in the scope where a new declaration by the same name is being introduced. If the new declaration occurs in a local scope, previous declarations with linkage may still be considered previous declarations (C99 6.2.2p4-5, C++ [basic.link]p6).

Parameters
PrevDeclthe previous declaration found by name lookup
DCthe context in which the new declaration is being declared.
Returns
true if PrevDecl is an out-of-scope previous declaration for a new delcaration with the same name.

Definition at line 5442 of file SemaDecl.cpp.

References clang::DeclContext::Equals(), clang::DeclContext::getEnclosingNamespaceContext(), clang::ASTContext::getLangOpts(), clang::DeclContext::getRedeclContext(), clang::NamedDecl::hasLinkage(), clang::DeclContext::isFunctionOrMethod(), and clang::DeclContext::isRecord().

Referenced by clang::Sema::FilterLookupForScope().

static bool isRepresentableIntegerValue ( ASTContext Context,
llvm::APSInt &  Value,
QualType  T 
)
static

Determine whether the given integral value is representable within the given type T.

Definition at line 14269 of file SemaDecl.cpp.

References clang::ASTContext::getIntWidth(), clang::Type::isIntegralType(), and clang::Type::isSignedIntegerOrEnumerationType().

Referenced by clang::Sema::ActOnEnumBody(), and clang::Sema::CheckEnumConstant().

static bool isResultTypeOrTemplate ( LookupResult R,
const Token NextToken 
)
static

Determine whether the given result set contains either a type name or.

Definition at line 695 of file SemaDecl.cpp.

References clang::LookupResult::begin(), clang::LookupResult::end(), clang::Sema::getLangOpts(), clang::LookupResult::getSema(), I, and clang::Token::is().

Referenced by clang::Sema::ClassifyName().

static bool isTagTypeWithMissingTag ( Sema SemaRef,
LookupResult Result,
Scope S,
CXXScopeSpec SS,
IdentifierInfo *&  Name,
SourceLocation  NameLoc 
)
static
static bool isUsingDecl ( NamedDecl D)
static

Definition at line 1350 of file SemaDecl.cpp.

Referenced by RemoveUsingDecls().

static void LookupPredefedObjCSuperType ( Sema ThisSema,
Scope S,
IdentifierInfo II 
)
static

Looks up the declaration of "struct objc_super" and saves it for later use in building builtin declaration of objc_msgSendSuper and objc_msgSendSuper_stret.

If no such pre-existing declaration exists no action takes place.

Definition at line 1748 of file SemaDecl.cpp.

References clang::Sema::Context, Context, clang::LookupResult::Found, clang::IdentifierTable::get(), clang::ASTContext::getTagDeclType(), clang::ASTContext::Idents, clang::IdentifierInfo::isStr(), clang::Sema::LookupName(), clang::Sema::LookupTagName, clang::Result, and clang::ASTContext::setObjCSuperType().

Referenced by clang::Sema::CheckFunctionDeclaration(), and clang::Sema::LazilyCreateBuiltin().

static UnqualifiedTypeNameLookupResult lookupUnqualifiedTypeNameInBase ( Sema S,
const IdentifierInfo II,
SourceLocation  NameLoc,
const CXXRecordDecl RD 
)
static

Tries to perform unqualified lookup of the type decls in bases for dependent class.

Returns
NotFound if no any decls is found, FoundNotType if found not a type decl, FoundType if only type decls are found.

Definition at line 146 of file SemaDecl.cpp.

References clang::CXXRecordDecl::bases(), clang::CXXRecordDecl::getCanonicalDecl(), clang::CXXRecordDecl::hasDefinition(), clang::DeclContext::lookup(), and clang::TemplateSpecializationType().

Referenced by recoverFromTypeInKnownDependentBase().

static bool mergeAlignedAttrs ( Sema S,
NamedDecl New,
Decl Old 
)
static

Merge alignment attributes from Old to New, taking into account the special semantics of C11's _Alignas specifier and C++11's alignas attribute.

Returns
true if any attributes were added to New.

Definition at line 2139 of file SemaDecl.cpp.

References clang::Sema::Context, clang::Sema::Diag(), clang::CharUnits::getQuantity(), clang::ASTContext::getTagDeclType(), clang::ASTContext::getTypeAlign(), I, isAttributeTargetADefinition(), and clang::ASTContext::toCharUnitsFromBits().

Referenced by clang::Sema::mergeDeclAttributes().

static bool mergeDeclAttribute ( Sema S,
NamedDecl D,
const InheritableAttr Attr,
Sema::AvailabilityMergeKind  AMK 
)
static
static void mergeParamDeclAttributes ( ParmVarDecl newDecl,
const ParmVarDecl oldDecl,
Sema S 
)
static
static void mergeParamDeclTypes ( ParmVarDecl NewParam,
const ParmVarDecl OldParam,
Sema S 
)
static
static bool mergeTypeWithPrevious ( Sema S,
VarDecl NewVD,
VarDecl OldVD,
LookupResult Previous 
)
static
static bool RebuildDeclaratorInCurrentInstantiation ( Sema S,
Declarator D,
DeclarationName  Name 
)
static

NeedsRebuildingInCurrentInstantiation - Checks whether the given declarator needs to be rebuilt in the current instantiation.

Any bits of declarator which appear before the name are valid for consideration here. That's specifically the type in the decl spec and the base type in any member-pointer chunks.

Definition at line 4719 of file SemaDecl.cpp.

References clang::Sema::Context, clang::Sema::CreateParsedType(), E, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Declarator::getIdentifierLoc(), clang::Declarator::getMutableDeclSpec(), clang::Declarator::getNumTypeObjects(), clang::DeclSpec::getRepAsExpr(), clang::DeclSpec::getRepAsType(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::TypeSourceInfo::getType(), clang::Sema::GetTypeFromParser(), clang::Declarator::getTypeObject(), clang::DeclSpec::getTypeSpecType(), clang::DeclSpec::getTypeSpecTypeLoc(), I, clang::Type::isDependentType(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::QualType::isNull(), clang::DeclaratorChunk::Kind, clang::DeclaratorChunk::Mem, clang::DeclaratorChunk::MemberPointer, clang::Name, clang::Sema::RebuildExprInCurrentInstantiation(), clang::Sema::RebuildNestedNameSpecifierInCurrentInstantiation(), clang::Sema::RebuildTypeInCurrentInstantiation(), clang::Result, clang::DeclaratorChunk::MemberPointerTypeInfo::Scope(), clang::DeclSpec::TST_atomic, clang::DeclSpec::TST_decltype, clang::DeclSpec::TST_typename, clang::DeclSpec::TST_typeofExpr, clang::DeclSpec::TST_typeofType, clang::DeclSpec::TST_underlyingType, clang::DeclSpec::UpdateExprRep(), and clang::DeclSpec::UpdateTypeRep().

Referenced by clang::Sema::HandleDeclarator().

static void RebuildLambdaScopeInfo ( CXXMethodDecl CallOperator,
Sema S 
)
static
static ParsedType recoverFromTypeInKnownDependentBase ( Sema S,
const IdentifierInfo II,
SourceLocation  NameLoc 
)
static
static void RemoveUsingDecls ( LookupResult R)
static
static void ReportOverrides ( Sema S,
unsigned  DiagID,
const CXXMethodDecl MD,
OverrideErrorKind  OEK = OEK_All 
)
static

Report an error regarding overriding, along with any relevant overriden methods.

Parameters
DiagIDthe primary error to report.
MDthe overriding method.
OEKwhich overrides to include as notes.

Definition at line 7046 of file SemaDecl.cpp.

References clang::CXXMethodDecl::begin_overridden_methods(), clang::Sema::Diag(), E, clang::CXXMethodDecl::end_overridden_methods(), clang::NamedDecl::getDeclName(), and I.

Referenced by clang::Sema::AddOverriddenMethods(), and clang::Sema::CheckFunctionDeclaration().

static void SetNestedNameSpecifier ( DeclaratorDecl DD,
Declarator D 
)
static
static bool shouldConsiderLinkage ( const VarDecl VD)
static
static bool shouldConsiderLinkage ( const FunctionDecl FD)
static
static bool ShouldDiagnoseUnusedDecl ( const NamedDecl D)
static
static bool ShouldWarnAboutMissingPrototype ( const FunctionDecl FD,
const FunctionDecl *&  PossibleZeroParamPrototype 
)
static
static StorageClass StorageClassSpecToVarDeclStorageClass ( const DeclSpec DS)
static
static NestedNameSpecifier* synthesizeCurrentNestedNameSpecifier ( ASTContext Context,
DeclContext DC 
)
static
static ObjCIvarDecl::AccessControl TranslateIvarVisibility ( tok::ObjCKeywordKind  ivarVisibility)
static

TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.

Definition at line 13694 of file SemaDecl.cpp.

References clang::ObjCIvarDecl::Package, clang::ObjCIvarDecl::Private, clang::ObjCIvarDecl::Protected, and clang::ObjCIvarDecl::Public.

Referenced by clang::Sema::ActOnIvar().

static QualType TryToFixInvalidVariablyModifiedType ( QualType  T,
ASTContext Context,
bool SizeIsNegative,
llvm::APSInt &  Oversized 
)
static
static TypeSourceInfo* TryToFixInvalidVariablyModifiedTypeSourceInfo ( TypeSourceInfo TInfo,
ASTContext Context,
bool SizeIsNegative,
llvm::APSInt &  Oversized 
)
static
static bool ValidDuplicateEnum ( EnumConstantDecl ECD,
EnumDecl Enum 
)
static

Variable Documentation

X

Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing namespace or file scope inside a friend declaration.

This should provide the commented out code in the following snippet: namespace N { struct X; namespace M { struct Y { friend struct /*N::

Definition at line 12171 of file SemaDecl.cpp.

Referenced by clang::Sema::ActOnOpenMPAtomicDirective(), clang::ento::BasicValueFactory::Add1(), checkDeducedTemplateArguments(), clang::SrcMgr::ExpansionInfo::create(), clang::CodeGen::CodeGenFunction::EmitAMDGPUBuiltinExpr(), EmitOverflowIntrinsic(), clang::CodeGen::CodeGenFunction::EmitPPCBuiltinExpr(), clang::CodeGen::CodeGenFunction::EmitSystemZBuiltinExpr(), clang::ento::nonloc::ConcreteInt::evalBinOp(), clang::ento::loc::ConcreteInt::evalBinOp(), clang::ento::ExprEngine::evalComplement(), clang::ento::ExprEngine::evalMinus(), clang::ento::PathDiagnosticConsumer::FlushDiagnostics(), clang::SrcMgr::FileInfo::get(), clang::ento::SVal::getAsFunctionDecl(), clang::ento::SVal::getAsLocSymbol(), getAsPointeeSymbol(), clang::ento::SVal::getAsRegion(), clang::ento::SVal::getAsSymbol(), clang::ento::SVal::getAsSymbolicExpression(), clang::CFGStmtMap::getBlock(), clang::DeclGroupRef::getFromOpaquePtr(), clang::SourceLocation::getFromRawEncoding(), clang::ento::SVal::getLocSymbolInBase(), isSameEntity(), isSameTemplateParameter(), mergeCandidatesWithResults(), clang::ento::PathDiagnosticLocation::operator!=(), clang::operator<=(), clang::operator>(), parameterTypeFromSVal(), clang::ento::ExprEngine::processBranch(), REGISTER_MAP_WITH_PROGRAMSTATE(), clang::ento::ScanReachableSymbols::scan(), clang::ento::BasicValueFactory::Sub1(), swap32le(), TryListConversion(), clang::ento::ExprEngine::VisitGCCAsmStmt(), clang::ento::ExprEngine::VisitLogicalExpr(), clang::ento::TrackConstraintBRVisitor::VisitNode(), clang::ento::ExprEngine::VisitOffsetOfExpr(), and clang::ento::ExprEngine::VisitUnaryOperator().