Deleted Added
full compact
JumpDiagnostics.cpp (194613) JumpDiagnostics.cpp (195341)
1//===--- JumpDiagnostics.cpp - Analyze Jump Targets for VLA issues --------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 63 unchanged lines hidden (view full) ---

72 BuildScopeInformation(Body, 0);
73
74 // Check that all jumps we saw are kosher.
75 VerifyJumps();
76}
77
78/// GetDiagForGotoScopeDecl - If this decl induces a new goto scope, return a
79/// diagnostic that should be emitted if control goes over it. If not, return 0.
1//===--- JumpDiagnostics.cpp - Analyze Jump Targets for VLA issues --------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 63 unchanged lines hidden (view full) ---

72 BuildScopeInformation(Body, 0);
73
74 // Check that all jumps we saw are kosher.
75 VerifyJumps();
76}
77
78/// GetDiagForGotoScopeDecl - If this decl induces a new goto scope, return a
79/// diagnostic that should be emitted if control goes over it. If not, return 0.
80static unsigned GetDiagForGotoScopeDecl(ASTContext &Context, const Decl *D) {
80static unsigned GetDiagForGotoScopeDecl(const Decl *D) {
81 if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
82 if (VD->getType()->isVariablyModifiedType())
83 return diag::note_protected_by_vla;
81 if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
82 if (VD->getType()->isVariablyModifiedType())
83 return diag::note_protected_by_vla;
84 if (VD->hasAttr<CleanupAttr>(Context))
84 if (VD->hasAttr())
85 return diag::note_protected_by_cleanup;
86 } else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
87 if (TD->getUnderlyingType()->isVariablyModifiedType())
88 return diag::note_protected_by_vla_typedef;
89 }
90
91 return 0;
92}

--- 27 unchanged lines hidden (view full) ---

120 // If this is a declstmt with a VLA definition, it defines a scope from here
121 // to the end of the containing context.
122 if (DeclStmt *DS = dyn_cast<DeclStmt>(SubStmt)) {
123 // The decl statement creates a scope if any of the decls in it are VLAs or
124 // have the cleanup attribute.
125 for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end();
126 I != E; ++I) {
127 // If this decl causes a new scope, push and switch to it.
85 return diag::note_protected_by_cleanup;
86 } else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
87 if (TD->getUnderlyingType()->isVariablyModifiedType())
88 return diag::note_protected_by_vla_typedef;
89 }
90
91 return 0;
92}

--- 27 unchanged lines hidden (view full) ---

120 // If this is a declstmt with a VLA definition, it defines a scope from here
121 // to the end of the containing context.
122 if (DeclStmt *DS = dyn_cast<DeclStmt>(SubStmt)) {
123 // The decl statement creates a scope if any of the decls in it are VLAs or
124 // have the cleanup attribute.
125 for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end();
126 I != E; ++I) {
127 // If this decl causes a new scope, push and switch to it.
128 if (unsigned Diag = GetDiagForGotoScopeDecl(this->S.Context, *I)) {
128 if (unsigned Diag = GetDiagForGotoScopeDecl(*I)) {
129 Scopes.push_back(GotoScope(ParentScope, Diag, (*I)->getLocation()));
130 ParentScope = Scopes.size()-1;
131 }
132
133 // If the decl has an initializer, walk it with the potentially new
134 // scope we just installed.
135 if (VarDecl *VD = dyn_cast<VarDecl>(*I))
136 if (Expr *Init = VD->getInit())

--- 191 unchanged lines hidden ---
129 Scopes.push_back(GotoScope(ParentScope, Diag, (*I)->getLocation()));
130 ParentScope = Scopes.size()-1;
131 }
132
133 // If the decl has an initializer, walk it with the potentially new
134 // scope we just installed.
135 if (VarDecl *VD = dyn_cast<VarDecl>(*I))
136 if (Expr *Init = VD->getInit())

--- 191 unchanged lines hidden ---