Skip to content

Commit f113f4d

Browse files
authored
Merge pull request cms-sw#34036 from smuzaffar/12_0-code-checks-CORE
[CORE] Apply code-checks/format with misc-definitions-in-headers
2 parents 08671d2 + 79930bd commit f113f4d

File tree

29 files changed

+210
-188
lines changed

29 files changed

+210
-188
lines changed

DataFormats/Common/interface/AssociationVector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ namespace edm {
157157

158158
template <typename KeyRefProd, typename CVal, typename KeyRef, typename SizeType, typename KeyReferenceHelper>
159159
inline typename AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::const_reference
160-
AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::operator[](size_type n) const {
160+
AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::operator[](size_type n) const {
161161
return transientVector()[n];
162162
}
163163

164164
template <typename KeyRefProd, typename CVal, typename KeyRef, typename SizeType, typename KeyReferenceHelper>
165165
inline typename CVal::const_reference
166-
AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::operator[](KeyRef const& k) const {
166+
AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::operator[](KeyRef const& k) const {
167167
KeyRef keyRef = KeyReferenceHelper::get(k, ref_.id());
168168
checkForWrongProduct(keyRef.id(), ref_.id());
169169
return data_[keyRef.key()];
@@ -172,7 +172,7 @@ namespace edm {
172172
template <typename KeyRefProd, typename CVal, typename KeyRef, typename SizeType, typename KeyReferenceHelper>
173173
template <typename K>
174174
inline typename CVal::const_reference
175-
AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::operator[](edm::Ptr<K> const& k) const {
175+
AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::operator[](edm::Ptr<K> const& k) const {
176176
static_assert(std::is_base_of<K, key_type>::value,
177177
"edm::Ptr's key type is not a base class of AssociationVector's item type");
178178
checkForWrongProduct(k.id(), ref_.id());

DataFormats/Common/interface/ConvertHandle.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,30 @@ namespace edm {
2020
// Convert from handle-to-void to handle-to-T
2121
template <typename T>
2222
Handle<T> convert_handle(BasicHandle&& bh) noexcept(true) {
23-
if
24-
UNLIKELY(bh.failedToGet()) { return Handle<T>(std::move(bh.whyFailedFactory())); }
23+
if UNLIKELY (bh.failedToGet()) {
24+
return Handle<T>(std::move(bh.whyFailedFactory()));
25+
}
2526
void const* basicWrapper = bh.wrapper();
26-
if
27-
UNLIKELY(nullptr == basicWrapper) { return Handle<T>{handleimpl::makeInvalidReferenceException()}; }
27+
if UNLIKELY (nullptr == basicWrapper) {
28+
return Handle<T>{handleimpl::makeInvalidReferenceException()};
29+
}
2830
auto wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
2931

3032
return Handle<T>(wrapper->product(), bh.provenance());
3133
}
3234

3335
template <typename T>
3436
Handle<T> convert_handle_check_type(BasicHandle&& bh) {
35-
if
36-
UNLIKELY(bh.failedToGet()) { return Handle<T>(std::move(bh.whyFailedFactory())); }
37+
if UNLIKELY (bh.failedToGet()) {
38+
return Handle<T>(std::move(bh.whyFailedFactory()));
39+
}
3740
void const* basicWrapper = bh.wrapper();
38-
if
39-
UNLIKELY(basicWrapper == nullptr) { return Handle<T>{handleimpl::makeInvalidReferenceException()}; }
40-
if
41-
UNLIKELY(!(bh.wrapper()->dynamicTypeInfo() == typeid(T))) {
42-
handleimpl::throwConvertTypeError(typeid(T), bh.wrapper()->dynamicTypeInfo());
43-
}
41+
if UNLIKELY (basicWrapper == nullptr) {
42+
return Handle<T>{handleimpl::makeInvalidReferenceException()};
43+
}
44+
if UNLIKELY (!(bh.wrapper()->dynamicTypeInfo() == typeid(T))) {
45+
handleimpl::throwConvertTypeError(typeid(T), bh.wrapper()->dynamicTypeInfo());
46+
}
4447
Wrapper<T> const* wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
4548

4649
return Handle<T>(wrapper->product(), bh.provenance());

DataFormats/Common/interface/DetSetVectorNew.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ namespace edmNew {
107107
size = rh.size;
108108
return *this;
109109
}
110-
Item(Item&& rh) noexcept : id(std::move(rh.id)), offset(int(rh.offset)), size(std::move(rh.size)) {}
110+
Item(Item&& rh) noexcept : id(rh.id), offset(int(rh.offset)), size(rh.size) {}
111111
Item& operator=(Item&& rh) noexcept {
112-
id = std::move(rh.id);
112+
id = rh.id;
113113
offset = int(rh.offset);
114-
size = std::move(rh.size);
114+
size = rh.size;
115115
return *this;
116116
}
117117

DataFormats/Common/interface/Ref.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ namespace edm {
253253
key_type index() const { return index_; }
254254

255255
/// Returns true if container referenced by the Ref has been cached
256-
bool hasProductCache() const { return product_.productPtr() != 0; }
256+
bool hasProductCache() const { return product_.productPtr() != nullptr; }
257257

258258
/// Checks if collection is in memory or available
259259
/// in the Event. No type checking is done.

DataFormats/Common/interface/RefProd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ namespace edm {
127127
EDProductGetter const* productGetter() const { return product_.productGetter(); }
128128

129129
/// Checks if product is in memory.
130-
bool hasCache() const { return product_.productPtr() != 0; }
130+
bool hasCache() const { return product_.productPtr() != nullptr; }
131131

132132
/// Checks if product is in memory.
133133
bool hasProductCache() const { return hasCache(); }

DataFormats/Common/interface/ValidHandle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ namespace edm {
2222
using element_type = T;
2323

2424
ValidHandle() = delete;
25-
ValidHandle(T const* prod, ProductID id) noexcept(false) : product_(prod), id_(std::move(id)) {
25+
ValidHandle(T const* prod, ProductID id) noexcept(false) : product_(prod), id_(id) {
2626
vhhelper::throwIfNotValid(prod);
2727
}
2828

2929
//NOTE: C++ disallows references to null
30-
ValidHandle(T const& prod, ProductID id) noexcept(true) : product_(&prod), id_(std::move(id)) {}
30+
ValidHandle(T const& prod, ProductID id) noexcept(true) : product_(&prod), id_(id) {}
3131
ValidHandle(const ValidHandle<T>&) = default;
3232
ValidHandle<T>& operator=(ValidHandle<T> const& rhs) = default;
3333
~ValidHandle() = default;

DataFormats/Provenance/interface/BranchKey.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,14 @@ namespace edm {
3636
};
3737

3838
inline bool operator<(BranchKey const& a, BranchKey const& b) {
39-
return a.friendlyClassName() < b.friendlyClassName()
40-
? true
41-
: a.friendlyClassName() > b.friendlyClassName()
42-
? false
43-
: a.moduleLabel() < b.moduleLabel()
44-
? true
45-
: a.moduleLabel() > b.moduleLabel()
46-
? false
47-
: a.productInstanceName() < b.productInstanceName()
48-
? true
49-
: a.productInstanceName() > b.productInstanceName()
50-
? false
51-
: a.processName() < b.processName() ? true : false;
39+
return a.friendlyClassName() < b.friendlyClassName() ? true
40+
: a.friendlyClassName() > b.friendlyClassName() ? false
41+
: a.moduleLabel() < b.moduleLabel() ? true
42+
: a.moduleLabel() > b.moduleLabel() ? false
43+
: a.productInstanceName() < b.productInstanceName() ? true
44+
: a.productInstanceName() > b.productInstanceName() ? false
45+
: a.processName() < b.processName() ? true
46+
: false;
5247
}
5348

5449
inline bool operator==(BranchKey const& a, BranchKey const& b) { return !(a < b || b < a); }

FWCore/FWLite/bin/storageSizeForBranch.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ int main(int argc, char* argv[]) try {
4545
"file"
4646
"\nAllowed options";
4747
boost::program_options::options_description desc(descString);
48-
desc.add_options()(kHelpCommandOpt, "show this help message")(kEntryNumberCommandOpt,
49-
boost::program_options::value<int>(),
50-
"read branch from the given entry value (default 0)")(
51-
kBranchNameOpt, "name of branch")(kFileNameOpt, "name of file");
48+
desc.add_options()(kHelpCommandOpt, "show this help message")(
49+
kEntryNumberCommandOpt,
50+
boost::program_options::value<int>(),
51+
"read branch from the given entry value (default 0)")(kBranchNameOpt, "name of branch")(kFileNameOpt,
52+
"name of file");
5253

5354
boost::program_options::positional_options_description p;
5455
p.add(kBranchNameOpt, 1);

FWCore/Framework/bin/cmsRun.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ int main(int argc, char* argv[]) {
151151
descString += "] config_file \nAllowed options";
152152
boost::program_options::options_description desc(descString);
153153

154+
// clang-format off
154155
desc.add_options()(kHelpCommandOpt, "produce help message")(
155156
kParameterSetCommandOpt, boost::program_options::value<std::string>(), "configuration file")(
156157
kJobreportCommandOpt,
@@ -166,6 +167,7 @@ int main(int argc, char* argv[]) {
166167
kSizeOfStackForThreadCommandOpt,
167168
boost::program_options::value<unsigned int>(),
168169
"Size of stack in KB to use for extra threads (0 is use system default size)")(kStrictOpt, "strict parsing");
170+
// clang-format on
169171

170172
// anything at the end will be ignored, and sent to python
171173
boost::program_options::positional_options_description p;

FWCore/Framework/bin/cmsRunPython3.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ int main(int argc, char* argv[]) {
150150
descString += "] config_file \nAllowed options";
151151
boost::program_options::options_description desc(descString);
152152

153+
// clang-format off
153154
desc.add_options()(kHelpCommandOpt, "produce help message")(
154155
kParameterSetCommandOpt, boost::program_options::value<std::string>(), "configuration file")(
155156
kJobreportCommandOpt,
@@ -165,6 +166,7 @@ int main(int argc, char* argv[]) {
165166
kSizeOfStackForThreadCommandOpt,
166167
boost::program_options::value<unsigned int>(),
167168
"Size of stack in KB to use for extra threads (0 is use system default size)")(kStrictOpt, "strict parsing");
169+
// clang-format on
168170

169171
// anything at the end will be ignored, and sent to python
170172
boost::program_options::positional_options_description p;

0 commit comments

Comments
 (0)