Skip to content

Commit 0a03a4b

Browse files
authored
Merge pull request #1926 from jwillemsen/jwi-taoidlnullptr3
Use nullptr, check pointers with 1, use std::addressof, reduced sloc
2 parents a457e9d + 0615e6e commit 0a03a4b

File tree

12 files changed

+83
-84
lines changed

12 files changed

+83
-84
lines changed

Diff for: TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ be_visitor_array_any_op_cs::visit_array (be_array *node)
7676

7777
*os << "void operator<<= (" << be_idt << be_idt_nl
7878
<< "::CORBA::Any &_tao_any," << be_nl
79-
<< "const " << node->name () << "_forany &_tao_elem" << be_uidt_nl
80-
<< ")" << be_uidt_nl
79+
<< "const " << node->name () << "_forany &_tao_elem)" << be_uidt_nl
80+
<< be_uidt_nl
8181
<< "{" << be_idt_nl
8282
<< "TAO::Any_Array_Impl_T<" << be_idt << be_idt_nl
8383
<< node->name () << "_slice," << be_nl
@@ -96,8 +96,8 @@ be_visitor_array_any_op_cs::visit_array (be_array *node)
9696

9797
*os << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl
9898
<< "const ::CORBA::Any &_tao_any," << be_nl
99-
<< node->name () << "_forany &_tao_elem" << be_uidt_nl
100-
<< ")" << be_uidt_nl
99+
<< node->name () << "_forany &_tao_elem)" << be_uidt_nl
100+
<< be_uidt_nl
101101
<< "{" << be_idt_nl
102102
<< "return" << be_idt_nl
103103
<< "TAO::Any_Array_Impl_T<" << be_idt << be_idt_nl
@@ -107,8 +107,8 @@ be_visitor_array_any_op_cs::visit_array (be_array *node)
107107
<< "_tao_any," << be_nl
108108
<< node->name () << "_forany::_tao_any_destructor," << be_nl
109109
<< (td != nullptr ? td->tc_name () : node->tc_name ()) << "," << be_nl
110-
<< "_tao_elem.out ()" << be_uidt_nl
111-
<< ");" << be_uidt << be_uidt << be_uidt << be_uidt_nl
110+
<< "_tao_elem.out ());" << be_uidt
111+
<< be_uidt << be_uidt << be_uidt << be_uidt_nl
112112
<< "}";
113113

114114
*os << be_global->anyops_versioning_end () << be_nl;

Diff for: TAO/TAO_IDL/be/be_visitor_component/executor_exs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ be_visitor_executor_exs::visit_component (be_component *node)
215215
<< "reactor = orb->orb_core ()->reactor ();"
216216
<< be_uidt_nl << "}"
217217
<< be_uidt << be_uidt_nl << "}"
218-
<< be_uidt_nl << "if (reactor == 0)" << be_idt_nl
218+
<< be_uidt_nl << "if (!reactor)" << be_idt_nl
219219
<< "{" << be_idt_nl
220220
<< "throw ::CORBA::INTERNAL ();"
221221
<< be_uidt_nl << "}"

Diff for: TAO/TAO_IDL/be/be_visitor_component/servant_svs.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ be_visitor_servant_svs::gen_provides_top ()
664664
<< "const char * name)" << be_uidt_nl
665665
<< "{" << be_idt_nl;
666666

667-
os_ << "if (name == 0)" << be_idt_nl
667+
os_ << "if (!name)" << be_idt_nl
668668
<< "{" << be_idt_nl
669669
<< "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
670670
<< "}" << be_uidt << be_nl_2;
@@ -713,7 +713,7 @@ be_visitor_servant_svs::gen_publishes_top ()
713713
<< be_uidt_nl
714714
<< "{" << be_idt_nl;
715715

716-
os_ << "if (publisher_name == 0)" << be_idt_nl
716+
os_ << "if (!publisher_name)" << be_idt_nl
717717
<< "{" << be_idt_nl
718718
<< "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
719719
<< "}" << be_uidt;
@@ -742,7 +742,7 @@ be_visitor_servant_svs::gen_publishes_top ()
742742
<< "::Components::Cookie * ck)" << be_uidt_nl
743743
<< "{" << be_idt_nl;
744744

745-
os_ << "if (publisher_name == 0)" << be_idt_nl
745+
os_ << "if (!publisher_name)" << be_idt_nl
746746
<< "{" << be_idt_nl
747747
<< "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
748748
<< "}" << be_uidt;
@@ -819,7 +819,7 @@ be_visitor_servant_svs::gen_uses_top ()
819819
<< "::CORBA::Object_ptr connection)" << be_uidt_nl
820820
<< "{" << be_idt_nl;
821821

822-
os_ << "if (name == 0)" << be_idt_nl
822+
os_ << "if (!name)" << be_idt_nl
823823
<< "{" << be_idt_nl
824824
<< "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
825825
<< "}" << be_uidt;
@@ -849,7 +849,7 @@ be_visitor_servant_svs::gen_uses_top ()
849849
<< (this->node_->has_uses_multiple () ? "ck" : "/* ck */")
850850
<< ")" << be_uidt_nl
851851
<< "{" << be_idt_nl
852-
<< "if (name == 0)" << be_idt_nl
852+
<< "if (!name)" << be_idt_nl
853853
<< "{" << be_idt_nl
854854
<< "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
855855
<< "}" << be_uidt;
@@ -936,7 +936,7 @@ be_visitor_servant_svs::gen_emits_top ()
936936
<< be_uidt_nl
937937
<< "{" << be_idt_nl;
938938

939-
os_ << "if (emitter_name == 0)" << be_idt_nl
939+
os_ << "if (!emitter_name)" << be_idt_nl
940940
<< "{" << be_idt_nl
941941
<< "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
942942
<< "}" << be_uidt;
@@ -964,7 +964,7 @@ be_visitor_servant_svs::gen_emits_top ()
964964
<< "const char * source_name)" << be_uidt_nl
965965
<< "{" << be_idt_nl;
966966

967-
os_ << "if (source_name == 0)" << be_idt_nl
967+
os_ << "if (!source_name)" << be_idt_nl
968968
<< "{" << be_idt_nl
969969
<< "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
970970
<< "}" << be_uidt;
@@ -1265,7 +1265,7 @@ be_visitor_disconnect_block::visit_uses (be_uses *node)
12651265

12661266
if (is_multiple)
12671267
{
1268-
os_ << "if (ck == 0)" << be_idt_nl
1268+
os_ << "if (!ck)" << be_idt_nl
12691269
<< "{" << be_idt_nl
12701270
<< "throw ::Components::CookieRequired ();" << be_uidt_nl
12711271
<< "}" << be_uidt_nl << be_nl;

Diff for: TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ int be_visitor_exception_cs::visit_exception (be_exception *node)
275275
<< "TAO_AnyTypeCode_Adapter *adapter =" << be_idt_nl
276276
<< "ACE_Dynamic_Service<TAO_AnyTypeCode_Adapter>::instance ("
277277
<< "\"AnyTypeCode_Adapter\");" << be_uidt_nl
278-
<< "if (adapter == 0)" << be_idt_nl
278+
<< "if (!adapter)" << be_idt_nl
279279
<< "{" << be_idt_nl
280280
// FUZZ: disable check_for_ace_log_categories
281281
<< "TAOLIB_ERROR_RETURN ((LM_ERROR," << be_idt_nl

Diff for: TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node)
122122
<< "{" << be_idt_nl
123123
<< node->full_name () << "_ptr _tao_objptr =" << be_idt_nl
124124
<< node->full_name () << "::_duplicate (_tao_elem);" << be_uidt_nl
125-
<< "_tao_any <<= &_tao_objptr;" << be_uidt_nl
125+
<< "_tao_any <<= std::addressof(_tao_objptr);" << be_uidt_nl
126126
<< "}" << be_nl_2;
127127

128128
*os << "/// Non-copying insertion." << be_nl

Diff for: TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_cs.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ int be_visitor_interface_smart_proxy_cs::visit_interface (be_interface *node)
214214
<< "return proxy;" << be_uidt_nl
215215
<< "}" << be_uidt_nl << be_nl
216216
<< "// Verify that an <proxy_factory_> is available else make one." << be_nl
217-
<< "if ("
218-
<<"this->proxy_factory_ == 0)" << be_idt_nl
217+
<< "if (!this->proxy_factory_)" << be_idt_nl
219218
<< "ACE_NEW_RETURN ("
220219
<< "this->proxy_factory_," << be_idt << be_idt_nl
221220
<< "TAO_" << node->flat_name ()

Diff for: TAO/TAO_IDL/be/be_visitor_typecode/struct_typecode.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ TAO::be_visitor_struct_typecode::visit (AST_Structure * node,
105105
{
106106
// Should only be possible for user exceptions with no fields.
107107
os << "* const " << be_idt_nl
108-
<< fields_name.c_str () << " = 0;" << be_uidt_nl << be_uidt_nl;
108+
<< fields_name.c_str () << " = nullptr;" << be_uidt_nl << be_uidt_nl;
109109
}
110110
else
111111
{

Diff for: TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ int be_visitor_union_cs::visit_union (be_union *node)
218218
<< node->name () << " &u)" << be_nl;
219219
*os << "{" << be_idt_nl;
220220
// First check for self-assignment.
221-
*os << "if (&u == this)" << be_idt_nl
221+
*os << "if (std::addressof(u) == this)" << be_idt_nl
222222
<< "{" << be_idt_nl
223223
<< "return *this;" << be_uidt_nl
224224
<< "}" << be_uidt_nl << be_nl;

Diff for: TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp

+38-38
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ be_visitor_union_branch_public_assign_cs::visit_interface (be_interface *node)
250250

251251
bool bt_is_defined = node->is_defined ();
252252

253-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
253+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
254254
<< "{" << be_idt_nl
255-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
255+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
256256
<< "}" << be_uidt_nl
257257
<< "else" << be_idt_nl
258258
<< "{" << be_idt_nl;
@@ -304,8 +304,8 @@ be_visitor_union_branch_public_assign_cs::visit_interface (be_interface *node)
304304
<< "u.u_." << ub->local_name ()
305305
<< "_->in ()" << be_uidt_nl
306306
<< ")" << be_uidt << be_uidt_nl << ")," << be_uidt_nl
307-
<< "*this" << be_uidt_nl
308-
<< ");" << be_uidt << be_uidt_nl;
307+
<< "*this);" << be_uidt
308+
<< be_uidt << be_uidt_nl;
309309
}
310310

311311
*os << "}" << be_uidt << be_uidt_nl;
@@ -347,9 +347,9 @@ be_visitor_union_branch_public_assign_cs::visit_interface_fwd (
347347

348348
bool bt_is_defined = node->full_definition ()->is_defined ();
349349

350-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
350+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
351351
<< "{" << be_idt_nl
352-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
352+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
353353
<< "}" << be_uidt_nl
354354
<< "else" << be_idt_nl
355355
<< "{" << be_idt_nl;
@@ -401,8 +401,8 @@ be_visitor_union_branch_public_assign_cs::visit_interface_fwd (
401401
<< "u.u_." << ub->local_name ()
402402
<< "_->in ()" << be_uidt_nl
403403
<< ")" << be_uidt << be_uidt_nl << ")," << be_uidt_nl
404-
<< "*this" << be_uidt_nl
405-
<< ");" << be_uidt << be_uidt_nl;
404+
<< "*this);" << be_uidt
405+
<< be_uidt << be_uidt_nl;
406406
}
407407

408408
*os << "}" << be_uidt << be_uidt_nl;
@@ -460,9 +460,9 @@ be_visitor_union_branch_public_assign_cs::emit_valuetype_common (be_type *node)
460460

461461
TAO_OutStream *os = this->ctx_->stream ();
462462

463-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
463+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
464464
<< "{" << be_idt_nl
465-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
465+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
466466
<< "}" << be_uidt_nl
467467
<< "else" << be_idt_nl
468468
<< "{" << be_idt_nl;
@@ -489,8 +489,8 @@ be_visitor_union_branch_public_assign_cs::emit_valuetype_common (be_type *node)
489489
<< "this->u_." << ub->local_name () << "_," << be_nl
490490
<< "OBJECT_FIELD (u.u_." << ub->local_name () << "_->in ()),"
491491
<< be_nl
492-
<< "*this" << be_uidt_nl
493-
<< ");" << be_uidt << be_uidt_nl;
492+
<< "*this);" << be_uidt
493+
<< be_uidt << be_uidt_nl;
494494
}
495495

496496
*os << "}" << be_uidt << be_uidt_nl;
@@ -555,8 +555,8 @@ be_visitor_union_branch_public_assign_cs::visit_predefined_type (
555555
<< "OBJECT_FIELD (::CORBA::Object"
556556
<< "::_duplicate (u.u_." << ub->local_name ()
557557
<< "_->in ()))," << be_nl
558-
<< "*this" << be_uidt_nl
559-
<< ");" << be_uidt << be_uidt_nl;
558+
<< "*this);" << be_uidt
559+
<< be_uidt << be_uidt_nl;
560560
}
561561

562562
break;
@@ -569,9 +569,9 @@ be_visitor_union_branch_public_assign_cs::visit_predefined_type (
569569
case AST_PredefinedType::PT_any:
570570
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
571571
{
572-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
572+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
573573
<< "{" << be_idt_nl
574-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
574+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
575575
<< "}" << be_uidt_nl
576576
<< "else" << be_idt_nl
577577
<< "{" << be_idt_nl
@@ -584,18 +584,18 @@ be_visitor_union_branch_public_assign_cs::visit_predefined_type (
584584
}
585585
else
586586
{
587-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
587+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
588588
<< "{" << be_idt_nl
589-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
589+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
590590
<< "}" << be_uidt_nl
591591
<< "else" << be_idt_nl
592592
<< "{" << be_idt_nl
593593
<< "ACE_NEW_RETURN (" << be_idt << be_idt_nl
594594
<< "this->u_." << ub->local_name () << "_," << be_nl
595595
<< bt->name () << " (*u.u_."
596596
<< ub->local_name () << "_)," << be_nl
597-
<< "*this" << be_uidt_nl
598-
<< ");" << be_uidt << be_uidt_nl
597+
<< "*this);" << be_uidt
598+
<< be_uidt << be_uidt_nl
599599
<< "}" << be_uidt << be_uidt_nl;
600600
}
601601

@@ -644,9 +644,9 @@ be_visitor_union_branch_public_assign_cs::visit_sequence (be_sequence *node)
644644

645645
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
646646
{
647-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
647+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
648648
<< "{" << be_idt_nl
649-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
649+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
650650
<< "}" << be_uidt_nl
651651
<< "else" << be_idt_nl
652652
<< "{" << be_idt_nl
@@ -659,18 +659,18 @@ be_visitor_union_branch_public_assign_cs::visit_sequence (be_sequence *node)
659659
}
660660
else
661661
{
662-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
662+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
663663
<< "{" << be_idt_nl
664-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
664+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
665665
<< "}" << be_uidt_nl
666666
<< "else" << be_idt_nl
667667
<< "{" << be_idt_nl
668668
<< "ACE_NEW_RETURN (" << be_idt << be_idt_nl
669669
<< "this->u_." << ub->local_name () << "_," << be_nl
670670
<< bt->name () << " (*u.u_."
671671
<< ub->local_name () << "_)," << be_nl
672-
<< "*this" << be_uidt_nl
673-
<< ");" << be_uidt << be_uidt_nl
672+
<< "*this);" << be_uidt
673+
<< be_uidt << be_uidt_nl
674674
<< "}" << be_uidt << be_uidt_nl;
675675
}
676676

@@ -747,9 +747,9 @@ be_visitor_union_branch_public_assign_cs::visit_structure (be_structure *node)
747747
{
748748
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
749749
{
750-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
750+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
751751
<< "{" << be_idt_nl
752-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
752+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
753753
<< "}" << be_uidt_nl
754754
<< "else" << be_idt_nl
755755
<< "{" << be_idt_nl
@@ -762,18 +762,18 @@ be_visitor_union_branch_public_assign_cs::visit_structure (be_structure *node)
762762
}
763763
else
764764
{
765-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
765+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
766766
<< "{" << be_idt_nl
767-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
767+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
768768
<< "}" << be_uidt_nl
769769
<< "else" << be_idt_nl
770770
<< "{" << be_idt_nl
771771
<< "ACE_NEW_RETURN (" << be_idt << be_idt_nl
772772
<< "this->u_." << ub->local_name () << "_," << be_nl
773773
<< bt->name () << " (*u.u_."
774774
<< ub->local_name () << "_)," << be_nl
775-
<< "*this" << be_uidt_nl
776-
<< ");" << be_uidt << be_uidt_nl
775+
<< "*this);" << be_uidt
776+
<< be_uidt << be_uidt_nl
777777
<< "}" << be_uidt << be_uidt_nl;
778778
}
779779
}
@@ -850,9 +850,9 @@ be_visitor_union_branch_public_assign_cs::visit_union (be_union *node)
850850

851851
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
852852
{
853-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
853+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
854854
<< "{" << be_idt_nl
855-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
855+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
856856
<< "}" << be_uidt_nl
857857
<< "else" << be_idt_nl
858858
<< "{" << be_idt_nl
@@ -865,18 +865,18 @@ be_visitor_union_branch_public_assign_cs::visit_union (be_union *node)
865865
}
866866
else
867867
{
868-
*os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl
868+
*os << "if (!u.u_." << ub->local_name () << "_)" << be_idt_nl
869869
<< "{" << be_idt_nl
870-
<< "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl
870+
<< "this->u_." << ub->local_name () << "_ = nullptr;" << be_uidt_nl
871871
<< "}" << be_uidt_nl
872872
<< "else" << be_idt_nl
873873
<< "{" << be_idt_nl
874874
<< "ACE_NEW_RETURN (" << be_idt << be_idt_nl
875875
<< "this->u_." << ub->local_name () << "_," << be_nl
876876
<< bt->name () << " (*u.u_."
877877
<< ub->local_name () << "_)," << be_nl
878-
<< "*this" << be_uidt_nl
879-
<< ");" << be_uidt << be_uidt_nl
878+
<< "*this);" << be_uidt
879+
<< be_uidt << be_uidt_nl
880880
<< "}" << be_uidt << be_uidt_nl;
881881
}
882882

0 commit comments

Comments
 (0)