Skip to content

Commit

Permalink
Merge pull request #297 from hvdijk/const-style
Browse files Browse the repository at this point in the history
[NFC] Pick a style for const.
  • Loading branch information
hvdijk authored Jan 18, 2024
2 parents e71008b + 0aeca1b commit 3713e73
Show file tree
Hide file tree
Showing 85 changed files with 1,040 additions and 1,039 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ IncludeCategories:
- Regex: '.*'
Priority: 3
DerivePointerAlignment: false
QualifierAlignment: Left
PointerAlignment: Right
...
8 changes: 4 additions & 4 deletions modules/cargo/include/cargo/detail/expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,11 @@ template <class T, class E,
struct expected_default_ctor_base {
constexpr expected_default_ctor_base() noexcept = default;
constexpr expected_default_ctor_base(
expected_default_ctor_base const &) noexcept = default;
const expected_default_ctor_base &) noexcept = default;
constexpr expected_default_ctor_base(expected_default_ctor_base &&) noexcept =
default;
expected_default_ctor_base &operator=(
expected_default_ctor_base const &) noexcept = default;
const expected_default_ctor_base &) noexcept = default;
expected_default_ctor_base &operator=(
expected_default_ctor_base &&) noexcept = default;

Expand All @@ -610,11 +610,11 @@ template <class T, class E>
struct expected_default_ctor_base<T, E, false> {
constexpr expected_default_ctor_base() noexcept = delete;
constexpr expected_default_ctor_base(
expected_default_ctor_base const &) noexcept = default;
const expected_default_ctor_base &) noexcept = default;
constexpr expected_default_ctor_base(expected_default_ctor_base &&) noexcept =
default;
expected_default_ctor_base &operator=(
expected_default_ctor_base const &) noexcept = default;
const expected_default_ctor_base &) noexcept = default;
expected_default_ctor_base &operator=(
expected_default_ctor_base &&) noexcept = default;

Expand Down
10 changes: 5 additions & 5 deletions modules/cargo/include/cargo/expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class expected
template <class G = E,
enable_if_t<std::is_constructible<E, const G &>::value> * = nullptr,
enable_if_t<std::is_convertible<const G &, E>::value> * = nullptr>
constexpr expected(unexpected<G> const &e)
constexpr expected(const unexpected<G> &e)
: impl_base(unexpect, e.value()),
ctor_base(detail::default_constructor_tag{}) {}

Expand Down Expand Up @@ -390,8 +390,8 @@ class expected
/// @param rhs Expected object to copy.
template <
class U, class G,
enable_if_t<!(std::is_convertible<U const &, T>::value &&
std::is_convertible<G const &, E>::value)> * = nullptr,
enable_if_t<!(std::is_convertible<const U &, T>::value &&
std::is_convertible<const G &, E>::value)> * = nullptr,
detail::expected_enable_from_other<T, E, U, G, const U &, const G &> * =
nullptr>
explicit constexpr expected(const expected<U, G> &rhs)
Expand All @@ -409,8 +409,8 @@ class expected
/// @tparam G Type of `rhs'`s unexpected value.
/// @param rhs Expected object to copy.
template <class U, class G,
enable_if_t<(std::is_convertible<U const &, T>::value &&
std::is_convertible<G const &, E>::value)> * = nullptr,
enable_if_t<(std::is_convertible<const U &, T>::value &&
std::is_convertible<const G &, E>::value)> * = nullptr,
detail::expected_enable_from_other<T, E, U, G, const U &, const G &>
* = nullptr>
constexpr expected(const expected<U, G> &rhs)
Expand Down
4 changes: 2 additions & 2 deletions modules/cargo/test/expected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,10 @@ TEST(expected, and_then_std_string) { getInt1(); }

cargo::expected<int, int> operation1() { return 42; }

cargo::expected<std::string, int> operation2(int const) { return "Bananas"; }
cargo::expected<std::string, int> operation2(const int) { return "Bananas"; }

TEST(expected, and_then_non_constexpr) {
auto const intermediate_result = operation1();
const auto intermediate_result = operation1();

intermediate_result.and_then(operation2);
}
Expand Down
6 changes: 3 additions & 3 deletions modules/compiler/spirv-ll/include/spirv-ll/builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ExtInstSetHandler {
///
/// @return Returns an `llvm::Error` object representing either success, or
/// an error value.
virtual llvm::Error create(OpExtInst const &opc) = 0;
virtual llvm::Error create(const OpExtInst &opc) = 0;

protected:
/// @brief `spirv_ll::Builder` that owns this object.
Expand Down Expand Up @@ -235,13 +235,13 @@ class Builder {

/// @brief Populate the incoming edges/values for the given Phi node
/// @param op The SpirV Op for the Phi node
void populatePhi(OpPhi const &op);
void populatePhi(const OpPhi &op);

/// @brief A unification of the four very similar access chain functions
///
/// @param opc The OpCode representing the access chain instruction
/// being translated
void accessChain(OpCode const &opc);
void accessChain(const OpCode &opc);

/// @brief Represents a lexical scope, used for debug information.
struct LexicalScopeTy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DebugInfoBuilder : public ExtInstSetHandler {
: ExtInstSetHandler(builder, module), workarounds(workarounds) {}

/// @see ExtInstSetHandler::create
virtual llvm::Error create(OpExtInst const &opc) override;
virtual llvm::Error create(const OpExtInst &opc) override;

virtual llvm::Error finishModuleProcessing() override;

Expand All @@ -67,7 +67,7 @@ class DebugInfoBuilder : public ExtInstSetHandler {
/// @return Returns an `llvm::Error` object representing either success, or
/// an error value.
template <typename T>
llvm::Error create(OpExtInst const &opc);
llvm::Error create(const OpExtInst &opc);

/// @brief Returns the LLVM DIBuilder for the given instruction.
///
Expand Down
4 changes: 2 additions & 2 deletions modules/compiler/spirv-ll/include/spirv-ll/builder_glsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GLSLBuilder : public ExtInstSetHandler {
: ExtInstSetHandler(builder, module) {}

/// @see ExtendedInstrSet::create
virtual llvm::Error create(OpExtInst const &opc) override;
virtual llvm::Error create(const OpExtInst &opc) override;

private:
/// @brief Create a GLSL extended instruction transformation to LLVM IR.
Expand All @@ -43,7 +43,7 @@ class GLSLBuilder : public ExtInstSetHandler {
/// @return Returns an `llvm::Error` object representing either success, or
/// an error value.
template <enum GLSLstd450 inst>
llvm::Error create(OpExtInst const &opc);
llvm::Error create(const OpExtInst &opc);
};

} // namespace spirv_ll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GroupAsyncCopiesBuilder : public ExtInstSetHandler {
};

/// @see ExtInstSetHandler::create
virtual llvm::Error create(OpExtInst const &opc) override;
virtual llvm::Error create(const OpExtInst &opc) override;

private:
/// @brief Create a Codeplay.GroupAsyncCopies extended instruction
Expand All @@ -54,7 +54,7 @@ class GroupAsyncCopiesBuilder : public ExtInstSetHandler {
/// @return Returns an `llvm::Error` object representing either success, or
/// an error value.
template <Instruction inst>
llvm::Error create(OpExtInst const &opc);
llvm::Error create(const OpExtInst &opc);
};

} // namespace spirv_ll
Expand Down
6 changes: 3 additions & 3 deletions modules/compiler/spirv-ll/include/spirv-ll/builder_opencl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class OpenCLBuilder : public spirv_ll::ExtInstSetHandler {
: ExtInstSetHandler(builder, module) {}

/// @see ExtInstSetHandler::create
virtual llvm::Error create(OpExtInst const &opc) override;
virtual llvm::Error create(const OpExtInst &opc) override;

private:
/// @brief Create an OpenCL extended instruction transformation to LLVM IR.
Expand All @@ -42,7 +42,7 @@ class OpenCLBuilder : public spirv_ll::ExtInstSetHandler {
/// @return Returns an `llvm::Error` object representing either success, or
/// an error value.
template <typename T>
llvm::Error create(OpExtInst const &opc);
llvm::Error create(const OpExtInst &opc);

/// @brief Create a vector OpenCL extended instruction transformation to LLVM
/// IR.
Expand All @@ -53,7 +53,7 @@ class OpenCLBuilder : public spirv_ll::ExtInstSetHandler {
/// @return Returns an `llvm::Error` object representing either success, or
/// an error value.
template <OpenCLLIB::Entrypoints inst>
llvm::Error createVec(OpExtInst const &opc);
llvm::Error createVec(const OpExtInst &opc);
};

} // namespace spirv_ll
Expand Down
12 changes: 6 additions & 6 deletions modules/compiler/spirv-ll/include/spirv-ll/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class Module : public ModuleHeader {
///
/// @param Op `OpResult` object with the ID whose value will be replaced.
/// @param V `Value` object to replace the old value with.
void replaceID(OpResult const *Op, llvm::Value *V);
void replaceID(const OpResult *Op, llvm::Value *V);

/// @brief Add a specified execution mode to the module.
///
Expand Down Expand Up @@ -638,7 +638,7 @@ class Module : public ModuleHeader {
/// @param[in] T The LLVM value for the given Op.
///
/// @return true on success, false if the ID already exists
bool addID(spv::Id id, OpCode const *Op, llvm::Type *T);
bool addID(spv::Id id, const OpCode *Op, llvm::Type *T);

/// @brief track the original SPIR-V type ids for the OpFunctionType `func`
///
Expand Down Expand Up @@ -796,7 +796,7 @@ class Module : public ModuleHeader {
/// @param[in] V The LLVM value for the given Op.
///
/// @return true on success, false if the ID already exists
bool addID(spv::Id id, OpCode const *Op, llvm::Value *V);
bool addID(spv::Id id, const OpCode *Op, llvm::Value *V);

/// @brief Get the LLVM Value for the given SPIR-V ID.
///
Expand Down Expand Up @@ -1082,7 +1082,7 @@ class Module : public ModuleHeader {
/// @brief Empty constructor, initializes everything to nullptr.
TypePair() : Op(nullptr), Type(nullptr) {}
/// @brief Constructor with initializers
TypePair(OpCode const *Op, llvm::Type *Type) : Op(Op), Type(Type) {}
TypePair(const OpCode *Op, llvm::Type *Type) : Op(Op), Type(Type) {}
/// @brief Pointer to the SPIR-V Op.
const OpCode *Op;
/// @brief Pointer to the LLVM Type defined by the SPIR-V Op.
Expand All @@ -1109,7 +1109,7 @@ class Module : public ModuleHeader {
/// @brief Empty constructor, initializes everything to nullptr.
ValuePair() : Op(nullptr), Value(nullptr) {}
/// @brief Constructor with initializers
ValuePair(OpCode const *Op, llvm::Value *Value) : Op(Op), Value(Value) {}
ValuePair(const OpCode *Op, llvm::Value *Value) : Op(Op), Value(Value) {}
/// @brief Pointer to the SPIR-V Op.
const OpCode *Op;
/// @brief Pointer to the LLVM Value defined by the SPIR-V Op.
Expand Down Expand Up @@ -1138,7 +1138,7 @@ class Module : public ModuleHeader {
llvm::Value *BufferSizeArray;
/// @brief List of `OpSpecConstantOp` instructions whose translation had to be
/// deferred.
llvm::SmallVector<spirv_ll::OpSpecConstantOp const *, 2>
llvm::SmallVector<const spirv_ll::OpSpecConstantOp *, 2>
deferredSpecConstantOps;
std::string ModuleProcess;
/// @brief True if debug scopes should be inferred and generated when
Expand Down
Loading

0 comments on commit 3713e73

Please sign in to comment.