diff --git a/.clang-format b/.clang-format index 23d6f8ef5..9d3caf0f5 100644 --- a/.clang-format +++ b/.clang-format @@ -3,6 +3,7 @@ BasedOnStyle: LLVM Language: Cpp Standard: Cpp11 PointerAlignment: Left +RemoveBracesLLVM: true IncludeCategories: - Regex: '^"[^/]+\"' diff --git a/demos/VectorForwardMode.cpp b/demos/VectorForwardMode.cpp index 28661f0ac..af887e4e9 100644 --- a/demos/VectorForwardMode.cpp +++ b/demos/VectorForwardMode.cpp @@ -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; } diff --git a/lib/Differentiator/VectorForwardModeVisitor.cpp b/lib/Differentiator/VectorForwardModeVisitor.cpp index 79760379d..d8bf0cc09 100644 --- a/lib/Differentiator/VectorForwardModeVisitor.cpp +++ b/lib/Differentiator/VectorForwardModeVisitor.cpp @@ -184,11 +184,10 @@ VectorForwardModeVisitor::DeriveVectorMode(const FunctionDecl* FD, // -> clad::array _d_vector_y = {0, 0}; // -> clad::array _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); @@ -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(m_Function->getType())->getExtProtoInfo(); @@ -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.