Skip to content

Commit 7882b37

Browse files
committed
[clang-tidy] Address several clang-tidy comments
1 parent d83c4f9 commit 7882b37

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

include/CppInterOp/CppInterOp.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define CPPINTEROP_CPPINTEROP_H
1616

1717
#include <cassert>
18+
#include <cstddef>
1819
#include <cstdint>
1920
#include <set>
2021
#include <string>
@@ -41,7 +42,7 @@ using TCppFuncAddr_t = void*;
4142
using TInterp_t = void*;
4243
using TCppObject_t = void*;
4344

44-
enum Operator {
45+
enum Operator : unsigned char {
4546
OP_None,
4647
OP_New,
4748
OP_Delete,
@@ -90,7 +91,7 @@ enum Operator {
9091
OP_Coawait,
9192
};
9293

93-
enum OperatorArity { kUnary = 1, kBinary, kBoth };
94+
enum OperatorArity : unsigned char { kUnary = 1, kBinary, kBoth };
9495

9596
/// A class modeling function calls for functions produced by the interpreter
9697
/// in compiled code. It provides an information if we are calling a standard
@@ -108,7 +109,7 @@ class JitCall {
108109
void** m_Args = nullptr;
109110
size_t m_ArgSize = 0;
110111
// Clang struggles with =default...
111-
ArgList() : m_Args(nullptr), m_ArgSize(0) {}
112+
ArgList() {}
112113
ArgList(void** Args, size_t ArgSize) : m_Args(Args), m_ArgSize(ArgSize) {}
113114
};
114115
// FIXME: Figure out how to unify the wrapper signatures.
@@ -122,13 +123,13 @@ class JitCall {
122123
GenericCall m_GenericCall;
123124
DestructorCall m_DestructorCall;
124125
};
125-
const Kind m_Kind;
126+
Kind m_Kind;
126127
TCppConstFunction_t m_FD;
127-
JitCall() : m_Kind(kUnknown), m_GenericCall(nullptr), m_FD(nullptr) {}
128+
JitCall() : m_GenericCall(nullptr), m_Kind(kUnknown), m_FD(nullptr) {}
128129
JitCall(Kind K, GenericCall C, TCppConstFunction_t FD)
129-
: m_Kind(K), m_GenericCall(C), m_FD(FD) {}
130+
: m_GenericCall(C), m_Kind(K), m_FD(FD) {}
130131
JitCall(Kind K, DestructorCall C, TCppConstFunction_t Dtor)
131-
: m_Kind(K), m_DestructorCall(C), m_FD(Dtor) {}
132+
: m_DestructorCall(C), m_Kind(K), m_FD(Dtor) {}
132133

133134
/// Checks if the passed arguments are valid for the given function.
134135
CPPINTEROP_API bool AreArgumentsValid(void* result, ArgList args,
@@ -162,15 +163,19 @@ class JitCall {
162163
// by default. These changes should be synchronized with the wrapper if we
163164
// decide to directly.
164165
void Invoke(void* result, ArgList args = {}, void* self = nullptr) const {
166+
// NOLINTBEGIN(*-type-union-access)
165167
// Forward if we intended to call a dtor with only 1 parameter.
166-
if (m_Kind == kDestructorCall && result && !args.m_Args)
167-
return InvokeDestructor(result, /*nary=*/0UL, /*withFree=*/true);
168+
if (m_Kind == kDestructorCall && result && !args.m_Args) {
169+
InvokeDestructor(result, /*nary=*/0UL, /*withFree=*/true);
170+
return;
171+
}
168172

169173
#ifndef NDEBUG
170174
assert(AreArgumentsValid(result, args, self) && "Invalid args!");
171175
ReportInvokeStart(result, args, self);
172176
#endif // NDEBUG
173177
m_GenericCall(self, args.m_ArgSize, args.m_Args, result);
178+
// NOLINTEND(*-type-union-access)
174179
}
175180
/// Makes a call to a destructor.
176181
///\param[in] object - the pointer of the object whose destructor we call.
@@ -746,6 +751,7 @@ CPPINTEROP_API void GetAllCppNames(TCppScope_t scope,
746751

747752
CPPINTEROP_API void DumpScope(TCppScope_t scope);
748753

754+
// FIXME: Rework the GetDimensions and make this enum redundant.
749755
namespace DimensionValue {
750756
enum : long int {
751757
UNKNOWN_SIZE = -1,

unittests/CppInterOp/Utils.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
#include "clang/Sema/Lookup.h"
1010
#include "clang/Sema/Sema.h"
1111

12-
#include "llvm/ADT/StringRef.h"
13-
#include "llvm/Support/FileSystem.h"
14-
#include "llvm/Support/Path.h"
15-
1612
#include <algorithm>
1713
#include <string>
1814
#include <vector>

unittests/CppInterOp/Utils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
#include "../../lib/CppInterOp/Compatibility.h"
55

6+
#include "clang-c/CXCppInterOp.h"
7+
#include "clang-c/CXString.h"
8+
69
#include "llvm/Support/Valgrind.h"
10+
711
#include <memory>
812
#include <string>
913
#include <vector>
10-
#include "clang-c/CXCppInterOp.h"
11-
#include "clang-c/CXString.h"
1214

1315
using namespace clang;
1416
using namespace llvm;

0 commit comments

Comments
 (0)