Looking for a tool to reformat C / C++ source code capable of adding braces in "if" and "while" statements

Hello.

I am looking for a source code rewriting tool to change the format of the source code, such as “clang-format”, “indent”, but that allow to add braces in “if” and “while” statements when in the source code only affect a single statement that is not surrounded by braces.

I don’t know if I missed something in the documentation for “clang-format” and “indent”, but in those programs I have not been able to find an option to add braces. I’ve seen options to choose the position of existing braces, but not to add braces when the original source code doesn’t have them.

Kind regads,
Oscar

I got using astyle:

astyle --style=allman --add-brackets ttserver.c

In my own software language PPL for operators “for”,“if”, “else” it is not needed curly bracket if block statement contains only 1 single statement.
for ex,:

if (x = 1)
write#(“something”);

The following part of code from my soft adds curly bracket before creation Tree.
I do not sure that all will be clear for you (written in C#):

case “if”:
{
if (CheckBlockInCurlyBrackets(input.Substring(i + 1), “if”) == false)
{
ppl.print(“Error: [TCreateCodeTree] block in ‘if’ must be in curly brackets”);
return null;
}
string condition;
int min_index = 0;
int indexes = GetIndexCharacters(input.Substring(i), new char { ‘;’, ‘{’, ‘}’ }, ref min_index);
int EndBlock = 0;
if (min_index == 0) // first stmt ‘;’ , without block{…}
{ // add {…} around first statement
string tmp = input.Substring(i + 1);
condition = tnot_tran.GetContents(tmp, ‘(’, ‘)’, ref EndBlock);

  int index_finalyzer = tmp.IndexOf(';');
    string tmp02 = tmp.Substring(EndBlock + 1);
    //string statement_true = tmp.Substring(EndBlock + 1, index_finalyzer - EndBlock);
    string statement_true = tmp02.Substring(0,index_finalyzer - EndBlock);
    statement_true = statement_true.Trim();

  string statement_true_in_curly_brackets = "{" + statement_true + "  }";

  string tmp2 = ReplaceFirst(tmp, statement_true, statement_true_in_curly_brackets);
  input = ReplaceFirst(input, tmp, tmp2);

  array = input.ToCharArray();   //(added characters to input ) 
                                 //     i = 0;
}

bs1 = new BoundarySymbols('(', ')');
bs2 = new BoundarySymbols('{', '}');
bsymbols = new BoundarySymbols[] { bs1, bs2 };

arr_con = GetArrayOfContents(input, ref i, bsymbols);
if (arr_con == null)
{
  CodeTree = null;
  return CodeTree;
}
condition = arr_con[0];
bool b4 = keyword_dict[value](condition, CurrentNode, ref result);
if (b4 == false)
{
  CodeTree = null;
  return CodeTree;
}
comp = new Composite(value, arr_con[0]);
comp.addit_info = result;
CurrentNode.Add(comp);
value = "";
TCreateCodeTree(ref arr_con[1], ref comp);

}
break;

Now PPL code is written in C#, but I convert it to C++, version 20 to increase performanace and for using PPL not only Windows platform. Name of new PPL version is FOREST. It takes a time, because I work without team.

Best Regars
Oscar K.