NoQ created this revision.
NoQ added reviewers: vsavchenko, xazax.hun, Szelethus, martong,
baloghadamsoftware, Charusso, steakhal, balazske, ASDenysPetrov.
Herald added subscribers: dkrupp, donat.nagy, mikhail.ramalho, a.sidorin,
rnkovacs, szepet.
NoQ requested review of this revision.
This is a cosmetic change. "Dead store" will now be displayed as "Unused code"
which is a nice broad category that could incorporate more than one checker. It
also doesn't mention dead people which despite being a common source of inside
jokes in the static analyzer community doesn't need to be translated onto
innocent users.
There's one more alpha checker that fits into the category, namely
UnreachableCode checker which flags code that wasn't covered by symbolic
execution. I don't immediately plan to actually make this checker useful as it
has to be quite an undertaking.
A broader plan that i have here is that some clang-tidy checks (eg.,
bugprone-redundant-branch-condition or misc-redundant-expression) can be put
into that category through D95403 <https://reviews.llvm.org/D95403>.
Repository:
rC Clang
https://reviews.llvm.org/D98741
Files:
clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
clang/test/Analysis/Inputs/expected-plists/objc-arc.m.plist
clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
Index: clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
===================================================================
--- clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
+++ clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
@@ -2169,7 +2169,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'foo' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -5654,7 +5654,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'x' is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead increment</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
Index: clang/test/Analysis/Inputs/expected-plists/objc-arc.m.plist
===================================================================
--- clang/test/Analysis/Inputs/expected-plists/objc-arc.m.plist
+++ clang/test/Analysis/Inputs/expected-plists/objc-arc.m.plist
@@ -382,7 +382,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'x' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -450,7 +450,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'obj1' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -518,7 +518,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'obj4' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -586,7 +586,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'obj5' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -654,7 +654,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'obj6' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -1064,7 +1064,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'cf1' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -1132,7 +1132,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'cf2' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -1200,7 +1200,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'cf3' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -1268,7 +1268,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'cf4' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
Index: clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
===================================================================
--- clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
+++ clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
@@ -2368,7 +2368,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'x' is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead increment</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
@@ -11409,7 +11409,7 @@
</dict>
</array>
<key>description</key><string>Value stored to 'foo' during its initialization is never read</string>
- <key>category</key><string>Dead store</string>
+ <key>category</key><string>Unused code</string>
<key>type</key><string>Dead initialization</string>
<key>check_name</key><string>deadcode.DeadStores</string>
<!-- This hash is experimental and going to change! -->
Index: clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
+++ clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
@@ -22,6 +22,7 @@
const char *const CXXObjectLifecycle = "C++ object lifecycle";
const char *const CXXMoveSemantics = "C++ move semantics";
const char *const SecurityError = "Security error";
+const char *const UnusedCode = "Unused code";
} // namespace categories
} // namespace ento
} // namespace clang
Index: clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -169,7 +169,7 @@
if (SM.isInSystemHeader(SL) || SM.isInExternCSystemHeader(SL))
continue;
- B.EmitBasicReport(D, this, "Unreachable code", "Dead code",
+ B.EmitBasicReport(D, this, "Unreachable code", categories::UnusedCode,
"This statement is never executed", DL, SR);
}
}
Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -260,8 +260,8 @@
break;
}
- BR.EmitBasicReport(AC->getDecl(), Checker, BugType, "Dead store", os.str(),
- L, R, Fixits);
+ BR.EmitBasicReport(AC->getDecl(), Checker, BugType, categories::UnusedCode,
+ os.str(), L, R, Fixits);
}
void CheckVarDecl(const VarDecl *VD, const Expr *Ex, const Expr *Val,
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
@@ -21,6 +21,7 @@
extern const char *const CXXObjectLifecycle;
extern const char *const CXXMoveSemantics;
extern const char *const SecurityError;
+extern const char *const UnusedCode;
} // namespace categories
} // namespace ento
} // namespace clang
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits