Skip to content

Commit 62f85dd

Browse files
committed
chore(output): improve the output logs
1 parent 4839eb5 commit 62f85dd

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

‎src/StackUsageAnalyzer.cpp‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define INFO_OUTPUT "[!Info!]"
4141
#define WARN_OUTPUT "[ !!Warn ]"
4242
#define ERROR_OUTPUT "[!!!Error]"
43+
#define TAB_OUTPUT "\t\t ↳ "
4344

4445
namespace ctrace::stack
4546
{
@@ -1198,7 +1199,7 @@ namespace ctrace::stack
11981199

11991200
std::ostringstream body;
12001201

1201-
body << "\t[ !!Warn ] stack pointer escape: address of variable '" << e.varName
1202+
body << "\t" << WARN_OUTPUT << " stack pointer escape: address of variable '" << e.varName
12021203
<< "' escapes this function\n";
12031204

12041205
if (e.escapeKind == "return")
@@ -1271,11 +1272,11 @@ namespace ctrace::stack
12711272
diag.severity = DiagnosticSeverity::Info;
12721273
diag.errCode = DescriptiveErrorCode::ConstParameterNotModified;
12731274

1274-
const char* prefix = "[!]";
1275+
const char* prefix = INFO_OUTPUT;
12751276
if (diag.severity == DiagnosticSeverity::Warning)
1276-
prefix = "[ !!Warn ]";
1277+
prefix = WARN_OUTPUT;
12771278
else if (diag.severity == DiagnosticSeverity::Error)
1278-
prefix = "[!!!]";
1279+
prefix = ERROR_OUTPUT;
12791280

12801281
const char* subLabel = "Pointer";
12811282
if (cp.pointerConstOnly)
@@ -1289,35 +1290,35 @@ namespace ctrace::stack
12891290

12901291
if (cp.isRvalueRef)
12911292
{
1292-
body << " " << prefix << "ConstParameterNotModified." << subLabel
1293+
body << "\t" << prefix << " ConstParameterNotModified." << subLabel
12931294
<< ": parameter '" << cp.paramName << "' in function '" << displayFuncName
12941295
<< "' is an rvalue reference and is never used to modify the referred "
12951296
"object\n";
1296-
body << " consider passing by value (" << cp.suggestedType
1297+
body << TAB_OUTPUT << "consider passing by value (" << cp.suggestedType
12971298
<< ") or const reference (" << cp.suggestedTypeAlt << ")\n";
1298-
body << " current type: " << cp.currentType << "\n";
1299+
body << TAB_OUTPUT << "current type: " << cp.currentType << "\n";
12991300
}
13001301
else if (cp.pointerConstOnly)
13011302
{
1302-
body << " " << prefix << "ConstParameterNotModified." << subLabel
1303+
body << "\t" << prefix << " ConstParameterNotModified." << subLabel
13031304
<< ": parameter '" << cp.paramName << "' in function '" << displayFuncName
13041305
<< "' is declared '" << cp.currentType
13051306
<< "' but the pointed object is never modified\n";
1306-
body << " consider '" << cp.suggestedType
1307+
body << TAB_OUTPUT << "consider '" << cp.suggestedType
13071308
<< "' for API const-correctness\n";
13081309
}
13091310
else
13101311
{
1311-
body << " " << prefix << "ConstParameterNotModified." << subLabel
1312+
body << "\t" << prefix << " ConstParameterNotModified." << subLabel
13121313
<< ": parameter '" << cp.paramName << "' in function '" << displayFuncName
13131314
<< "' is never used to modify the "
13141315
<< (cp.isReference ? "referred" : "pointed") << " object\n";
13151316
}
13161317

13171318
if (!cp.isRvalueRef)
13181319
{
1319-
body << " current type: " << cp.currentType << "\n";
1320-
body << " suggested type: " << cp.suggestedType << "\n";
1320+
body << TAB_OUTPUT << "current type: " << cp.currentType << "\n";
1321+
body << TAB_OUTPUT << "suggested type: " << cp.suggestedType << "\n";
13211322
}
13221323

13231324
diag.funcName = cp.funcName;

0 commit comments

Comments
 (0)