SemaStmtAttr.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. //===--- SemaStmtAttr.cpp - Statement Attribute Handling ------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements stmt-related attribute processing.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "clang/AST/ASTContext.h"
  13. #include "clang/AST/EvaluatedExprVisitor.h"
  14. #include "clang/Basic/SourceManager.h"
  15. #include "clang/Basic/TargetInfo.h"
  16. #include "clang/Sema/DelayedDiagnostic.h"
  17. #include "clang/Sema/Lookup.h"
  18. #include "clang/Sema/ScopeInfo.h"
  19. #include "clang/Sema/SemaInternal.h"
  20. #include "llvm/ADT/StringExtras.h"
  21. #include <optional>
  22. using namespace clang;
  23. using namespace sema;
  24. static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const ParsedAttr &A,
  25. SourceRange Range) {
  26. FallThroughAttr Attr(S.Context, A);
  27. if (isa<SwitchCase>(St)) {
  28. S.Diag(A.getRange().getBegin(), diag::err_fallthrough_attr_wrong_target)
  29. << A << St->getBeginLoc();
  30. SourceLocation L = S.getLocForEndOfToken(Range.getEnd());
  31. S.Diag(L, diag::note_fallthrough_insert_semi_fixit)
  32. << FixItHint::CreateInsertion(L, ";");
  33. return nullptr;
  34. }
  35. auto *FnScope = S.getCurFunction();
  36. if (FnScope->SwitchStack.empty()) {
  37. S.Diag(A.getRange().getBegin(), diag::err_fallthrough_attr_outside_switch);
  38. return nullptr;
  39. }
  40. // If this is spelled as the standard C++17 attribute, but not in C++17, warn
  41. // about using it as an extension.
  42. if (!S.getLangOpts().CPlusPlus17 && A.isCXX11Attribute() &&
  43. !A.getScopeName())
  44. S.Diag(A.getLoc(), diag::ext_cxx17_attr) << A;
  45. FnScope->setHasFallthroughStmt();
  46. return ::new (S.Context) FallThroughAttr(S.Context, A);
  47. }
  48. static Attr *handleSuppressAttr(Sema &S, Stmt *St, const ParsedAttr &A,
  49. SourceRange Range) {
  50. std::vector<StringRef> DiagnosticIdentifiers;
  51. for (unsigned I = 0, E = A.getNumArgs(); I != E; ++I) {
  52. StringRef RuleName;
  53. if (!S.checkStringLiteralArgumentAttr(A, I, RuleName, nullptr))
  54. return nullptr;
  55. // FIXME: Warn if the rule name is unknown. This is tricky because only
  56. // clang-tidy knows about available rules.
  57. DiagnosticIdentifiers.push_back(RuleName);
  58. }
  59. return ::new (S.Context) SuppressAttr(
  60. S.Context, A, DiagnosticIdentifiers.data(), DiagnosticIdentifiers.size());
  61. }
  62. static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A,
  63. SourceRange) {
  64. IdentifierLoc *PragmaNameLoc = A.getArgAsIdent(0);
  65. IdentifierLoc *OptionLoc = A.getArgAsIdent(1);
  66. IdentifierLoc *StateLoc = A.getArgAsIdent(2);
  67. Expr *ValueExpr = A.getArgAsExpr(3);
  68. StringRef PragmaName =
  69. llvm::StringSwitch<StringRef>(PragmaNameLoc->Ident->getName())
  70. .Cases("unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam",
  71. PragmaNameLoc->Ident->getName())
  72. .Default("clang loop");
  73. // This could be handled automatically by adding a Subjects definition in
  74. // Attr.td, but that would make the diagnostic behavior worse in this case
  75. // because the user spells this attribute as a pragma.
  76. if (!isa<DoStmt, ForStmt, CXXForRangeStmt, WhileStmt>(St)) {
  77. std::string Pragma = "#pragma " + std::string(PragmaName);
  78. S.Diag(St->getBeginLoc(), diag::err_pragma_loop_precedes_nonloop) << Pragma;
  79. return nullptr;
  80. }
  81. LoopHintAttr::OptionType Option;
  82. LoopHintAttr::LoopHintState State;
  83. auto SetHints = [&Option, &State](LoopHintAttr::OptionType O,
  84. LoopHintAttr::LoopHintState S) {
  85. Option = O;
  86. State = S;
  87. };
  88. if (PragmaName == "nounroll") {
  89. SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
  90. } else if (PragmaName == "unroll") {
  91. // #pragma unroll N
  92. if (ValueExpr)
  93. SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
  94. else
  95. SetHints(LoopHintAttr::Unroll, LoopHintAttr::Enable);
  96. } else if (PragmaName == "nounroll_and_jam") {
  97. SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Disable);
  98. } else if (PragmaName == "unroll_and_jam") {
  99. // #pragma unroll_and_jam N
  100. if (ValueExpr)
  101. SetHints(LoopHintAttr::UnrollAndJamCount, LoopHintAttr::Numeric);
  102. else
  103. SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Enable);
  104. } else {
  105. // #pragma clang loop ...
  106. assert(OptionLoc && OptionLoc->Ident &&
  107. "Attribute must have valid option info.");
  108. Option = llvm::StringSwitch<LoopHintAttr::OptionType>(
  109. OptionLoc->Ident->getName())
  110. .Case("vectorize", LoopHintAttr::Vectorize)
  111. .Case("vectorize_width", LoopHintAttr::VectorizeWidth)
  112. .Case("interleave", LoopHintAttr::Interleave)
  113. .Case("vectorize_predicate", LoopHintAttr::VectorizePredicate)
  114. .Case("interleave_count", LoopHintAttr::InterleaveCount)
  115. .Case("unroll", LoopHintAttr::Unroll)
  116. .Case("unroll_count", LoopHintAttr::UnrollCount)
  117. .Case("pipeline", LoopHintAttr::PipelineDisabled)
  118. .Case("pipeline_initiation_interval",
  119. LoopHintAttr::PipelineInitiationInterval)
  120. .Case("distribute", LoopHintAttr::Distribute)
  121. .Default(LoopHintAttr::Vectorize);
  122. if (Option == LoopHintAttr::VectorizeWidth) {
  123. assert((ValueExpr || (StateLoc && StateLoc->Ident)) &&
  124. "Attribute must have a valid value expression or argument.");
  125. if (ValueExpr && S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
  126. return nullptr;
  127. if (StateLoc && StateLoc->Ident && StateLoc->Ident->isStr("scalable"))
  128. State = LoopHintAttr::ScalableWidth;
  129. else
  130. State = LoopHintAttr::FixedWidth;
  131. } else if (Option == LoopHintAttr::InterleaveCount ||
  132. Option == LoopHintAttr::UnrollCount ||
  133. Option == LoopHintAttr::PipelineInitiationInterval) {
  134. assert(ValueExpr && "Attribute must have a valid value expression.");
  135. if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
  136. return nullptr;
  137. State = LoopHintAttr::Numeric;
  138. } else if (Option == LoopHintAttr::Vectorize ||
  139. Option == LoopHintAttr::Interleave ||
  140. Option == LoopHintAttr::VectorizePredicate ||
  141. Option == LoopHintAttr::Unroll ||
  142. Option == LoopHintAttr::Distribute ||
  143. Option == LoopHintAttr::PipelineDisabled) {
  144. assert(StateLoc && StateLoc->Ident && "Loop hint must have an argument");
  145. if (StateLoc->Ident->isStr("disable"))
  146. State = LoopHintAttr::Disable;
  147. else if (StateLoc->Ident->isStr("assume_safety"))
  148. State = LoopHintAttr::AssumeSafety;
  149. else if (StateLoc->Ident->isStr("full"))
  150. State = LoopHintAttr::Full;
  151. else if (StateLoc->Ident->isStr("enable"))
  152. State = LoopHintAttr::Enable;
  153. else
  154. llvm_unreachable("bad loop hint argument");
  155. } else
  156. llvm_unreachable("bad loop hint");
  157. }
  158. return LoopHintAttr::CreateImplicit(S.Context, Option, State, ValueExpr, A);
  159. }
  160. namespace {
  161. class CallExprFinder : public ConstEvaluatedExprVisitor<CallExprFinder> {
  162. bool FoundAsmStmt = false;
  163. std::vector<const CallExpr *> CallExprs;
  164. public:
  165. typedef ConstEvaluatedExprVisitor<CallExprFinder> Inherited;
  166. CallExprFinder(Sema &S, const Stmt *St) : Inherited(S.Context) { Visit(St); }
  167. bool foundCallExpr() { return !CallExprs.empty(); }
  168. const std::vector<const CallExpr *> &getCallExprs() { return CallExprs; }
  169. bool foundAsmStmt() { return FoundAsmStmt; }
  170. void VisitCallExpr(const CallExpr *E) { CallExprs.push_back(E); }
  171. void VisitAsmStmt(const AsmStmt *S) { FoundAsmStmt = true; }
  172. void Visit(const Stmt *St) {
  173. if (!St)
  174. return;
  175. ConstEvaluatedExprVisitor<CallExprFinder>::Visit(St);
  176. }
  177. };
  178. } // namespace
  179. static Attr *handleNoMergeAttr(Sema &S, Stmt *St, const ParsedAttr &A,
  180. SourceRange Range) {
  181. NoMergeAttr NMA(S.Context, A);
  182. CallExprFinder CEF(S, St);
  183. if (!CEF.foundCallExpr() && !CEF.foundAsmStmt()) {
  184. S.Diag(St->getBeginLoc(), diag::warn_attribute_ignored_no_calls_in_stmt)
  185. << A;
  186. return nullptr;
  187. }
  188. return ::new (S.Context) NoMergeAttr(S.Context, A);
  189. }
  190. static Attr *handleNoInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A,
  191. SourceRange Range) {
  192. NoInlineAttr NIA(S.Context, A);
  193. if (!NIA.isClangNoInline()) {
  194. S.Diag(St->getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
  195. << "[[clang::noinline]]";
  196. return nullptr;
  197. }
  198. CallExprFinder CEF(S, St);
  199. if (!CEF.foundCallExpr()) {
  200. S.Diag(St->getBeginLoc(), diag::warn_attribute_ignored_no_calls_in_stmt)
  201. << A;
  202. return nullptr;
  203. }
  204. for (const auto *CallExpr : CEF.getCallExprs()) {
  205. const Decl *Decl = CallExpr->getCalleeDecl();
  206. if (Decl->hasAttr<AlwaysInlineAttr>() || Decl->hasAttr<FlattenAttr>())
  207. S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
  208. << A << (Decl->hasAttr<AlwaysInlineAttr>() ? 0 : 1);
  209. }
  210. return ::new (S.Context) NoInlineAttr(S.Context, A);
  211. }
  212. static Attr *handleAlwaysInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A,
  213. SourceRange Range) {
  214. AlwaysInlineAttr AIA(S.Context, A);
  215. if (!AIA.isClangAlwaysInline()) {
  216. S.Diag(St->getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
  217. << "[[clang::always_inline]]";
  218. return nullptr;
  219. }
  220. CallExprFinder CEF(S, St);
  221. if (!CEF.foundCallExpr()) {
  222. S.Diag(St->getBeginLoc(), diag::warn_attribute_ignored_no_calls_in_stmt)
  223. << A;
  224. return nullptr;
  225. }
  226. for (const auto *CallExpr : CEF.getCallExprs()) {
  227. const Decl *Decl = CallExpr->getCalleeDecl();
  228. if (Decl->hasAttr<NoInlineAttr>() || Decl->hasAttr<FlattenAttr>())
  229. S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
  230. << A << (Decl->hasAttr<NoInlineAttr>() ? 2 : 1);
  231. }
  232. return ::new (S.Context) AlwaysInlineAttr(S.Context, A);
  233. }
  234. static Attr *handleMustTailAttr(Sema &S, Stmt *St, const ParsedAttr &A,
  235. SourceRange Range) {
  236. // Validation is in Sema::ActOnAttributedStmt().
  237. return ::new (S.Context) MustTailAttr(S.Context, A);
  238. }
  239. static Attr *handleLikely(Sema &S, Stmt *St, const ParsedAttr &A,
  240. SourceRange Range) {
  241. if (!S.getLangOpts().CPlusPlus20 && A.isCXX11Attribute() && !A.getScopeName())
  242. S.Diag(A.getLoc(), diag::ext_cxx20_attr) << A << Range;
  243. return ::new (S.Context) LikelyAttr(S.Context, A);
  244. }
  245. static Attr *handleUnlikely(Sema &S, Stmt *St, const ParsedAttr &A,
  246. SourceRange Range) {
  247. if (!S.getLangOpts().CPlusPlus20 && A.isCXX11Attribute() && !A.getScopeName())
  248. S.Diag(A.getLoc(), diag::ext_cxx20_attr) << A << Range;
  249. return ::new (S.Context) UnlikelyAttr(S.Context, A);
  250. }
  251. #define WANT_STMT_MERGE_LOGIC
  252. #include "clang/Sema/AttrParsedAttrImpl.inc"
  253. #undef WANT_STMT_MERGE_LOGIC
  254. static void
  255. CheckForIncompatibleAttributes(Sema &S,
  256. const SmallVectorImpl<const Attr *> &Attrs) {
  257. // The vast majority of attributed statements will only have one attribute
  258. // on them, so skip all of the checking in the common case.
  259. if (Attrs.size() < 2)
  260. return;
  261. // First, check for the easy cases that are table-generated for us.
  262. if (!DiagnoseMutualExclusions(S, Attrs))
  263. return;
  264. enum CategoryType {
  265. // For the following categories, they come in two variants: a state form and
  266. // a numeric form. The state form may be one of default, enable, and
  267. // disable. The numeric form provides an integer hint (for example, unroll
  268. // count) to the transformer.
  269. Vectorize,
  270. Interleave,
  271. UnrollAndJam,
  272. Pipeline,
  273. // For unroll, default indicates full unrolling rather than enabling the
  274. // transformation.
  275. Unroll,
  276. // The loop distribution transformation only has a state form that is
  277. // exposed by #pragma clang loop distribute (enable | disable).
  278. Distribute,
  279. // The vector predication only has a state form that is exposed by
  280. // #pragma clang loop vectorize_predicate (enable | disable).
  281. VectorizePredicate,
  282. // This serves as a indicator to how many category are listed in this enum.
  283. NumberOfCategories
  284. };
  285. // The following array accumulates the hints encountered while iterating
  286. // through the attributes to check for compatibility.
  287. struct {
  288. const LoopHintAttr *StateAttr;
  289. const LoopHintAttr *NumericAttr;
  290. } HintAttrs[CategoryType::NumberOfCategories] = {};
  291. for (const auto *I : Attrs) {
  292. const LoopHintAttr *LH = dyn_cast<LoopHintAttr>(I);
  293. // Skip non loop hint attributes
  294. if (!LH)
  295. continue;
  296. CategoryType Category = CategoryType::NumberOfCategories;
  297. LoopHintAttr::OptionType Option = LH->getOption();
  298. switch (Option) {
  299. case LoopHintAttr::Vectorize:
  300. case LoopHintAttr::VectorizeWidth:
  301. Category = Vectorize;
  302. break;
  303. case LoopHintAttr::Interleave:
  304. case LoopHintAttr::InterleaveCount:
  305. Category = Interleave;
  306. break;
  307. case LoopHintAttr::Unroll:
  308. case LoopHintAttr::UnrollCount:
  309. Category = Unroll;
  310. break;
  311. case LoopHintAttr::UnrollAndJam:
  312. case LoopHintAttr::UnrollAndJamCount:
  313. Category = UnrollAndJam;
  314. break;
  315. case LoopHintAttr::Distribute:
  316. // Perform the check for duplicated 'distribute' hints.
  317. Category = Distribute;
  318. break;
  319. case LoopHintAttr::PipelineDisabled:
  320. case LoopHintAttr::PipelineInitiationInterval:
  321. Category = Pipeline;
  322. break;
  323. case LoopHintAttr::VectorizePredicate:
  324. Category = VectorizePredicate;
  325. break;
  326. };
  327. assert(Category != NumberOfCategories && "Unhandled loop hint option");
  328. auto &CategoryState = HintAttrs[Category];
  329. const LoopHintAttr *PrevAttr;
  330. if (Option == LoopHintAttr::Vectorize ||
  331. Option == LoopHintAttr::Interleave || Option == LoopHintAttr::Unroll ||
  332. Option == LoopHintAttr::UnrollAndJam ||
  333. Option == LoopHintAttr::VectorizePredicate ||
  334. Option == LoopHintAttr::PipelineDisabled ||
  335. Option == LoopHintAttr::Distribute) {
  336. // Enable|Disable|AssumeSafety hint. For example, vectorize(enable).
  337. PrevAttr = CategoryState.StateAttr;
  338. CategoryState.StateAttr = LH;
  339. } else {
  340. // Numeric hint. For example, vectorize_width(8).
  341. PrevAttr = CategoryState.NumericAttr;
  342. CategoryState.NumericAttr = LH;
  343. }
  344. PrintingPolicy Policy(S.Context.getLangOpts());
  345. SourceLocation OptionLoc = LH->getRange().getBegin();
  346. if (PrevAttr)
  347. // Cannot specify same type of attribute twice.
  348. S.Diag(OptionLoc, diag::err_pragma_loop_compatibility)
  349. << /*Duplicate=*/true << PrevAttr->getDiagnosticName(Policy)
  350. << LH->getDiagnosticName(Policy);
  351. if (CategoryState.StateAttr && CategoryState.NumericAttr &&
  352. (Category == Unroll || Category == UnrollAndJam ||
  353. CategoryState.StateAttr->getState() == LoopHintAttr::Disable)) {
  354. // Disable hints are not compatible with numeric hints of the same
  355. // category. As a special case, numeric unroll hints are also not
  356. // compatible with enable or full form of the unroll pragma because these
  357. // directives indicate full unrolling.
  358. S.Diag(OptionLoc, diag::err_pragma_loop_compatibility)
  359. << /*Duplicate=*/false
  360. << CategoryState.StateAttr->getDiagnosticName(Policy)
  361. << CategoryState.NumericAttr->getDiagnosticName(Policy);
  362. }
  363. }
  364. }
  365. static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A,
  366. SourceRange Range) {
  367. // Although the feature was introduced only in OpenCL C v2.0 s6.11.5, it's
  368. // useful for OpenCL 1.x too and doesn't require HW support.
  369. // opencl_unroll_hint can have 0 arguments (compiler
  370. // determines unrolling factor) or 1 argument (the unroll factor provided
  371. // by the user).
  372. unsigned UnrollFactor = 0;
  373. if (A.getNumArgs() == 1) {
  374. Expr *E = A.getArgAsExpr(0);
  375. std::optional<llvm::APSInt> ArgVal;
  376. if (!(ArgVal = E->getIntegerConstantExpr(S.Context))) {
  377. S.Diag(A.getLoc(), diag::err_attribute_argument_type)
  378. << A << AANT_ArgumentIntegerConstant << E->getSourceRange();
  379. return nullptr;
  380. }
  381. int Val = ArgVal->getSExtValue();
  382. if (Val <= 0) {
  383. S.Diag(A.getRange().getBegin(),
  384. diag::err_attribute_requires_positive_integer)
  385. << A << /* positive */ 0;
  386. return nullptr;
  387. }
  388. UnrollFactor = static_cast<unsigned>(Val);
  389. }
  390. return ::new (S.Context) OpenCLUnrollHintAttr(S.Context, A, UnrollFactor);
  391. }
  392. static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A,
  393. SourceRange Range) {
  394. if (A.isInvalid() || A.getKind() == ParsedAttr::IgnoredAttribute)
  395. return nullptr;
  396. // Unknown attributes are automatically warned on. Target-specific attributes
  397. // which do not apply to the current target architecture are treated as
  398. // though they were unknown attributes.
  399. const TargetInfo *Aux = S.Context.getAuxTargetInfo();
  400. if (A.getKind() == ParsedAttr::UnknownAttribute ||
  401. !(A.existsInTarget(S.Context.getTargetInfo()) ||
  402. (S.Context.getLangOpts().SYCLIsDevice && Aux &&
  403. A.existsInTarget(*Aux)))) {
  404. S.Diag(A.getLoc(), A.isDeclspecAttribute()
  405. ? (unsigned)diag::warn_unhandled_ms_attribute_ignored
  406. : (unsigned)diag::warn_unknown_attribute_ignored)
  407. << A << A.getRange();
  408. return nullptr;
  409. }
  410. if (S.checkCommonAttributeFeatures(St, A))
  411. return nullptr;
  412. switch (A.getKind()) {
  413. case ParsedAttr::AT_AlwaysInline:
  414. return handleAlwaysInlineAttr(S, St, A, Range);
  415. case ParsedAttr::AT_FallThrough:
  416. return handleFallThroughAttr(S, St, A, Range);
  417. case ParsedAttr::AT_LoopHint:
  418. return handleLoopHintAttr(S, St, A, Range);
  419. case ParsedAttr::AT_OpenCLUnrollHint:
  420. return handleOpenCLUnrollHint(S, St, A, Range);
  421. case ParsedAttr::AT_Suppress:
  422. return handleSuppressAttr(S, St, A, Range);
  423. case ParsedAttr::AT_NoMerge:
  424. return handleNoMergeAttr(S, St, A, Range);
  425. case ParsedAttr::AT_NoInline:
  426. return handleNoInlineAttr(S, St, A, Range);
  427. case ParsedAttr::AT_MustTail:
  428. return handleMustTailAttr(S, St, A, Range);
  429. case ParsedAttr::AT_Likely:
  430. return handleLikely(S, St, A, Range);
  431. case ParsedAttr::AT_Unlikely:
  432. return handleUnlikely(S, St, A, Range);
  433. default:
  434. // N.B., ClangAttrEmitter.cpp emits a diagnostic helper that ensures a
  435. // declaration attribute is not written on a statement, but this code is
  436. // needed for attributes in Attr.td that do not list any subjects.
  437. S.Diag(A.getRange().getBegin(), diag::err_decl_attribute_invalid_on_stmt)
  438. << A << St->getBeginLoc();
  439. return nullptr;
  440. }
  441. }
  442. void Sema::ProcessStmtAttributes(Stmt *S, const ParsedAttributes &InAttrs,
  443. SmallVectorImpl<const Attr *> &OutAttrs) {
  444. for (const ParsedAttr &AL : InAttrs) {
  445. if (const Attr *A = ProcessStmtAttribute(*this, S, AL, InAttrs.Range))
  446. OutAttrs.push_back(A);
  447. }
  448. CheckForIncompatibleAttributes(*this, OutAttrs);
  449. }