Skip to content

Commit a07aba5

Browse files
authored
[clang] Rename all AST/Interp stuff to AST/ByteCode (#104552)
"Interp" clashes with the clang interpreter and people often confuse this.
1 parent ef6e7af commit a07aba5

File tree

127 files changed

+198
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+198
-167
lines changed

clang/docs/ClangFormattedStatus.rst

Lines changed: 1 addition & 1 deletion

clang/docs/tools/clang-formatted-files.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -322,24 +322,24 @@ clang/lib/APINotes/APINotesTypes.cpp
322322
clang/lib/APINotes/APINotesYAMLCompiler.cpp
323323
clang/lib/AST/DataCollection.cpp
324324
clang/lib/AST/Linkage.h
325-
clang/lib/AST/Interp/ByteCodeGenError.cpp
326-
clang/lib/AST/Interp/ByteCodeGenError.h
327-
clang/lib/AST/Interp/Context.cpp
328-
clang/lib/AST/Interp/Context.h
329-
clang/lib/AST/Interp/Descriptor.cpp
330-
clang/lib/AST/Interp/Disasm.cpp
331-
clang/lib/AST/Interp/EvalEmitter.h
332-
clang/lib/AST/Interp/Frame.cpp
333-
clang/lib/AST/Interp/Frame.h
334-
clang/lib/AST/Interp/InterpState.h
335-
clang/lib/AST/Interp/Opcode.h
336-
clang/lib/AST/Interp/Pointer.cpp
337-
clang/lib/AST/Interp/PrimType.cpp
338-
clang/lib/AST/Interp/Record.h
339-
clang/lib/AST/Interp/Source.cpp
340-
clang/lib/AST/Interp/Source.h
341-
clang/lib/AST/Interp/State.cpp
342-
clang/lib/AST/Interp/State.h
325+
clang/lib/AST/ByteCode/ByteCodeGenError.cpp
326+
clang/lib/AST/ByteCode/ByteCodeGenError.h
327+
clang/lib/AST/ByteCode/Context.cpp
328+
clang/lib/AST/ByteCode/Context.h
329+
clang/lib/AST/ByteCode/Descriptor.cpp
330+
clang/lib/AST/ByteCode/Disasm.cpp
331+
clang/lib/AST/ByteCode/EvalEmitter.h
332+
clang/lib/AST/ByteCode/Frame.cpp
333+
clang/lib/AST/ByteCode/Frame.h
334+
clang/lib/AST/ByteCode/InterpState.h
335+
clang/lib/AST/ByteCode/Opcode.h
336+
clang/lib/AST/ByteCode/Pointer.cpp
337+
clang/lib/AST/ByteCode/PrimType.cpp
338+
clang/lib/AST/ByteCode/Record.h
339+
clang/lib/AST/ByteCode/Source.cpp
340+
clang/lib/AST/ByteCode/Source.h
341+
clang/lib/AST/ByteCode/State.cpp
342+
clang/lib/AST/ByteCode/State.h
343343
clang/lib/ASTMatchers/GtestMatchers.cpp
344344
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
345345
clang/lib/Basic/Attributes.cpp

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "clang/AST/ASTContext.h"
14+
#include "ByteCode/Context.h"
1415
#include "CXXABI.h"
15-
#include "Interp/Context.h"
1616
#include "clang/AST/APValue.h"
1717
#include "clang/AST/ASTConcept.h"
1818
#include "clang/AST/ASTMutationListener.h"

clang/lib/AST/Interp/Boolean.h renamed to clang/lib/AST/ByteCode/Boolean.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
#ifndef LLVM_CLANG_AST_INTERP_BOOLEAN_H
1010
#define LLVM_CLANG_AST_INTERP_BOOLEAN_H
1111

12-
#include <cstddef>
13-
#include <cstdint>
1412
#include "Integral.h"
1513
#include "clang/AST/APValue.h"
1614
#include "clang/AST/ComparisonCategories.h"
1715
#include "llvm/ADT/APSInt.h"
1816
#include "llvm/Support/MathExtras.h"
1917
#include "llvm/Support/raw_ostream.h"
18+
#include <cstddef>
19+
#include <cstdint>
2020

2121
namespace clang {
2222
namespace interp {
2323

2424
/// Wrapper around boolean types.
2525
class Boolean final {
26-
private:
26+
private:
2727
/// Underlying boolean.
2828
bool V;
2929

30-
public:
30+
public:
3131
/// Zero-initializes a boolean.
3232
Boolean() : V(false) {}
3333
explicit Boolean(bool V) : V(V) {}
@@ -104,8 +104,7 @@ class Boolean final {
104104

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

107-
template <typename T>
108-
static Boolean from(T Value, unsigned NumBits) {
107+
template <typename T> static Boolean from(T Value, unsigned NumBits) {
109108
return Boolean(Value);
110109
}
111110

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

156-
} // namespace interp
157-
} // namespace clang
155+
} // namespace interp
156+
} // namespace clang
158157

159158
#endif

clang/lib/AST/Interp/ByteCodeEmitter.cpp renamed to clang/lib/AST/ByteCode/ByteCodeEmitter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ void ByteCodeEmitter::emitLabel(LabelTy Label) {
206206
const size_t Target = Code.size();
207207
LabelOffsets.insert({Label, Target});
208208

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

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

230229
// If target is known, compute jump offset.
231-
if (auto It = LabelOffsets.find(Label);
232-
It != LabelOffsets.end())
230+
if (auto It = LabelOffsets.find(Label); It != LabelOffsets.end())
233231
return It->second - Position;
234232

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

310308
template <typename... Tys>
311-
bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &... Args, const SourceInfo &SI) {
309+
bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &...Args,
310+
const SourceInfo &SI) {
312311
bool Success = true;
313312

314313
// The opcode is followed by arguments. The source info is

clang/lib/AST/Interp/ByteCodeEmitter.h renamed to clang/lib/AST/ByteCode/ByteCodeEmitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ByteCodeEmitter {
9292

9393
/// Emits an opcode.
9494
template <typename... Tys>
95-
bool emitOp(Opcode Op, const Tys &... Args, const SourceInfo &L);
95+
bool emitOp(Opcode Op, const Tys &...Args, const SourceInfo &L);
9696

9797
protected:
9898
#define GET_LINK_PROTO

clang/lib/AST/Interp/Compiler.cpp renamed to clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,7 +3722,8 @@ bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
37223722
}
37233723

37243724
template <class Emitter>
3725-
VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Toplevel) {
3725+
VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
3726+
bool Toplevel) {
37263727
// We don't know what to do with these, so just return false.
37273728
if (VD->getType().isNull())
37283729
return false;
@@ -5124,7 +5125,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
51245125
if (!this->visit(SubExpr))
51255126
return false;
51265127
return DiscardResult ? this->emitPop(*T, E) : this->emitNeg(*T, E);
5127-
case UO_Plus: // +x
5128+
case UO_Plus: // +x
51285129
if (!T)
51295130
return this->emitError(E);
51305131

File renamed without changes.
File renamed without changes.
File renamed without changes.

clang/lib/AST/Interp/Descriptor.h renamed to clang/lib/AST/ByteCode/Descriptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ struct Descriptor final {
229229
/// Returns the allocated size, including metadata.
230230
unsigned getAllocSize() const { return AllocSize; }
231231
/// returns the size of an element when the structure is viewed as an array.
232-
unsigned getElemSize() const { return ElemSize; }
232+
unsigned getElemSize() const { return ElemSize; }
233233
/// Returns the size of the metadata.
234234
unsigned getMetadataSize() const { return MDSize; }
235235

File renamed without changes.

clang/lib/AST/Interp/EvalEmitter.cpp renamed to clang/lib/AST/ByteCode/EvalEmitter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD,
7676
return std::move(this->EvalResult);
7777
}
7878

79-
void EvalEmitter::emitLabel(LabelTy Label) {
80-
CurrentLabel = Label;
81-
}
79+
void EvalEmitter::emitLabel(LabelTy Label) { CurrentLabel = Label; }
8280

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

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

clang/lib/AST/Interp/Integral.h renamed to clang/lib/AST/ByteCode/Integral.h

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#ifndef LLVM_CLANG_AST_INTERP_INTEGRAL_H
1414
#define LLVM_CLANG_AST_INTERP_INTEGRAL_H
1515

16-
#include "clang/AST/ComparisonCategories.h"
1716
#include "clang/AST/APValue.h"
17+
#include "clang/AST/ComparisonCategories.h"
1818
#include "llvm/ADT/APSInt.h"
1919
#include "llvm/Support/MathExtras.h"
2020
#include "llvm/Support/raw_ostream.h"
@@ -33,14 +33,30 @@ template <bool Signed> class IntegralAP;
3333

3434
// Helper structure to select the representation.
3535
template <unsigned Bits, bool Signed> struct Repr;
36-
template <> struct Repr<8, false> { using Type = uint8_t; };
37-
template <> struct Repr<16, false> { using Type = uint16_t; };
38-
template <> struct Repr<32, false> { using Type = uint32_t; };
39-
template <> struct Repr<64, false> { using Type = uint64_t; };
40-
template <> struct Repr<8, true> { using Type = int8_t; };
41-
template <> struct Repr<16, true> { using Type = int16_t; };
42-
template <> struct Repr<32, true> { using Type = int32_t; };
43-
template <> struct Repr<64, true> { using Type = int64_t; };
36+
template <> struct Repr<8, false> {
37+
using Type = uint8_t;
38+
};
39+
template <> struct Repr<16, false> {
40+
using Type = uint16_t;
41+
};
42+
template <> struct Repr<32, false> {
43+
using Type = uint32_t;
44+
};
45+
template <> struct Repr<64, false> {
46+
using Type = uint64_t;
47+
};
48+
template <> struct Repr<8, true> {
49+
using Type = int8_t;
50+
};
51+
template <> struct Repr<16, true> {
52+
using Type = int16_t;
53+
};
54+
template <> struct Repr<32, true> {
55+
using Type = int32_t;
56+
};
57+
template <> struct Repr<64, true> {
58+
using Type = int64_t;
59+
};
4460

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

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

162-
static Integral min(unsigned NumBits) {
163-
return Integral(Min);
164-
}
165-
static Integral max(unsigned NumBits) {
166-
return Integral(Max);
167-
}
178+
static Integral min(unsigned NumBits) { return Integral(Min); }
179+
static Integral max(unsigned NumBits) { return Integral(Max); }
168180

169181
template <typename ValT> static Integral from(ValT Value) {
170182
if constexpr (std::is_integral<ValT>::value)
File renamed without changes.

clang/lib/AST/Interp/Interp.h renamed to clang/lib/AST/ByteCode/Interp.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
12261226
bool GetField(InterpState &S, CodePtr OpPC, uint32_t I) {
12271227
const Pointer &Obj = S.Stk.peek<Pointer>();
12281228
if (!CheckNull(S, OpPC, Obj, CSK_Field))
1229-
return false;
1229+
return false;
12301230
if (!CheckRange(S, OpPC, Obj, CSK_Field))
12311231
return false;
12321232
const Pointer &Field = Obj.atField(I);
@@ -1542,7 +1542,7 @@ inline bool GetPtrActiveField(InterpState &S, CodePtr OpPC, uint32_t Off) {
15421542
}
15431543

15441544
inline bool GetPtrActiveThisField(InterpState &S, CodePtr OpPC, uint32_t Off) {
1545-
if (S.checkingPotentialConstantExpression())
1545+
if (S.checkingPotentialConstantExpression())
15461546
return false;
15471547
const Pointer &This = S.Current->getThis();
15481548
if (!CheckThis(S, OpPC, This))
@@ -2053,7 +2053,7 @@ template <PrimType TIn, PrimType TOut> bool Cast(InterpState &S, CodePtr OpPC) {
20532053
/// 1) Pops a Floating from the stack.
20542054
/// 2) Pushes a new floating on the stack that uses the given semantics.
20552055
inline bool CastFP(InterpState &S, CodePtr OpPC, const llvm::fltSemantics *Sem,
2056-
llvm::RoundingMode RM) {
2056+
llvm::RoundingMode RM) {
20572057
Floating F = S.Stk.pop<Floating>();
20582058
Floating Result = F.toSemantics(Sem, RM);
20592059
S.Stk.push<Floating>(Result);
@@ -2313,9 +2313,9 @@ inline bool DoShift(InterpState &S, CodePtr OpPC, LT &LHS, RT &RHS) {
23132313
if (!S.noteUndefinedBehavior())
23142314
return false;
23152315
RHS = -RHS;
2316-
return DoShift < LT, RT,
2317-
Dir == ShiftDir::Left ? ShiftDir::Right
2318-
: ShiftDir::Left > (S, OpPC, LHS, RHS);
2316+
return DoShift<LT, RT,
2317+
Dir == ShiftDir::Left ? ShiftDir::Right : ShiftDir::Left>(
2318+
S, OpPC, LHS, RHS);
23192319
}
23202320

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

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

clang/lib/AST/Interp/InterpBlock.h renamed to clang/lib/AST/ByteCode/InterpBlock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#define LLVM_CLANG_AST_INTERP_BLOCK_H
1515

1616
#include "Descriptor.h"
17+
#include "clang/AST/ComparisonCategories.h"
1718
#include "clang/AST/Decl.h"
1819
#include "clang/AST/DeclCXX.h"
1920
#include "clang/AST/Expr.h"
20-
#include "clang/AST/ComparisonCategories.h"
2121
#include "llvm/ADT/PointerUnion.h"
2222
#include "llvm/Support/raw_ostream.h"
2323

clang/lib/AST/Interp/InterpFrame.cpp renamed to clang/lib/AST/ByteCode/InterpFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx,
137137
if (!Ty->isReferenceType())
138138
OS << "&";
139139
llvm::SmallVector<Pointer, 2> Levels;
140-
for (Pointer F = P; !F.isRoot(); ) {
140+
for (Pointer F = P; !F.isRoot();) {
141141
Levels.push_back(F);
142142
F = F.isArrayElement() ? F.getArray().expand() : F.getBase();
143143
}

clang/lib/AST/Interp/InterpFrame.h renamed to clang/lib/AST/ByteCode/InterpFrame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class InterpFrame final : public Frame {
9191

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

9797
/// Returns a pointer to an argument - lazily creates a block.

clang/lib/AST/Interp/InterpStack.cpp renamed to clang/lib/AST/ByteCode/InterpStack.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
using namespace clang;
1919
using namespace clang::interp;
2020

21-
InterpStack::~InterpStack() {
22-
clear();
23-
}
21+
InterpStack::~InterpStack() { clear(); }
2422

2523
void InterpStack::clear() {
2624
if (Chunk && Chunk->Next)

clang/lib/AST/Interp/InterpStack.h renamed to clang/lib/AST/ByteCode/InterpStack.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class InterpStack final {
3232
~InterpStack();
3333

3434
/// Constructs a value in place on the top of the stack.
35-
template <typename T, typename... Tys> void push(Tys &&... Args) {
35+
template <typename T, typename... Tys> void push(Tys &&...Args) {
3636
new (grow(aligned_size<T>())) T(std::forward<Tys>(Args)...);
3737
#ifndef NDEBUG
3838
ItemTypes.push_back(toPrimType<T>());
@@ -153,8 +153,7 @@ class InterpStack final {
153153
template <typename T> static constexpr PrimType toPrimType() {
154154
if constexpr (std::is_same_v<T, Pointer>)
155155
return PT_Ptr;
156-
else if constexpr (std::is_same_v<T, bool> ||
157-
std::is_same_v<T, Boolean>)
156+
else if constexpr (std::is_same_v<T, bool> || std::is_same_v<T, Boolean>)
158157
return PT_Bool;
159158
else if constexpr (std::is_same_v<T, int8_t> ||
160159
std::is_same_v<T, Integral<8, true>>)
File renamed without changes.
File renamed without changes.
File renamed without changes.

clang/lib/AST/Interp/Pointer.h renamed to clang/lib/AST/ByteCode/Pointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class Pointer {
173173

174174
/// Subtract the given offset from the current Base and Offset
175175
/// of the pointer.
176-
[[nodiscard]] Pointer atFieldSub(unsigned Off) const {
176+
[[nodiscard]] Pointer atFieldSub(unsigned Off) const {
177177
assert(Offset >= Off);
178178
unsigned O = Offset - Off;
179179
return Pointer(asBlockPointer().Pointee, O, O);

0 commit comments

Comments
 (0)