| 5174 | //----------------------------------------------------------------------------- |
| 5175 | |
| 5176 | void CodeGenerator::WrapInCompoundIfNeeded(const Stmt* stmt, const AddNewLineAfter addNewLineAfter) |
| 5177 | { |
| 5178 | const bool hasNoCompoundStmt = not(isa<CompoundStmt>(stmt) or isa<AttributedStmt>(stmt)); |
| 5179 | |
| 5180 | if(hasNoCompoundStmt) { |
| 5181 | mOutputFormatHelper.OpenScope(); |
| 5182 | } |
| 5183 | |
| 5184 | if(not isa<NullStmt>(stmt)) { |
| 5185 | InsertArg(stmt); |
| 5186 | |
| 5187 | const bool isAttrWithCompound{[&] { |
| 5188 | auto* attrStmt = dyn_cast_or_null<AttributedStmt>(stmt); |
| 5189 | return attrStmt and isa<CompoundStmt>(attrStmt->getSubStmt()); |
| 5190 | }()}; |
| 5191 | |
| 5192 | // Add semi-colon if necessary. A do{} while does already add one. |
| 5193 | if(IsStmtRequiringSemi<IfStmt, CompoundStmt, NullStmt, WhileStmt, DoStmt>(stmt) and not isAttrWithCompound) { |
| 5194 | mOutputFormatHelper.AppendSemiNewLine(); |
| 5195 | } |
| 5196 | } |
| 5197 | |
| 5198 | if(hasNoCompoundStmt) { |
| 5199 | mOutputFormatHelper.CloseScope(OutputFormatHelper::NoNewLineBefore::Yes); |
| 5200 | } |
| 5201 | |
| 5202 | const bool addNewLine = (AddNewLineAfter::Yes == addNewLineAfter); |
| 5203 | if(addNewLine or (hasNoCompoundStmt and addNewLine)) { |
| 5204 | mOutputFormatHelper.AppendNewLine(); |
| 5205 | } else if(not addNewLine or (hasNoCompoundStmt and not addNewLine)) { |
| 5206 | mOutputFormatHelper.Append(' '); |
| 5207 | } |
| 5208 | } |
| 5209 | //----------------------------------------------------------------------------- |
| 5210 | |
| 5211 | void CodeGenerator::WrapInParens(void_func_ref lambda, const AddSpaceAtTheEnd addSpaceAtTheEnd) |
nothing calls this directly
no test coverage detected