Skip to content

Commit 8448c26

Browse files
author
Aaron Eline
committed
Fixing comments
1 parent dea4915 commit 8448c26

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

clang/lib/3C/CheckedRegions.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
using namespace llvm;
2727
using namespace clang;
2828

29+
30+
// Check if the compound statement is a function body
31+
// Used in both visitors so abstracted to a function
32+
bool isTopLevel(ASTContext *Context, CompoundStmt *S) {
33+
const auto &Parents = Context->getParents(*S);
34+
if (Parents.empty()) {
35+
return false;
36+
}
37+
// Ensure that our parent is a functiondecl
38+
return Parents[0].get<FunctionDecl>() != nullptr;
39+
}
40+
2941
// CheckedRegionAdder
3042

3143
bool CheckedRegionAdder::VisitCompoundStmt(CompoundStmt *S) {
@@ -93,13 +105,6 @@ CheckedRegionAdder::findParentCompound(const ast_type_traits::DynTypedNode &N,
93105
}
94106

95107

96-
bool isTopLevel(ASTContext *Context, CompoundStmt *S) {
97-
const auto &Parents = Context->getParents(*S);
98-
if (Parents.empty()) {
99-
return false;
100-
}
101-
return Parents[0].get<FunctionDecl>();
102-
}
103108

104109
bool CheckedRegionAdder::isFunctionBody(CompoundStmt *S) {
105110
return isTopLevel(Context, S);
@@ -171,7 +176,7 @@ bool CheckedRegionFinder::VisitCompoundStmt(CompoundStmt *S) {
171176
const auto &Parents = Context->getParents(*S);
172177
assert(!Parents.empty());
173178
FunctionDecl* Parent = const_cast<FunctionDecl*>(Parents[0].get<FunctionDecl>());
174-
assert(Parent != NULL);
179+
assert(Parent != nullptr);
175180
auto retType = Parent->getReturnType().getTypePtr();
176181
if (retType->isPointerType()) {
177182
CVarOption CV = Info.getVariable(Parent, Context);

0 commit comments

Comments
 (0)