Skip to content

[clang-tidy] NO.42-44 enable noexcept-move-constructor,unused-but-set-variable,security.FloatLoopCounter #61555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ clang-analyzer-optin.portability.UnixAPI,
-clang-analyzer-osx.coreFoundation.CFRetainRelease,
-clang-analyzer-osx.coreFoundation.containers.OutOfBounds,
-clang-analyzer-osx.coreFoundation.containers.PointerSizedValues,
-clang-analyzer-security.FloatLoopCounter,
clang-analyzer-security.FloatLoopCounter,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
-clang-analyzer-security.insecureAPI.SecuritySyntaxChecker,
-clang-analyzer-security.insecureAPI.UncheckedReturn,
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/inference/utils/table_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void TablePrinter::CalcLayout() {
void TablePrinter::AddRowDivider(std::stringstream& ss) {
ss << "+";
for (float share : shares_) {
for (float j = 0; j < share + 2; ++j) ss << "-";
for (int j = 0; j < static_cast<int>(share) + 2; ++j) ss << "-";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果 shares_是 float 类型,为什么一定要转成 int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是这样想的:
j的值如果是100.001,这样一来,最后一次的循环,就会因为100.001比100大0.001,导致最后一次循环被跳过,就会只循环99次。

ss << "+";
}
ss << "\n";
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/event_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ HostTraceEventNode* NodeTrees::BuildTreeRelationship(

// build relationship between host event node and op supplement node
for (auto it = post_order_nodes.begin(); it < post_order_nodes.end(); ++it) {
int op_supplement_count = 0;
int op_supplement_count = 0; // NOLINT
bool hasenter = false;
std::vector<OperatorSupplementEventNode*>::iterator firstposition;
std::vector<OperatorSupplementEventNode*>::iterator lastposition =
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/fluid/reader/reader_blocking_queue_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct MyClass {
MyClass() : val_(0) {}
explicit MyClass(int val) : val_(val) {}
MyClass(const MyClass& b) { val_ = b.val_; }
MyClass(MyClass&& b) { val_ = b.val_; }
MyClass(MyClass&& b) noexcept { val_ = b.val_; }
MyClass& operator=(const MyClass& b) {
if (this != &b) {
val_ = b.val_;
Expand Down