Lines Matching refs:decl
10 // This file implements decl-related attribute processing.
62 static const FunctionType *getFunctionType(const Decl *D,
65 if (const ValueDecl *decl = dyn_cast<ValueDecl>(D))
66 Ty = decl->getType();
67 else if (const FieldDecl *decl = dyn_cast<FieldDecl>(D))
68 Ty = decl->getType();
69 else if (const TypedefNameDecl* decl = dyn_cast<TypedefNameDecl>(D))
70 Ty = decl->getUnderlyingType();
85 /// isFunction - Return true if the given decl has function
87 static bool isFunction(const Decl *D) {
91 /// isFunctionOrMethod - Return true if the given decl has function
94 static bool isFunctionOrMethod(const Decl *D) {
98 /// isFunctionOrMethodOrBlock - Return true if the given decl has function
101 static bool isFunctionOrMethodOrBlock(const Decl *D) {
112 /// Return true if the given decl has a declarator that should have
114 static bool hasDeclarator(const Decl *D) {
120 /// hasFunctionProto - Return true if the given decl has a argument
121 /// information. This decl should have already passed
123 static bool hasFunctionProto(const Decl *D) {
135 static unsigned getFunctionOrMethodNumArgs(const Decl *D) {
143 static QualType getFunctionOrMethodArgType(const Decl *D, unsigned Idx) {
152 static QualType getFunctionOrMethodResultType(const Decl *D) {
158 static bool isFunctionOrMethodVariadic(const Decl *D) {
169 static bool isInstanceMethod(const Decl *D) {
236 static bool checkFunctionOrMethodArgumentIndex(Sema &S, const Decl *D,
280 /// \brief Check if passed in Decl is a field or potentially shared global var
281 /// \return true if the Decl is a field or potentially shared global variable
283 static bool mayBeSharedVariable(const Decl *D) {
315 /// \brief Check if passed in Decl is a pointer type.
317 /// \return true if the Decl is a pointer type; false otherwise
318 static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D,
370 static void checkForLockableRecord(Sema &S, Decl *D, const AttributeList &Attr,
411 static void checkAttrArgsAreLockableObjs(Sema &S, Decl *D,
493 static bool checkGuardedVarAttrCommon(Sema &S, Decl *D,
510 static void handleGuardedVarAttr(Sema &S, Decl *D, const AttributeList &Attr) {
519 static void handlePtGuardedVarAttr(Sema &S, Decl *D,
532 static bool checkGuardedByAttrCommon(Sema &S, Decl *D,
559 static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr) {
567 static void handlePtGuardedByAttr(Sema &S, Decl *D,
580 static bool checkLockableAttrCommon(Sema &S, Decl *D,
597 static void handleLockableAttr(Sema &S, Decl *D, const AttributeList &Attr) {
604 static void handleScopedLockableAttr(Sema &S, Decl *D,
614 static void handleNoThreadSafetyAnalysis(Sema &S, Decl *D,
631 static void handleNoSanitizeAddressAttr(Sema &S, Decl *D,
649 static void handleNoSanitizeMemory(Sema &S, Decl *D,
666 static void handleNoSanitizeThread(Sema &S, Decl *D,
683 static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D,
718 static void handleAcquiredAfterAttr(Sema &S, Decl *D,
731 static void handleAcquiredBeforeAttr(Sema &S, Decl *D,
744 static bool checkLockFunAttrCommon(Sema &S, Decl *D,
764 static void handleSharedLockFunctionAttr(Sema &S, Decl *D,
777 static void handleExclusiveLockFunctionAttr(Sema &S, Decl *D,
791 static bool checkTryLockFunAttrCommon(Sema &S, Decl *D,
817 static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D,
831 static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D,
845 static bool checkLocksRequiredCommon(Sema &S, Decl *D,
867 static void handleExclusiveLocksRequiredAttr(Sema &S, Decl *D,
880 static void handleSharedLocksRequiredAttr(Sema &S, Decl *D,
893 static void handleUnlockFunAttr(Sema &S, Decl *D,
916 static void handleLockReturnedAttr(Sema &S, Decl *D,
941 static void handleLocksExcludedAttr(Sema &S, Decl *D,
968 static void handleExtVectorTypeAttr(Sema &S, Scope *scope, Decl *D,
978 // Remember this typedef decl, we will need it later for diagnostics.
982 static void handlePackedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1005 static void handleMsStructAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1014 static void handleIBAction(Sema &S, Decl *D, const AttributeList &Attr) {
1031 static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &Attr) {
1057 static void handleIBOutlet(Sema &S, Decl *D, const AttributeList &Attr) {
1070 static void handleIBOutletCollection(Sema &S, Decl *D,
1122 static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1197 static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1250 // FIXME: Should also highlight argument in decl.
1287 static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
1386 // FIXME: Should also highlight argument in decl.
1444 Decl *D, const AttributeList &Attr) {
1509 // check for an existing decl?
1519 static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1548 static void handleMinSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1564 static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1585 static void handleHotAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1606 static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1622 static void handleAlwaysInlineAttr(Sema &S, Decl *D,
1641 static void handleTLSModelAttr(Sema &S, Decl *D,
1678 static void handleMallocAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1698 static void handleMayAliasAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1708 static void handleNoCommonAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1719 static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1730 static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &attr) {
1756 static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D,
1782 static void handleCXX11NoReturnAttr(Sema &S, Decl *D,
1800 static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1862 static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D,
1883 static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1902 static void handleReturnsTwiceAttr(Sema &S, Decl *D,
1921 static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1944 static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1975 static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2007 static void handleAttrWithMessage(Sema &S, Decl *D, const AttributeList &Attr,
2031 static void handleArcWeakrefUnavailableAttr(Sema &S, Decl *D,
2044 static void handleObjCRootClassAttr(Sema &S, Decl *D,
2062 static void handleObjCRequiresPropertyDefsAttr(Sema &S, Decl *D,
2259 static void handleAvailabilityAttr(Sema &S, Decl *D,
2298 static T *mergeVisibilityAttr(Sema &S, Decl *D, SourceRange range,
2313 VisibilityAttr *Sema::mergeVisibilityAttr(Decl *D, SourceRange Range,
2320 TypeVisibilityAttr *Sema::mergeTypeVisibilityAttr(Decl *D, SourceRange Range,
2327 static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &Attr,
2396 static void handleObjCMethodFamilyAttr(Sema &S, Decl *decl,
2398 ObjCMethodDecl *method = dyn_cast<ObjCMethodDecl>(decl);
2449 static void handleObjCExceptionAttr(Sema &S, Decl *D,
2465 static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) {
2499 handleOverloadableAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2515 static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2541 static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2635 static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &Attr) {
2663 static void handleWeakAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2687 static void handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2717 static void handleWorkGroupSize(Sema &S, Decl *D,
2772 static void handleVecTypeHint(Sema &S, Decl *D, const AttributeList &Attr) {
2802 static void handleEndianAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2811 SectionAttr *Sema::mergeSectionAttr(Decl *D, SourceRange Range,
2825 static void handleSectionAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2861 static void handleNothrowAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2878 static void handleConstAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2895 static void handlePureAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2905 static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2970 static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3073 static void handleInitPriorityAttr(Sema &S, Decl *D,
3121 FormatAttr *Sema::mergeFormatAttr(Decl *D, SourceRange Range, StringRef Format,
3147 static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3288 static void handleTransparentUnionAttr(Sema &S, Decl *D,
3357 static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3385 static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3412 void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
3500 void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *TS,
3510 void Sema::CheckAlignasUnderalignment(Decl *D) {
3511 assert(D->hasAttrs() && "no attributes on decl");
3546 /// handleModeAttr - This attribute modifies the width of a decl with primitive
3549 /// Despite what would be logical, the mode attribute is a decl attribute, not a
3552 static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3720 static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3742 static void handleNoInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3759 static void handleNoInstrumentFunctionAttr(Sema &S, Decl *D,
3777 static void handleKernelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3785 static void handleConstantAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3807 static void handleDeviceAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3829 static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3864 static void handleHostAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3885 static void handleSharedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3905 static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3927 static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3932 // in the Decl node for syntactic reasoning, e.g., pretty-printing.
4003 static void handleOpenCLKernelAttr(Sema &S, Decl *D, const AttributeList &Attr){
4071 static void handleRegparmAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4129 static void handleLaunchBoundsAttr(Sema &S, Decl *D, const AttributeList &Attr){
4176 static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D,
4227 static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D,
4261 static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4294 static void handleNSConsumesSelfAttr(Sema &S, Decl *D,
4307 static void handleNSReturnsRetainedAttr(Sema &S, Decl *D,
4383 static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D,
4413 static void handleObjCRequiresSuperAttr(Sema &S, Decl *D,
4442 static void handleCFTransferAttr(Sema &S, Decl *D, const AttributeList &A) {
4478 static void handleNSBridgedAttr(Sema &S, Scope *Sc, Decl *D,
4509 static void handleObjCOwnershipAttr(Sema &S, Decl *D,
4517 static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D,
4568 static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4623 static void handleInheritanceAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4647 static void handlePortabilityAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4666 static void handleForceInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4679 static void ProcessNonInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
4691 static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
4985 /// ProcessDeclAttribute - Apply the specific attribute to the specified decl if
4988 static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
5007 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
5008 /// attribute list to the specified decl, ignoring any type attributes.
5009 void Sema::ProcessDeclAttributeList(Scope *S, Decl *D,
5045 /// contains any decl attributes that we should warn about.
5063 /// used to build a declaration, complain about any decl attributes
5072 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
5073 /// \#pragma weak needs a non-definition decl and source may not have one.
5128 if (W.getAlias()) { // clone decl, impersonate __attribute(weak,alias(...))
5136 // to insert Decl at TU scope, sorry.
5146 void Sema::ProcessPragmaWeak(Scope *S, Decl *D) {
5175 void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD,
5177 // Apply decl attributes from the DeclSpec if present.
5181 // Walk the declarator structure, applying decl attributes that were in a type
5182 // position to the decl itself. This handles cases like:
5184 // when X is a decl attribute.
5190 // Finally, apply any attributes on the decl itself.
5196 static bool isForbiddenTypeAllowed(Sema &S, Decl *decl) {
5201 if (!isa<FieldDecl>(decl) && !isa<ObjCPropertyDecl>(decl) &&
5202 !isa<FunctionDecl>(decl))
5206 return S.Context.getSourceManager().isInSystemHeader(decl->getLocation());
5211 Decl *decl) {
5212 if (decl && isForbiddenTypeAllowed(S, decl)) {
5213 decl->addAttr(new (S.Context) UnavailableAttr(diag.Loc, S.Context,
5218 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(decl)) {
5234 void Sema::PopParsingDeclaration(ParsingDeclState state, Decl *decl) {
5242 if (!decl) return;
5245 // parents. In general, we'll get one pool for the decl spec
5246 // and a child pool for each declarator; in a decl group like:
5249 // we really do need to consider delayed diagnostics from the decl spec
5262 // Don't bother giving deprecation diagnostics if the decl is invalid.
5263 if (!decl->isInvalidDecl())
5264 HandleDelayedDeprecationCheck(diag, decl);
5268 HandleDelayedAccessCheck(diag, decl);
5272 handleDelayedForbiddenType(*this, diag, decl);
5288 static bool isDeclDeprecated(Decl *D) {
5295 } while ((D = cast_or_null<Decl>(D->getDeclContext())));
5328 Decl *Ctx) {
5353 if (isDeclDeprecated(cast<Decl>(getCurLexicalContext())))