Skip to content

Commit 3267bc0

Browse files
author
Mandeep Singh Grang
authored
[checked-c-convert] Silence compile-time warnings and clean-up code (#671)
1 parent b242b14 commit 3267bc0

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

tools/checked-c-convert/ArrayBoundsInferenceConsumer.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,10 @@ void HandleArrayVariablesBoundsDetection(ASTContext *C, ProgramInfo &I) {
117117
LocalVarABVisitor LVAB(C, I);
118118
TranslationUnitDecl *TUD = C->getTranslationUnitDecl();
119119
for (const auto &D : TUD->decls()) {
120-
if (dyn_cast<FunctionDecl>(D)) {
121-
FunctionDecl *fb = dyn_cast<FunctionDecl>(D);
122120
#ifdef DEBUG
123-
llvm::dbgs() << "Analyzing function:" << fb->getName() << "\n";
121+
if (auto *FB = dyn_cast<FunctionDecl>(D))
122+
llvm::dbgs() << "Analyzing function:" << FB->getName() << "\n";
124123
#endif
125-
}
126124
LVAB.TraverseDecl(D);
127125
}
128-
}
126+
}

tools/checked-c-convert/ConstraintBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class FunctionVisitor : public RecursiveASTVisitor<FunctionVisitor> {
451451

452452
i++;
453453
}
454-
} else if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D))
454+
} else if (isa<DeclaratorDecl>(D))
455455
handleFunctionPointerCall(E);
456456
else
457457
// Constrain all arguments to wild.

tools/checked-c-convert/ConstraintVariables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ PointerVariableConstraint::PointerVariableConstraint(const QualType &QT, Constra
5858
if (InteropTypeExpr *ITE = D->getInteropTypeExpr()) {
5959
// External variables can also have itype. So, check if the provided
6060
// declaration is an external variable.
61-
if (dyn_cast<VarDecl>(D) && dyn_cast<VarDecl>(D)->isExternC()) {
61+
if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExternC()) {
6262
QualType InteropType = C.getInteropTypeAndAdjust(ITE, false);
6363
// TODO: handle array_ptr types.
6464
if (InteropType->isCheckedPointerPtrType()) {

tools/checked-c-convert/Constraints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ bool Constraints::canAssignConst(VarAtom *src) {
166166
// of the provided type.
167167
if (Not *N = dyn_cast<Not>(C))
168168
if (Eq *E = dyn_cast<Eq>(N->getBody()))
169-
if (dyn_cast<T>(E->getRHS()))
169+
if (isa<T>(E->getRHS()))
170170
return false;
171171
}
172172
return true;

tools/checked-c-convert/ProgramInfo.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ ProgramInfo::getVariable(clang::Decl *D, clang::ASTContext *C, bool inFunctionCo
795795

796796
// if this a function declaration
797797
// set in context to false.
798-
if (dyn_cast<FunctionDecl>(D))
798+
if (isa<FunctionDecl>(D))
799799
inFunctionContext = false;
800800

801801
return getVariableOnDemand(D, C, inFunctionContext);
@@ -811,16 +811,16 @@ ProgramInfo::getVariableOnDemand(Decl *D, ASTContext *C, bool inFunctionContext)
811811
// variable, or return value then we should see if we're looking this
812812
// up in the context of a function or not. If we are not, then we
813813
// should find a declaration
814-
ParmVarDecl *PD = nullptr;
815814
FunctionDecl *funcDefinition = nullptr;
816815
FunctionDecl *funcDeclaration = nullptr;
817816
// get the function declaration and definition
818-
if (D != nullptr && dyn_cast<FunctionDecl>(D)) {
819-
funcDeclaration = getDeclaration(dyn_cast<FunctionDecl>(D));
820-
funcDefinition = getDefinition(dyn_cast<FunctionDecl>(D));
817+
if (D != nullptr && isa<FunctionDecl>(D)) {
818+
auto *FDecl = cast<FunctionDecl>(D);
819+
funcDeclaration = getDeclaration(FDecl);
820+
funcDefinition = getDefinition(FDecl);
821821
}
822822
int parameterIndex = -1;
823-
if (PD = dyn_cast<ParmVarDecl>(D)) {
823+
if (auto *PD = dyn_cast<ParmVarDecl>(D)) {
824824
// okay, we got a request for a parameter
825825
DeclContext *DC = PD->getParentFunctionOrMethod();
826826
assert(DC != nullptr);

0 commit comments

Comments
 (0)