Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/docs/ClangFormattedStatus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ tree in terms of conformance to :doc:`ClangFormat` as of: March 06, 2022 17:32:2
- `2`
- `79`
- :part:`2%`
* - clang/lib/AST/Interp
* - clang/lib/AST/ByteCode
- `44`
- `18`
- `26`
Expand Down
36 changes: 18 additions & 18 deletions clang/docs/tools/clang-formatted-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,24 +322,24 @@ clang/lib/APINotes/APINotesTypes.cpp
clang/lib/APINotes/APINotesYAMLCompiler.cpp
clang/lib/AST/DataCollection.cpp
clang/lib/AST/Linkage.h
clang/lib/AST/Interp/ByteCodeGenError.cpp
clang/lib/AST/Interp/ByteCodeGenError.h
clang/lib/AST/Interp/Context.cpp
clang/lib/AST/Interp/Context.h
clang/lib/AST/Interp/Descriptor.cpp
clang/lib/AST/Interp/Disasm.cpp
clang/lib/AST/Interp/EvalEmitter.h
clang/lib/AST/Interp/Frame.cpp
clang/lib/AST/Interp/Frame.h
clang/lib/AST/Interp/InterpState.h
clang/lib/AST/Interp/Opcode.h
clang/lib/AST/Interp/Pointer.cpp
clang/lib/AST/Interp/PrimType.cpp
clang/lib/AST/Interp/Record.h
clang/lib/AST/Interp/Source.cpp
clang/lib/AST/Interp/Source.h
clang/lib/AST/Interp/State.cpp
clang/lib/AST/Interp/State.h
clang/lib/AST/ByteCode/ByteCodeGenError.cpp
clang/lib/AST/ByteCode/ByteCodeGenError.h
clang/lib/AST/ByteCode/Context.cpp
clang/lib/AST/ByteCode/Context.h
clang/lib/AST/ByteCode/Descriptor.cpp
clang/lib/AST/ByteCode/Disasm.cpp
clang/lib/AST/ByteCode/EvalEmitter.h
clang/lib/AST/ByteCode/Frame.cpp
clang/lib/AST/ByteCode/Frame.h
clang/lib/AST/ByteCode/InterpState.h
clang/lib/AST/ByteCode/Opcode.h
clang/lib/AST/ByteCode/Pointer.cpp
clang/lib/AST/ByteCode/PrimType.cpp
clang/lib/AST/ByteCode/Record.h
clang/lib/AST/ByteCode/Source.cpp
clang/lib/AST/ByteCode/Source.h
clang/lib/AST/ByteCode/State.cpp
clang/lib/AST/ByteCode/State.h
clang/lib/ASTMatchers/GtestMatchers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/Basic/Attributes.cpp
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
//===----------------------------------------------------------------------===//

#include "clang/AST/ASTContext.h"
#include "ByteCode/Context.h"
#include "CXXABI.h"
#include "Interp/Context.h"
#include "clang/AST/APValue.h"
#include "clang/AST/ASTConcept.h"
#include "clang/AST/ASTMutationListener.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
#ifndef LLVM_CLANG_AST_INTERP_BOOLEAN_H
#define LLVM_CLANG_AST_INTERP_BOOLEAN_H

#include <cstddef>
#include <cstdint>
#include "Integral.h"
#include "clang/AST/APValue.h"
#include "clang/AST/ComparisonCategories.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
#include <cstdint>

namespace clang {
namespace interp {

/// Wrapper around boolean types.
class Boolean final {
private:
private:
/// Underlying boolean.
bool V;

public:
public:
/// Zero-initializes a boolean.
Boolean() : V(false) {}
explicit Boolean(bool V) : V(V) {}
Expand Down Expand Up @@ -104,8 +104,7 @@ class Boolean final {

static Boolean zero() { return from(false); }

template <typename T>
static Boolean from(T Value, unsigned NumBits) {
template <typename T> static Boolean from(T Value, unsigned NumBits) {
return Boolean(Value);
}

Expand Down Expand Up @@ -153,7 +152,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Boolean &B) {
return OS;
}

} // namespace interp
} // namespace clang
} // namespace interp
} // namespace clang

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ void ByteCodeEmitter::emitLabel(LabelTy Label) {
const size_t Target = Code.size();
LabelOffsets.insert({Label, Target});

if (auto It = LabelRelocs.find(Label);
It != LabelRelocs.end()) {
if (auto It = LabelRelocs.find(Label); It != LabelRelocs.end()) {
for (unsigned Reloc : It->second) {
using namespace llvm::support;

Expand All @@ -228,8 +227,7 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) {
assert(aligned(Position));

// If target is known, compute jump offset.
if (auto It = LabelOffsets.find(Label);
It != LabelOffsets.end())
if (auto It = LabelOffsets.find(Label); It != LabelOffsets.end())
return It->second - Position;

// Otherwise, record relocation and return dummy offset.
Expand Down Expand Up @@ -308,7 +306,8 @@ void emit(Program &P, std::vector<std::byte> &Code, const IntegralAP<true> &Val,
}

template <typename... Tys>
bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &... Args, const SourceInfo &SI) {
bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &...Args,
const SourceInfo &SI) {
bool Success = true;

// The opcode is followed by arguments. The source info is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ByteCodeEmitter {

/// Emits an opcode.
template <typename... Tys>
bool emitOp(Opcode Op, const Tys &... Args, const SourceInfo &L);
bool emitOp(Opcode Op, const Tys &...Args, const SourceInfo &L);

protected:
#define GET_LINK_PROTO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,8 @@ bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
}

template <class Emitter>
VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Toplevel) {
VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
bool Toplevel) {
// We don't know what to do with these, so just return false.
if (VD->getType().isNull())
return false;
Expand Down Expand Up @@ -5124,7 +5125,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
if (!this->visit(SubExpr))
return false;
return DiscardResult ? this->emitPop(*T, E) : this->emitNeg(*T, E);
case UO_Plus: // +x
case UO_Plus: // +x
if (!T)
return this->emitError(E);

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ struct Descriptor final {
/// Returns the allocated size, including metadata.
unsigned getAllocSize() const { return AllocSize; }
/// returns the size of an element when the structure is viewed as an array.
unsigned getElemSize() const { return ElemSize; }
unsigned getElemSize() const { return ElemSize; }
/// Returns the size of the metadata.
unsigned getMetadataSize() const { return MDSize; }

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD,
return std::move(this->EvalResult);
}

void EvalEmitter::emitLabel(LabelTy Label) {
CurrentLabel = Label;
}
void EvalEmitter::emitLabel(LabelTy Label) { CurrentLabel = Label; }

EvalEmitter::LabelTy EvalEmitter::getLabel() { return NextLabel++; }

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#ifndef LLVM_CLANG_AST_INTERP_INTEGRAL_H
#define LLVM_CLANG_AST_INTERP_INTEGRAL_H

#include "clang/AST/ComparisonCategories.h"
#include "clang/AST/APValue.h"
#include "clang/AST/ComparisonCategories.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
Expand All @@ -33,14 +33,30 @@ template <bool Signed> class IntegralAP;

// Helper structure to select the representation.
template <unsigned Bits, bool Signed> struct Repr;
template <> struct Repr<8, false> { using Type = uint8_t; };
template <> struct Repr<16, false> { using Type = uint16_t; };
template <> struct Repr<32, false> { using Type = uint32_t; };
template <> struct Repr<64, false> { using Type = uint64_t; };
template <> struct Repr<8, true> { using Type = int8_t; };
template <> struct Repr<16, true> { using Type = int16_t; };
template <> struct Repr<32, true> { using Type = int32_t; };
template <> struct Repr<64, true> { using Type = int64_t; };
template <> struct Repr<8, false> {
using Type = uint8_t;
};
template <> struct Repr<16, false> {
using Type = uint16_t;
};
template <> struct Repr<32, false> {
using Type = uint32_t;
};
template <> struct Repr<64, false> {
using Type = uint64_t;
};
template <> struct Repr<8, true> {
using Type = int8_t;
};
template <> struct Repr<16, true> {
using Type = int16_t;
};
template <> struct Repr<32, true> {
using Type = int32_t;
};
template <> struct Repr<64, true> {
using Type = int64_t;
};

/// Wrapper around numeric types.
///
Expand Down Expand Up @@ -159,12 +175,8 @@ template <unsigned Bits, bool Signed> class Integral final {

void print(llvm::raw_ostream &OS) const { OS << V; }

static Integral min(unsigned NumBits) {
return Integral(Min);
}
static Integral max(unsigned NumBits) {
return Integral(Max);
}
static Integral min(unsigned NumBits) { return Integral(Min); }
static Integral max(unsigned NumBits) { return Integral(Max); }

template <typename ValT> static Integral from(ValT Value) {
if constexpr (std::is_integral<ValT>::value)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
bool GetField(InterpState &S, CodePtr OpPC, uint32_t I) {
const Pointer &Obj = S.Stk.peek<Pointer>();
if (!CheckNull(S, OpPC, Obj, CSK_Field))
return false;
return false;
if (!CheckRange(S, OpPC, Obj, CSK_Field))
return false;
const Pointer &Field = Obj.atField(I);
Expand Down Expand Up @@ -1542,7 +1542,7 @@ inline bool GetPtrActiveField(InterpState &S, CodePtr OpPC, uint32_t Off) {
}

inline bool GetPtrActiveThisField(InterpState &S, CodePtr OpPC, uint32_t Off) {
if (S.checkingPotentialConstantExpression())
if (S.checkingPotentialConstantExpression())
return false;
const Pointer &This = S.Current->getThis();
if (!CheckThis(S, OpPC, This))
Expand Down Expand Up @@ -2053,7 +2053,7 @@ template <PrimType TIn, PrimType TOut> bool Cast(InterpState &S, CodePtr OpPC) {
/// 1) Pops a Floating from the stack.
/// 2) Pushes a new floating on the stack that uses the given semantics.
inline bool CastFP(InterpState &S, CodePtr OpPC, const llvm::fltSemantics *Sem,
llvm::RoundingMode RM) {
llvm::RoundingMode RM) {
Floating F = S.Stk.pop<Floating>();
Floating Result = F.toSemantics(Sem, RM);
S.Stk.push<Floating>(Result);
Expand Down Expand Up @@ -2313,9 +2313,9 @@ inline bool DoShift(InterpState &S, CodePtr OpPC, LT &LHS, RT &RHS) {
if (!S.noteUndefinedBehavior())
return false;
RHS = -RHS;
return DoShift < LT, RT,
Dir == ShiftDir::Left ? ShiftDir::Right
: ShiftDir::Left > (S, OpPC, LHS, RHS);
return DoShift<LT, RT,
Dir == ShiftDir::Left ? ShiftDir::Right : ShiftDir::Left>(
S, OpPC, LHS, RHS);
}

if constexpr (Dir == ShiftDir::Left) {
Expand Down Expand Up @@ -2467,7 +2467,8 @@ inline bool ArrayElemPop(InterpState &S, CodePtr OpPC, uint32_t Index) {
}

template <PrimType Name, class T = typename PrimConv<Name>::T>
inline bool CopyArray(InterpState &S, CodePtr OpPC, uint32_t SrcIndex, uint32_t DestIndex, uint32_t Size) {
inline bool CopyArray(InterpState &S, CodePtr OpPC, uint32_t SrcIndex,
uint32_t DestIndex, uint32_t Size) {
const auto &SrcPtr = S.Stk.pop<Pointer>();
const auto &DestPtr = S.Stk.peek<Pointer>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#define LLVM_CLANG_AST_INTERP_BLOCK_H

#include "Descriptor.h"
#include "clang/AST/ComparisonCategories.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ComparisonCategories.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/Support/raw_ostream.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx,
if (!Ty->isReferenceType())
OS << "&";
llvm::SmallVector<Pointer, 2> Levels;
for (Pointer F = P; !F.isRoot(); ) {
for (Pointer F = P; !F.isRoot();) {
Levels.push_back(F);
F = F.isArrayElement() ? F.getArray().expand() : F.getBase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class InterpFrame final : public Frame {

/// Mutates a local copy of a parameter.
template <typename T> void setParam(unsigned Offset, const T &Value) {
getParamPointer(Offset).deref<T>() = Value;
getParamPointer(Offset).deref<T>() = Value;
}

/// Returns a pointer to an argument - lazily creates a block.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
using namespace clang;
using namespace clang::interp;

InterpStack::~InterpStack() {
clear();
}
InterpStack::~InterpStack() { clear(); }

void InterpStack::clear() {
if (Chunk && Chunk->Next)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class InterpStack final {
~InterpStack();

/// Constructs a value in place on the top of the stack.
template <typename T, typename... Tys> void push(Tys &&... Args) {
template <typename T, typename... Tys> void push(Tys &&...Args) {
new (grow(aligned_size<T>())) T(std::forward<Tys>(Args)...);
#ifndef NDEBUG
ItemTypes.push_back(toPrimType<T>());
Expand Down Expand Up @@ -153,8 +153,7 @@ class InterpStack final {
template <typename T> static constexpr PrimType toPrimType() {
if constexpr (std::is_same_v<T, Pointer>)
return PT_Ptr;
else if constexpr (std::is_same_v<T, bool> ||
std::is_same_v<T, Boolean>)
else if constexpr (std::is_same_v<T, bool> || std::is_same_v<T, Boolean>)
return PT_Bool;
else if constexpr (std::is_same_v<T, int8_t> ||
std::is_same_v<T, Integral<8, true>>)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Pointer {

/// Subtract the given offset from the current Base and Offset
/// of the pointer.
[[nodiscard]] Pointer atFieldSub(unsigned Off) const {
[[nodiscard]] Pointer atFieldSub(unsigned Off) const {
assert(Offset >= Off);
unsigned O = Offset - Off;
return Pointer(asBlockPointer().Pointee, O, O);
Expand Down
File renamed without changes.
Loading