Skip to content

Commit

Permalink
Remove optional braces in control statements
Browse files Browse the repository at this point in the history
  • Loading branch information
vaithak committed Aug 8, 2023
1 parent 56fe2ae commit 0a6ce09
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ BasedOnStyle: LLVM
Language: Cpp
Standard: Cpp11
PointerAlignment: Left
RemoveBracesLLVM: true

IncludeCategories:
- Regex: '^"[^/]+\"'
Expand Down
3 changes: 1 addition & 2 deletions demos/VectorForwardMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
// A function for weighted sum of array elements.
double weighted_sum(double* arr, double* weights, int n) {
double res = 0;
for (int i = 0; i < n; ++i) {
for (int i = 0; i < n; ++i)
res += weights[i] * arr[i];
}
return res;
}

Expand Down
13 changes: 5 additions & 8 deletions lib/Differentiator/VectorForwardModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ VectorForwardModeVisitor::DeriveVectorMode(const FunctionDecl* FD,
// -> clad::array<double> _d_vector_y = {0, 0};
// -> clad::array<double> _d_vector_z = {0, 1};
QualType dVectorParamType;
if (is_array) {
if (is_array)
dVectorParamType = GetCladMatrixOfType(dParamType);
} else {
else
dVectorParamType = GetCladArrayOfType(dParamType);
}
auto dVectorParamDecl =
BuildVarDecl(dVectorParamType, "_d_vector_" + param->getNameAsString(),
dVectorParam);
Expand Down Expand Up @@ -239,9 +238,8 @@ clang::FunctionDecl* VectorForwardModeVisitor::CreateVectorModeOverload() {
QualType outputParamType = GetCladArrayRefOfType(m_Context.VoidTy);

// Push param types for derived params.
for (std::size_t i = 0; i < m_Function->getNumParams(); ++i) {
for (std::size_t i = 0; i < m_Function->getNumParams(); ++i)
paramTypes.push_back(outputParamType);
}

auto vectorModeFuncOverloadEPI =
dyn_cast<FunctionProtoType>(m_Function->getType())->getExtProtoInfo();
Expand Down Expand Up @@ -499,12 +497,11 @@ StmtDiff VectorForwardModeVisitor::VisitReturnStmt(const ReturnStmt* RS) {
Expr* offsetExpr = arrayIndVarCountExpr;
Expr* nonArrayIndVarCountExpr = ConstantFolder::synthesizeLiteral(
m_Context.UnsignedLongTy, m_Context, nonArrayIndVarCount);
if (!offsetExpr) {
if (!offsetExpr)
offsetExpr = nonArrayIndVarCountExpr;
} else if (nonArrayIndVarCount != 0) {
else if (nonArrayIndVarCount != 0)
offsetExpr = BuildOp(BinaryOperatorKind::BO_Add, offsetExpr,
nonArrayIndVarCountExpr);
}

if (isCladArrayType(dParam->getType())) {
// Get the size of the array.
Expand Down

0 comments on commit 0a6ce09

Please sign in to comment.