Skip to content

Commit dcaca0f

Browse files
authored
[clang-tidy] enable bugprone-exception-escape check (#56692)
1 parent c0f5dac commit dcaca0f

File tree

24 files changed

+53
-45
lines changed

24 files changed

+53
-45
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ bugprone-argument-comment,
88
bugprone-copy-constructor-init,
99
-bugprone-dangling-handle,
1010
-bugprone-dynamic-static-initializers,
11-
-bugprone-exception-escape,
11+
bugprone-exception-escape,
1212
-bugprone-fold-init-type,
1313
-bugprone-forwarding-reference-overload,
1414
-bugprone-inaccurate-erase,

paddle/fluid/distributed/auto_parallel/spmd_rules/dim_trans.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Flatten::Flatten(const std::vector<DimTrans*>& dims)
7272
all_dim_trans.emplace_back(this);
7373
}
7474

75-
Flatten::~Flatten() {
75+
Flatten::~Flatten() { // NOLINT
7676
input_dims_.assign(input_dims_.size(), nullptr);
7777
std::vector<DimTrans*>().swap(input_dims_);
7878
}

paddle/fluid/eager/auto_code_generator/eager_generator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3299,7 +3299,7 @@ static void DygraphCodeGeneration(const std::string& output_dir,
32993299
} // namespace framework
33003300
} // namespace paddle
33013301

3302-
int main(int argc, char* argv[]) {
3302+
int main(int argc, char* argv[]) { // NOLINT
33033303
if (argc != 3) {
33043304
std::cerr << "argc must be 3" << std::endl;
33053305
return -1;

paddle/fluid/eager/pylayer/py_layer_node.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "pybind11/pytypes.h"
2828

2929
namespace egr {
30-
GradNodePyLayer::~GradNodePyLayer() {
30+
GradNodePyLayer::~GradNodePyLayer() { // NOLINT
3131
pybind11::gil_scoped_acquire gil;
3232
Py_XDECREF(ctx_);
3333
}

paddle/fluid/framework/custom_operator.cc

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -916,11 +916,12 @@ static void RegisterOperatorKernel(
916916
OperatorWithKernel::OpKernelFunc op_kernel_func;
917917
if (kernel_func) {
918918
VLOG(3) << "Register custom operator " << name << " with kernel func";
919-
op_kernel_func = [kernel_func, inputs, outputs, attrs, inplace_map](
920-
const framework::ExecutionContext& ctx) {
921-
VLOG(3) << "Custom Operator: run custom kernel func in lambda.";
922-
RunKernelFunc(ctx, kernel_func, inputs, outputs, attrs, inplace_map);
923-
};
919+
op_kernel_func =
920+
[kernel_func, inputs, outputs, attrs, inplace_map]( // NOLINT
921+
const framework::ExecutionContext& ctx) {
922+
VLOG(3) << "Custom Operator: run custom kernel func in lambda.";
923+
RunKernelFunc(ctx, kernel_func, inputs, outputs, attrs, inplace_map);
924+
};
924925
} else {
925926
VLOG(3) << "Register custom operator " << name
926927
<< " with raw op kernel func";
@@ -1027,12 +1028,12 @@ void RegisterOperatorWithMetaInfo(const std::vector<OpMetaInfo>& op_meta_infos,
10271028
// InferShape
10281029
if (infer_shape_func == nullptr) {
10291030
// use default InferShape
1030-
info.infer_shape_ =
1031-
[op_inputs, op_outputs, op_inplace_map](InferShapeContext* ctx) {
1032-
RunDefaultInferShapeFunc(ctx, op_inputs, op_outputs, op_inplace_map);
1033-
};
1031+
info.infer_shape_ = [op_inputs, op_outputs, op_inplace_map]( // NOLINT
1032+
InferShapeContext* ctx) {
1033+
RunDefaultInferShapeFunc(ctx, op_inputs, op_outputs, op_inplace_map);
1034+
};
10341035
} else {
1035-
info.infer_shape_ = [op_inputs,
1036+
info.infer_shape_ = [op_inputs, // NOLINT
10361037
op_outputs,
10371038
op_attrs,
10381039
op_inplace_map,
@@ -1051,12 +1052,12 @@ void RegisterOperatorWithMetaInfo(const std::vector<OpMetaInfo>& op_meta_infos,
10511052
// Infer Dtype
10521053
if (infer_dtype_func == nullptr) {
10531054
// use default InferDtype
1054-
info.infer_var_type_ =
1055-
[op_inputs, op_outputs, op_inplace_map](InferVarTypeContext* ctx) {
1056-
RunDefaultInferDtypeFunc(ctx, op_inputs, op_outputs, op_inplace_map);
1057-
};
1055+
info.infer_var_type_ = [op_inputs, op_outputs, op_inplace_map]( // NOLINT
1056+
InferVarTypeContext* ctx) {
1057+
RunDefaultInferDtypeFunc(ctx, op_inputs, op_outputs, op_inplace_map);
1058+
};
10581059
} else {
1059-
info.infer_var_type_ = [op_inputs,
1060+
info.infer_var_type_ = [op_inputs, // NOLINT
10601061
op_outputs,
10611062
op_attrs,
10621063
op_inplace_map,
@@ -1115,7 +1116,10 @@ void RegisterOperatorWithMetaInfo(const std::vector<OpMetaInfo>& op_meta_infos,
11151116

11161117
// GradOpDescMaker
11171118
info.grad_op_maker_ =
1118-
[grad_op_name, grad_op_inputs, grad_op_outputs, is_double_grad](
1119+
[grad_op_name, // NOLINT
1120+
grad_op_inputs,
1121+
grad_op_outputs,
1122+
is_double_grad](
11191123
const OpDesc& fwd_op,
11201124
const std::unordered_set<std::string>& no_grad_set,
11211125
std::unordered_map<std::string, std::string>* grad_to_var,
@@ -1133,7 +1137,10 @@ void RegisterOperatorWithMetaInfo(const std::vector<OpMetaInfo>& op_meta_infos,
11331137

11341138
// GradOpBaseMaker
11351139
info.dygraph_grad_op_maker_ =
1136-
[grad_op_name, grad_op_inputs, grad_op_outputs, is_double_grad](
1140+
[grad_op_name, // NOLINT
1141+
grad_op_inputs,
1142+
grad_op_outputs,
1143+
is_double_grad](
11371144
const std::string& type,
11381145
const imperative::NameVarBaseMap& var_base_map_in,
11391146
const imperative::NameVarBaseMap& var_base_map_out,
@@ -1173,7 +1180,7 @@ void RegisterOperatorWithMetaInfo(const std::vector<OpMetaInfo>& op_meta_infos,
11731180

11741181
// Grad InferShape
11751182
if (grad_infer_shape_fn == nullptr) {
1176-
grad_info.infer_shape_ = [grad_op_inputs,
1183+
grad_info.infer_shape_ = [grad_op_inputs, // NOLINT
11771184
grad_op_outputs,
11781185
is_double_grad](InferShapeContext* ctx) {
11791186
// 1. if forward input exists, gradient's shape is same with forward
@@ -1211,7 +1218,7 @@ void RegisterOperatorWithMetaInfo(const std::vector<OpMetaInfo>& op_meta_infos,
12111218
}
12121219
};
12131220
} else {
1214-
grad_info.infer_shape_ = [grad_op_inputs,
1221+
grad_info.infer_shape_ = [grad_op_inputs, // NOLINT
12151222
grad_op_outputs,
12161223
grad_op_attrs,
12171224
grad_op_inplace_map,
@@ -1230,7 +1237,7 @@ void RegisterOperatorWithMetaInfo(const std::vector<OpMetaInfo>& op_meta_infos,
12301237
// Grad InferDtype
12311238
if (grad_infer_dtype_fn != nullptr) {
12321239
grad_info.infer_var_type_ =
1233-
[grad_op_inputs,
1240+
[grad_op_inputs, // NOLINT
12341241
grad_op_outputs,
12351242
grad_op_attrs,
12361243
grad_op_inplace_map,

paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SingleStreamGuard {
7272
}
7373
}
7474

75-
~SingleStreamGuard() {
75+
~SingleStreamGuard() { // NOLINT
7676
if (!is_changed) {
7777
return;
7878
}

paddle/fluid/framework/scope.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PADDLE_DEFINE_EXPORTED_bool(
3333
namespace paddle {
3434
namespace framework {
3535

36-
Scope::~Scope() { DropKids(); }
36+
Scope::~Scope() { DropKids(); } // NOLINT
3737

3838
Scope& Scope::NewScope() const {
3939
Scope* child = new Scope(this);

paddle/fluid/inference/api/analysis_predictor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,7 @@ bool AnalysisPredictor::SaveTrtCalibToDisk() {
25812581
}
25822582
#endif
25832583

2584-
AnalysisPredictor::~AnalysisPredictor() {
2584+
AnalysisPredictor::~AnalysisPredictor() { // NOLINT
25852585
#ifdef PADDLE_WITH_TENSORRT
25862586
if (config_.tensorrt_engine_enabled() &&
25872587
config_.tensorrt_precision_mode_ == AnalysisConfig::Precision::kInt8 &&

paddle/fluid/memory/allocation/mmap_allocator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void MemoryMapAllocationPool::Clear() {
391391
memory_map_allocations_.clear();
392392
}
393393

394-
MemoryMapAllocationPool::~MemoryMapAllocationPool() { Clear(); }
394+
MemoryMapAllocationPool::~MemoryMapAllocationPool() { Clear(); } // NOLINT
395395

396396
} // namespace allocation
397397
} // namespace memory

paddle/fluid/platform/profiler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ MemEvenRecorder::RecordMemEvent::RecordMemEvent(const Place &place,
591591
PushMemEvent(start_ns_, end_ns_, bytes_, place_, alloc_in_);
592592
}
593593

594-
MemEvenRecorder::RecordMemEvent::~RecordMemEvent() {
594+
MemEvenRecorder::RecordMemEvent::~RecordMemEvent() { // NOLINT
595595
phi::DeviceTracer *tracer = phi::GetDeviceTracer();
596596
end_ns_ = PosixInNsec();
597597

0 commit comments

Comments
 (0)