23#include "llvm/ADT/BitVector.h"
38class JumpScopeChecker {
43 const bool Permissive;
66 GotoScope(
unsigned parentScope,
unsigned InDiag,
unsigned OutDiag,
68 : ParentScope(parentScope), InDiag(InDiag), OutDiag(OutDiag), Loc(L) {}
71 SmallVector<GotoScope, 48> Scopes;
72 llvm::DenseMap<Stmt*, unsigned> LabelAndGotoScopes;
73 SmallVector<Stmt*, 16> Jumps;
75 SmallVector<Stmt*, 4> IndirectJumps;
76 SmallVector<LabelDecl *, 4> IndirectJumpTargets;
77 SmallVector<AttributedStmt *, 4> MustTailStmts;
80 JumpScopeChecker(Stmt *Body, Sema &S);
82 void BuildScopeInformation(Decl *D,
unsigned &ParentScope);
83 void BuildScopeInformation(VarDecl *D,
const BlockDecl *BDecl,
84 unsigned &ParentScope);
85 void BuildScopeInformation(CompoundLiteralExpr *CLE,
unsigned &ParentScope);
86 void BuildScopeInformation(Stmt *S,
unsigned &origParentScope);
89 void VerifyIndirectJumps();
90 void VerifyMustTailStmts();
91 void NoteJumpIntoScopes(ArrayRef<unsigned> ToScopes);
92 void DiagnoseIndirectOrAsmJump(Stmt *IG,
unsigned IGScope, LabelDecl *
Target,
93 unsigned TargetScope);
94 void CheckJump(Stmt *From, Stmt *To, SourceLocation DiagLoc,
95 unsigned JumpDiag,
unsigned JumpDiagWarning,
96 unsigned JumpDiagCompat);
97 void CheckGotoStmt(GotoStmt *GS);
98 const Attr *GetMustTailAttr(AttributedStmt *AS);
100 unsigned GetDeepestCommonScope(
unsigned A,
unsigned B);
104#define CHECK_PERMISSIVE(x) (assert(Permissive || !(x)), (Permissive && (x)))
106JumpScopeChecker::JumpScopeChecker(
Stmt *Body,
Sema &
s)
107 : S(
s), Permissive(
s.hasAnyUnrecoverableErrorsInThisFunction()) {
113 unsigned BodyParentScope = 0;
114 BuildScopeInformation(Body, BodyParentScope);
118 VerifyIndirectJumps();
119 VerifyMustTailStmts();
124unsigned JumpScopeChecker::GetDeepestCommonScope(
unsigned A,
unsigned B) {
129 assert(Scopes[B].ParentScope < B);
130 B = Scopes[B].ParentScope;
132 assert(Scopes[A].ParentScope < A);
133 A = Scopes[A].ParentScope;
144 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
146 unsigned OutDiag = 0;
148 if (VD->getType()->isVariablyModifiedType())
149 InDiag = diag::note_protected_by_vla;
151 if (VD->hasAttr<BlocksAttr>())
152 return ScopePair(diag::note_protected_by___block,
153 diag::note_exits___block);
155 if (VD->hasAttr<CleanupAttr>())
156 return ScopePair(diag::note_protected_by_cleanup,
157 diag::note_exits_cleanup);
159 if (VD->hasLocalStorage()) {
160 switch (VD->getType().isDestructedType()) {
162 return ScopePair(diag::note_protected_by_objc_strong_init,
163 diag::note_exits_objc_strong);
166 return ScopePair(diag::note_protected_by_objc_weak_init,
167 diag::note_exits_objc_weak);
170 return ScopePair(diag::note_protected_by_non_trivial_c_struct_init,
171 diag::note_exits_dtor);
174 OutDiag = diag::note_exits_dtor;
184 if (
const Expr *
Init = VD->getInit();
185 !InDiag && VD->hasLocalStorage() &&
Init && !
Init->containsErrors()) {
200 InDiag = diag::note_protected_by_variable_init;
210 InDiag = diag::note_protected_by_variable_nontriv_destructor;
212 InDiag = diag::note_protected_by_variable_non_pod;
223 if (TD->getUnderlyingType()->isVariablyModifiedType())
225 ? diag::note_protected_by_vla_typedef
226 : diag::note_protected_by_vla_type_alias,
234void JumpScopeChecker::BuildScopeInformation(Decl *D,
unsigned &ParentScope) {
237 if (Diags.first || Diags.second) {
238 Scopes.push_back(GotoScope(ParentScope, Diags.first, Diags.second,
240 ParentScope = Scopes.size()-1;
245 if (VarDecl *VD = dyn_cast<VarDecl>(D))
246 if (Expr *
Init = VD->getInit())
247 BuildScopeInformation(
Init, ParentScope);
251void JumpScopeChecker::BuildScopeInformation(VarDecl *D,
252 const BlockDecl *BDecl,
253 unsigned &ParentScope) {
261 std::pair<unsigned,unsigned> Diags;
262 switch (destructKind) {
264 Diags =
ScopePair(diag::note_enters_block_captures_cxx_obj,
265 diag::note_exits_block_captures_cxx_obj);
268 Diags =
ScopePair(diag::note_enters_block_captures_strong,
269 diag::note_exits_block_captures_strong);
272 Diags =
ScopePair(diag::note_enters_block_captures_weak,
273 diag::note_exits_block_captures_weak);
276 Diags =
ScopePair(diag::note_enters_block_captures_non_trivial_c_struct,
277 diag::note_exits_block_captures_non_trivial_c_struct);
280 llvm_unreachable(
"non-lifetime captured variable");
285 Scopes.push_back(GotoScope(ParentScope,
286 Diags.first, Diags.second, Loc));
287 ParentScope = Scopes.size()-1;
293void JumpScopeChecker::BuildScopeInformation(CompoundLiteralExpr *CLE,
294 unsigned &ParentScope) {
295 unsigned InDiag = diag::note_enters_compound_literal_scope;
296 unsigned OutDiag = diag::note_exits_compound_literal_scope;
297 Scopes.push_back(GotoScope(ParentScope, InDiag, OutDiag, CLE->
getExprLoc()));
298 ParentScope = Scopes.size() - 1;
305void JumpScopeChecker::BuildScopeInformation(Stmt *S,
306 unsigned &origParentScope) {
310 unsigned independentParentScope = origParentScope;
312 ? origParentScope : independentParentScope);
314 unsigned StmtsToSkip = 0u;
318 case Stmt::AddrLabelExprClass:
322 case Stmt::ObjCForCollectionStmtClass: {
324 unsigned Diag = diag::note_protected_by_objc_fast_enumeration;
325 unsigned NewParentScope = Scopes.size();
327 BuildScopeInformation(CS->getBody(), NewParentScope);
331 case Stmt::IndirectGotoStmtClass:
338 goto RecordJumpScope;
340 LabelAndGotoScopes[S] = ParentScope;
341 IndirectJumps.push_back(S);
344 case Stmt::SwitchStmtClass:
348 BuildScopeInformation(
Init, ParentScope);
352 BuildScopeInformation(Var, ParentScope);
355 goto RecordJumpScope;
357 case Stmt::GCCAsmStmtClass:
362 case Stmt::GotoStmtClass:
366 LabelAndGotoScopes[S] = ParentScope;
370 case Stmt::IfStmtClass: {
376 unsigned Diag = diag::note_protected_by_if_available;
378 Diag = diag::note_protected_by_constexpr_if;
380 Diag = diag::note_protected_by_consteval_if;
383 BuildScopeInformation(Var, ParentScope);
386 unsigned NewParentScope = Scopes.size();
390 BuildScopeInformation(IS->
getCond(), NewParentScope);
393 NewParentScope = Scopes.size();
395 BuildScopeInformation(IS->
getThen(), NewParentScope);
396 if (Stmt *Else = IS->
getElse()) {
397 NewParentScope = Scopes.size();
399 BuildScopeInformation(Else, NewParentScope);
404 case Stmt::CXXTryStmtClass: {
407 unsigned NewParentScope = Scopes.size();
408 Scopes.push_back(GotoScope(ParentScope,
409 diag::note_protected_by_cxx_try,
410 diag::note_exits_cxx_try,
413 BuildScopeInformation(TryBlock, NewParentScope);
419 unsigned NewParentScope = Scopes.size();
420 Scopes.push_back(GotoScope(ParentScope,
421 diag::note_protected_by_cxx_catch,
422 diag::note_exits_cxx_catch,
429 case Stmt::SEHTryStmtClass: {
432 unsigned NewParentScope = Scopes.size();
433 Scopes.push_back(GotoScope(ParentScope,
434 diag::note_protected_by_seh_try,
435 diag::note_exits_seh_try,
438 BuildScopeInformation(TryBlock, NewParentScope);
443 unsigned NewParentScope = Scopes.size();
444 Scopes.push_back(GotoScope(ParentScope,
445 diag::note_protected_by_seh_except,
446 diag::note_exits_seh_except,
447 Except->getSourceRange().getBegin()));
448 BuildScopeInformation(Except->getBlock(), NewParentScope);
450 unsigned NewParentScope = Scopes.size();
451 Scopes.push_back(GotoScope(ParentScope,
452 diag::note_protected_by_seh_finally,
453 diag::note_exits_seh_finally,
454 Finally->getSourceRange().getBegin()));
455 BuildScopeInformation(Finally->getBlock(), NewParentScope);
461 case Stmt::DeclStmtClass: {
467 for (
auto *I : DS->
decls())
468 BuildScopeInformation(I, origParentScope);
472 case Stmt::StmtExprClass: {
479 unsigned NewParentScope = Scopes.size();
480 Scopes.push_back(GotoScope(ParentScope,
481 diag::note_enters_statement_expression,
483 BuildScopeInformation(SE->
getSubStmt(), NewParentScope);
487 case Stmt::ObjCAtTryStmtClass: {
493 unsigned NewParentScope = Scopes.size();
494 Scopes.push_back(GotoScope(ParentScope,
495 diag::note_protected_by_objc_try,
496 diag::note_exits_objc_try,
499 BuildScopeInformation(TryPart, NewParentScope);
504 unsigned NewParentScope = Scopes.size();
505 Scopes.push_back(GotoScope(ParentScope,
506 diag::note_protected_by_objc_catch,
507 diag::note_exits_objc_catch,
508 AC->getAtCatchLoc()));
510 BuildScopeInformation(AC->getCatchBody(), NewParentScope);
515 unsigned NewParentScope = Scopes.size();
516 Scopes.push_back(GotoScope(ParentScope,
517 diag::note_protected_by_objc_finally,
518 diag::note_exits_objc_finally,
519 AF->getAtFinallyLoc()));
520 BuildScopeInformation(AF, NewParentScope);
526 case Stmt::ObjCAtSynchronizedStmtClass: {
536 unsigned NewParentScope = Scopes.size();
537 Scopes.push_back(GotoScope(ParentScope,
538 diag::note_protected_by_objc_synchronized,
539 diag::note_exits_objc_synchronized,
541 BuildScopeInformation(AS->
getSynchBody(), NewParentScope);
545 case Stmt::ObjCAutoreleasePoolStmtClass: {
550 unsigned NewParentScope = Scopes.size();
551 Scopes.push_back(GotoScope(ParentScope,
552 diag::note_protected_by_objc_autoreleasepool,
553 diag::note_exits_objc_autoreleasepool,
555 BuildScopeInformation(AS->
getSubStmt(), NewParentScope);
559 case Stmt::ExprWithCleanupsClass: {
564 for (
unsigned i = 0, e = EWC->
getNumObjects(); i != e; ++i) {
565 if (
auto *BDecl = dyn_cast<BlockDecl *>(EWC->
getObject(i)))
566 for (
const auto &CI : BDecl->
captures()) {
567 VarDecl *variable = CI.getVariable();
568 BuildScopeInformation(variable, BDecl, origParentScope);
570 else if (
auto *CLE = dyn_cast<CompoundLiteralExpr *>(EWC->
getObject(i)))
571 BuildScopeInformation(CLE, origParentScope);
573 llvm_unreachable(
"unexpected cleanup object type");
578 case Stmt::MaterializeTemporaryExprClass: {
583 const Expr *ExtendedObject =
586 Scopes.push_back(GotoScope(ParentScope, 0,
587 diag::note_exits_temporary_dtor,
589 origParentScope = Scopes.size()-1;
595 case Stmt::DeferStmtClass: {
600 unsigned NewParentScope = Scopes.size();
601 Scopes.emplace_back(ParentScope, diag::note_protected_by_defer_stmt, 0,
603 origParentScope = NewParentScope;
608 unsigned NewParentScope = Scopes.size();
609 Scopes.emplace_back(ParentScope, diag::note_enters_defer_stmt,
610 diag::note_exits_defer_stmt, D->getDeferLoc());
611 BuildScopeInformation(D->
getBody(), NewParentScope);
616 case Stmt::CaseStmtClass:
617 case Stmt::DefaultStmtClass:
618 case Stmt::LabelStmtClass:
619 LabelAndGotoScopes[S] = ParentScope;
622 case Stmt::OpenACCComputeConstructClass: {
623 unsigned NewParentScope = Scopes.size();
625 Scopes.push_back(GotoScope(
626 ParentScope, diag::note_acc_branch_into_compute_construct,
627 diag::note_acc_branch_out_of_compute_construct, CC->getBeginLoc()));
630 if (CC->getStructuredBlock())
631 BuildScopeInformation(CC->getStructuredBlock(), NewParentScope);
635 case Stmt::OpenACCCombinedConstructClass: {
636 unsigned NewParentScope = Scopes.size();
638 Scopes.push_back(GotoScope(
639 ParentScope, diag::note_acc_branch_into_compute_construct,
640 diag::note_acc_branch_out_of_compute_construct, CC->getBeginLoc()));
644 BuildScopeInformation(CC->
getLoop(), NewParentScope);
649 if (
auto *ED = dyn_cast<OMPExecutableDirective>(S)) {
650 if (!ED->isStandaloneDirective()) {
651 unsigned NewParentScope = Scopes.size();
652 Scopes.emplace_back(ParentScope,
653 diag::note_omp_protected_structured_block,
654 diag::note_omp_exits_structured_block,
655 ED->getStructuredBlock()->getBeginLoc());
656 BuildScopeInformation(ED->getStructuredBlock(), NewParentScope);
663 for (Stmt *SubStmt : S->
children()) {
676 if (SwitchCase *SC = dyn_cast<SwitchCase>(SubStmt))
677 Next = SC->getSubStmt();
678 else if (LabelStmt *LS = dyn_cast<LabelStmt>(SubStmt))
679 Next = LS->getSubStmt();
680 else if (AttributedStmt *AS = dyn_cast<AttributedStmt>(SubStmt)) {
681 if (GetMustTailAttr(AS)) {
682 LabelAndGotoScopes[AS] = ParentScope;
683 MustTailStmts.push_back(AS);
689 LabelAndGotoScopes[SubStmt] = ParentScope;
694 BuildScopeInformation(SubStmt, ParentScope);
700void JumpScopeChecker::VerifyJumps() {
701 while (!Jumps.empty()) {
702 Stmt *Jump = Jumps.pop_back_val();
705 if (GotoStmt *GS = dyn_cast<GotoStmt>(Jump)) {
707 if (GS->getLabel()->getStmt()) {
708 CheckJump(GS, GS->getLabel()->getStmt(), GS->getGotoLoc(),
709 diag::err_goto_into_protected_scope,
710 diag::ext_goto_into_protected_scope,
711 S.getLangOpts().CPlusPlus
712 ? diag::warn_cxx98_compat_goto_into_protected_scope
713 : diag::warn_cpp_compat_goto_into_protected_scope);
724 if (
auto *G = dyn_cast<GCCAsmStmt>(Jump)) {
725 for (AddrLabelExpr *L : G->labels()) {
726 LabelDecl *LD = L->getLabel();
727 unsigned JumpScope = LabelAndGotoScopes[G];
728 unsigned TargetScope = LabelAndGotoScopes[LD->
getStmt()];
729 if (JumpScope != TargetScope)
730 DiagnoseIndirectOrAsmJump(G, JumpScope, LD, TargetScope);
736 if (IndirectGotoStmt *IGS = dyn_cast<IndirectGotoStmt>(Jump)) {
737 LabelDecl *
Target = IGS->getConstantTarget();
738 CheckJump(IGS,
Target->getStmt(), IGS->getGotoLoc(),
739 diag::err_goto_into_protected_scope,
740 diag::ext_goto_into_protected_scope,
741 S.getLangOpts().CPlusPlus
742 ? diag::warn_cxx98_compat_goto_into_protected_scope
743 : diag::warn_cpp_compat_goto_into_protected_scope);
753 if (CaseStmt *CS = dyn_cast<CaseStmt>(SC))
755 else if (DefaultStmt *DS = dyn_cast<DefaultStmt>(SC))
758 Loc = SC->getBeginLoc();
759 CheckJump(SS, SC, Loc, diag::err_switch_into_protected_scope, 0,
760 S.getLangOpts().CPlusPlus
761 ? diag::warn_cxx98_compat_switch_into_protected_scope
762 : diag::warn_cpp_compat_switch_into_protected_scope);
784void JumpScopeChecker::VerifyIndirectJumps() {
785 if (IndirectJumps.empty())
789 if (IndirectJumpTargets.empty()) {
790 S.Diag(IndirectJumps[0]->getBeginLoc(),
791 diag::err_indirect_goto_without_addrlabel);
797 using JumpScope = std::pair<unsigned, Stmt *>;
798 SmallVector<JumpScope, 32> JumpScopes;
800 llvm::DenseMap<unsigned, Stmt*> JumpScopesMap;
801 for (Stmt *IG : IndirectJumps) {
804 unsigned IGScope = LabelAndGotoScopes[IG];
805 JumpScopesMap.try_emplace(IGScope, IG);
807 JumpScopes.reserve(JumpScopesMap.size());
808 for (
auto &Pair : JumpScopesMap)
809 JumpScopes.emplace_back(Pair);
815 llvm::DenseMap<unsigned, LabelDecl*> TargetScopes;
816 for (LabelDecl *TheLabel : IndirectJumpTargets) {
819 unsigned LabelScope = LabelAndGotoScopes[TheLabel->getStmt()];
820 TargetScopes.try_emplace(LabelScope, TheLabel);
831 llvm::BitVector Reachable(Scopes.size(),
false);
832 for (
auto [TargetScope, TargetLabel] : TargetScopes) {
838 unsigned Min = TargetScope;
846 if (Scopes[
Min].InDiag)
break;
848 Min = Scopes[
Min].ParentScope;
853 for (
auto [JumpScope, JumpStmt] : JumpScopes) {
854 unsigned Scope = JumpScope;
860 bool IsReachable =
false;
862 if (Reachable.test(Scope)) {
865 for (
unsigned S = JumpScope; S != Scope; S = Scopes[S].ParentScope)
873 if (Scope == 0 || Scope <
Min)
break;
876 if (Scopes[Scope].OutDiag)
break;
878 Scope = Scopes[Scope].ParentScope;
882 if (IsReachable)
continue;
884 DiagnoseIndirectOrAsmJump(JumpStmt, JumpScope, TargetLabel, TargetScope);
892 return (JumpDiag == diag::err_goto_into_protected_scope &&
893 (InDiagNote == diag::note_protected_by_variable_init ||
894 InDiagNote == diag::note_protected_by_variable_nontriv_destructor));
901 InDiagNote == diag::note_protected_by_variable_non_pod;
908 InDiagNote == diag::note_protected_by_variable_init;
917 S.
Diag(Jump->
getBeginLoc(), diag::err_indirect_goto_in_protected_scope)
919 S.
Diag(
Target->getStmt()->getIdentLoc(), diag::note_indirect_goto_target)
925void JumpScopeChecker::NoteJumpIntoScopes(ArrayRef<unsigned> ToScopes) {
928 for (
unsigned I = 0, E = ToScopes.size(); I != E; ++I)
929 if (Scopes[ToScopes[I]].InDiag)
930 S.Diag(Scopes[ToScopes[I]].Loc, Scopes[ToScopes[I]].InDiag);
934void JumpScopeChecker::DiagnoseIndirectOrAsmJump(Stmt *Jump,
unsigned JumpScope,
936 unsigned TargetScope) {
940 unsigned Common = GetDeepestCommonScope(JumpScope, TargetScope);
941 bool Diagnosed =
false;
944 for (
unsigned I = JumpScope; I != Common; I = Scopes[I].ParentScope)
945 if (Scopes[I].OutDiag) {
947 S.Diag(Scopes[I].Loc, Scopes[I].OutDiag);
950 SmallVector<unsigned, 10> ToScopesCXX98Compat, ToScopesCppCompat;
953 for (
unsigned I = TargetScope; I != Common; I = Scopes[I].ParentScope)
955 ToScopesCXX98Compat.push_back(I);
957 ToScopesCppCompat.push_back(I);
958 else if (Scopes[I].InDiag) {
960 S.Diag(Scopes[I].Loc, Scopes[I].InDiag);
966 auto Diag = [&](
unsigned DiagId,
const SmallVectorImpl<unsigned> &Notes) {
968 S.Diag(
Target->getStmt()->getIdentLoc(), diag::note_indirect_goto_target)
970 NoteJumpIntoScopes(Notes);
972 if (!ToScopesCXX98Compat.empty())
973 Diag(diag::warn_cxx98_compat_indirect_goto_in_protected_scope,
974 ToScopesCXX98Compat);
975 else if (!ToScopesCppCompat.empty())
976 Diag(diag::warn_cpp_compat_indirect_goto_in_protected_scope,
983void JumpScopeChecker::CheckJump(Stmt *From, Stmt *To, SourceLocation DiagLoc,
984 unsigned JumpDiagError,
985 unsigned JumpDiagWarning,
986 unsigned JumpDiagCompat) {
992 unsigned FromScope = LabelAndGotoScopes[From];
993 unsigned ToScope = LabelAndGotoScopes[To];
996 if (FromScope == ToScope)
return;
1002 for (
unsigned I = FromScope; I > ToScope; I = Scopes[I].ParentScope) {
1003 if (Scopes[I].InDiag == diag::note_protected_by_seh_finally) {
1004 S.Diag(From->
getBeginLoc(), diag::warn_jump_out_of_seh_finally);
1006 }
else if (Scopes[I].InDiag ==
1007 diag::note_omp_protected_structured_block) {
1008 S.Diag(From->
getBeginLoc(), diag::err_goto_into_protected_scope);
1009 S.Diag(To->
getBeginLoc(), diag::note_omp_exits_structured_block);
1011 }
else if (Scopes[I].InDiag ==
1012 diag::note_acc_branch_into_compute_construct) {
1013 S.Diag(From->
getBeginLoc(), diag::err_goto_into_protected_scope);
1014 S.Diag(Scopes[I].Loc, diag::note_acc_branch_out_of_compute_construct);
1016 }
else if (Scopes[I].OutDiag == diag::note_exits_defer_stmt) {
1017 S.Diag(From->
getBeginLoc(), diag::err_goto_into_protected_scope);
1018 S.Diag(Scopes[I].Loc, diag::note_exits_defer_stmt);
1024 unsigned CommonScope = GetDeepestCommonScope(FromScope, ToScope);
1027 if (CommonScope == ToScope)
return;
1030 SmallVector<unsigned, 10> ToScopesCompat;
1031 SmallVector<unsigned, 10> ToScopesError;
1032 SmallVector<unsigned, 10> ToScopesWarning;
1033 for (
unsigned I = ToScope; I != CommonScope; I = Scopes[I].ParentScope) {
1034 if (S.getLangOpts().MSVCCompat && S.getLangOpts().CPlusPlus &&
1035 JumpDiagWarning != 0 &&
1037 ToScopesWarning.push_back(I);
1040 ToScopesCompat.push_back(I);
1041 else if (Scopes[I].InDiag)
1042 ToScopesError.push_back(I);
1046 if (!ToScopesWarning.empty()) {
1047 S.Diag(DiagLoc, JumpDiagWarning);
1048 NoteJumpIntoScopes(ToScopesWarning);
1055 if (!ToScopesError.empty()) {
1056 S.Diag(DiagLoc, JumpDiagError);
1057 NoteJumpIntoScopes(ToScopesError);
1061 if (ToScopesError.empty() && !ToScopesCompat.empty()) {
1062 S.Diag(DiagLoc, JumpDiagCompat);
1063 NoteJumpIntoScopes(ToScopesCompat);
1067void JumpScopeChecker::CheckGotoStmt(GotoStmt *GS) {
1069 S.Diag(GS->
getGotoLoc(), diag::err_goto_ms_asm_label)
1076void JumpScopeChecker::VerifyMustTailStmts() {
1077 for (AttributedStmt *AS : MustTailStmts) {
1078 for (
unsigned I = LabelAndGotoScopes[AS]; I; I = Scopes[I].ParentScope) {
1079 if (Scopes[I].OutDiag) {
1080 S.Diag(AS->
getBeginLoc(), diag::err_musttail_scope);
1081 S.Diag(Scopes[I].Loc, Scopes[I].OutDiag);
1087const Attr *JumpScopeChecker::GetMustTailAttr(AttributedStmt *AS) {
1088 ArrayRef<const Attr *> Attrs = AS->
getAttrs();
1091 return Iter != Attrs.end() ? *Iter :
nullptr;
1095 (void)JumpScopeChecker(Body, *
this);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
std::pair< unsigned, unsigned > ScopePair
static ScopePair GetDiagForGotoScopeDecl(Sema &S, const Decl *D)
GetDiagForGotoScopeDecl - If this decl induces a new goto scope, return a diagnostic that should be e...
static bool IsCXX98CompatWarning(Sema &S, unsigned InDiagNote)
Return true if a particular note should be downgraded to a compatibility warning in C++11 mode.
static bool IsMicrosoftJumpWarning(unsigned JumpDiag, unsigned InDiagNote)
Return true if a particular error+note combination must be downgraded to a warning in Microsoft mode.
static bool IsCppCompatWarning(Sema &S, unsigned InDiagNote)
Returns true if a particular note should be a C++ compatibility warning in C mode with -Wc++-compat.
#define CHECK_PERMISSIVE(x)
static void DiagnoseIndirectOrAsmJumpStmt(Sema &S, Stmt *Jump, LabelDecl *Target, bool &Diagnosed)
Produce primary diagnostic for an indirect jump statement.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
Defines the clang::SourceLocation class and associated facilities.
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
__device__ __2f16 float __ockl_bool s
ArrayRef< const Attr * > getAttrs() const
ArrayRef< Capture > captures() const
Stmt * getHandlerBlock() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
CompoundStmt * getTryBlock()
SourceLocation getBeginLoc() const LLVM_READONLY
Decl - This represents one declaration (or definition), e.g.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
SourceLocation getLocation() const
CleanupObject getObject(unsigned i) const
unsigned getNumObjects() const
This represents one expression.
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr * > &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
SourceLocation getGotoLoc() const
LabelDecl * getLabel() const
bool isObjCAvailabilityCheck() const
SourceLocation getBeginLoc() const
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
Represents the declaration of a label.
LabelStmt * getStmt() const
bool isMSAsmLabel() const
void setSideEntry(bool SE)
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
const Expr * getSynchExpr() const
const CompoundStmt * getSynchBody() const
SourceLocation getAtSynchronizedLoc() const
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
const Stmt * getTryBody() const
Retrieve the @try body.
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
catch_range catch_stmts()
SourceLocation getAtLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
const Stmt * getSubStmt() const
@ DK_objc_strong_lifetime
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
CompoundStmt * getTryBlock() const
SEHFinallyStmt * getFinallyHandler() const
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Sema - This implements semantic analysis and AST building for C.
const LangOptions & getLangOpts() const
void DiagnoseInvalidJumps(Stmt *Body)
Encodes a location in the source.
SourceLocation getBegin() const
CompoundStmt * getSubStmt()
SourceLocation getBeginLoc() const LLVM_READONLY
Stmt - This represents one statement.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
const SwitchCase * getNextSwitchCase() const
SwitchCase * getSwitchCaseList()
Base class for declarations which introduce a typedef-name.
Represents a variable declaration or definition.
@ CallInit
Call-style initialization (C++98)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
@ SD_Automatic
Automatic storage duration (most local variables).
const FunctionProtoType * T
U cast(CodeGen::Address addr)