mirror of https://github.com/microsoft/clang.git
Switch CGObjCMac to use ConstantInitBuilder. Whew.
Not strictly NFC because I did change the order of emission of some global constants, but it shouldn't make any difference. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288229 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
03313c383f
commit
5050adc78c
|
@ -1621,9 +1621,6 @@ public:
|
|||
|
||||
/// \brief Emit the encoded type for the method declaration \p Decl into
|
||||
/// \p S.
|
||||
///
|
||||
/// \returns true if an error occurred (e.g., because one of the parameter
|
||||
/// types is incomplete), false otherwise.
|
||||
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
|
||||
bool Extended = false) const;
|
||||
|
||||
|
|
|
@ -463,6 +463,9 @@ public:
|
|||
ImplementationControl getImplementationControl() const {
|
||||
return ImplementationControl(DeclImplementation);
|
||||
}
|
||||
bool isOptional() const {
|
||||
return getImplementationControl() == Optional;
|
||||
}
|
||||
|
||||
/// Returns true if this specific method declaration is marked with the
|
||||
/// designated initializer attribute.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -87,7 +87,7 @@ public:
|
|||
}
|
||||
|
||||
~AggregateBuilderBase() {
|
||||
assert(Finished && "didn't claim value from aggregate builder");
|
||||
assert(Finished && "didn't finish aggregate builder");
|
||||
}
|
||||
|
||||
void markFinished() {
|
||||
|
@ -119,24 +119,81 @@ public:
|
|||
}
|
||||
AggregateBuilderBase &operator=(AggregateBuilderBase &&other) = delete;
|
||||
|
||||
/// Abandon this builder completely.
|
||||
void abandon() {
|
||||
markFinished();
|
||||
auto &buffer = Builder.Buffer;
|
||||
buffer.erase(buffer.begin() + Begin, buffer.end());
|
||||
}
|
||||
|
||||
/// Add a new value to this initializer.
|
||||
void add(llvm::Constant *value) {
|
||||
assert(value && "adding null value to constant initializer");
|
||||
assert(!Finished && "cannot add more values after finishing builder");
|
||||
assert(!Frozen && "cannot add values while subbuilder is active");
|
||||
Builder.Buffer.push_back(value);
|
||||
}
|
||||
|
||||
/// Add an integer value of type size_t.
|
||||
void addSize(CharUnits size) {
|
||||
add(Builder.CGM.getSize(size));
|
||||
}
|
||||
|
||||
/// Add an integer value of a specific type.
|
||||
void addInt(llvm::IntegerType *intTy, uint64_t value,
|
||||
bool isSigned = false) {
|
||||
add(llvm::ConstantInt::get(intTy, value, isSigned));
|
||||
}
|
||||
|
||||
/// Add a null pointer of a specific type.
|
||||
void addNullPointer(llvm::PointerType *ptrTy) {
|
||||
add(llvm::ConstantPointerNull::get(ptrTy));
|
||||
}
|
||||
|
||||
/// Add a bitcast of a value to a specific type.
|
||||
void addBitCast(llvm::Constant *value, llvm::Type *type) {
|
||||
add(llvm::ConstantExpr::getBitCast(value, type));
|
||||
}
|
||||
|
||||
/// An opaque class to hold the abstract position of a placeholder.
|
||||
class PlaceholderPosition {
|
||||
size_t Index;
|
||||
friend class AggregateBuilderBase;
|
||||
PlaceholderPosition(size_t index) : Index(index) {}
|
||||
};
|
||||
|
||||
/// Add a placeholder value to the structure. The returned position
|
||||
/// can be used to set the value later; it will not be invalidated by
|
||||
/// any intermediate operations except (1) filling the same position or
|
||||
/// (2) finishing the entire builder.
|
||||
///
|
||||
/// This is useful for emitting certain kinds of structure which
|
||||
/// contain some sort of summary field, generaly a count, before any
|
||||
/// of the data. By emitting a placeholder first, the structure can
|
||||
/// be emitted eagerly.
|
||||
PlaceholderPosition addPlaceholder() {
|
||||
assert(!Finished && "cannot add more values after finishing builder");
|
||||
assert(!Frozen && "cannot add values while subbuilder is active");
|
||||
Builder.Buffer.push_back(nullptr);
|
||||
return Builder.Buffer.size() - 1;
|
||||
}
|
||||
|
||||
/// Fill a previously-added placeholder.
|
||||
void fillPlaceholderWithInt(PlaceholderPosition position,
|
||||
llvm::IntegerType *type, uint64_t value,
|
||||
bool isSigned = false) {
|
||||
fillPlaceholder(position, llvm::ConstantInt::get(type, value, isSigned));
|
||||
}
|
||||
|
||||
/// Fill a previously-added placeholder.
|
||||
void fillPlaceholder(PlaceholderPosition position, llvm::Constant *value) {
|
||||
assert(!Finished && "cannot change values after finishing builder");
|
||||
assert(!Frozen && "cannot add values while subbuilder is active");
|
||||
llvm::Constant *&slot = Builder.Buffer[position.Index];
|
||||
assert(slot == nullptr && "placeholder already filled");
|
||||
slot = value;
|
||||
}
|
||||
|
||||
ArrayRef<llvm::Constant*> getGEPIndicesToCurrentPosition(
|
||||
llvm::SmallVectorImpl<llvm::Constant*> &indices) {
|
||||
getGEPIndicesTo(indices, Builder.Buffer.size());
|
||||
|
@ -214,7 +271,7 @@ public:
|
|||
|
||||
private:
|
||||
llvm::GlobalVariable *createGlobal(llvm::Constant *initializer,
|
||||
StringRef name,
|
||||
const llvm::Twine &name,
|
||||
CharUnits alignment,
|
||||
bool constant = false,
|
||||
llvm::GlobalValue::LinkageTypes linkage
|
||||
|
@ -257,6 +314,10 @@ public:
|
|||
return getBuffer().size() - Begin;
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
private:
|
||||
/// Form an array constant from the values that have been added to this
|
||||
/// builder.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s
|
||||
// RUN: FileCheck < %t %s
|
||||
//
|
||||
// CHECK: @OBJC_METH_VAR_TYPE_.34 = private unnamed_addr constant [16 x i8] c"v12@0:4[3[4@]]8\00"
|
||||
// CHECK: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant [16 x i8] c"v12@0:4[3[4@]]8\00"
|
||||
|
||||
@class Int1;
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
// CHECK: .lazy_reference .objc_class_name_J0
|
||||
|
||||
// CHECK: @OBJC_METH_VAR_NAME_{{[0-9]*}} = private unnamed_addr constant {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
|
||||
// CHECK: @OBJC_METH_VAR_TYPE_{{[0-9]*}} = private unnamed_addr constant {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
|
||||
// CHECK: @"\01l_OBJC_PROTOCOLEXT_P" = private global
|
||||
// CHECK-NOT: section
|
||||
// CHECK: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
|
||||
// CHECK: @"\01l_OBJC_PROTOCOLEXT_P" = private global {{.*}}}, align
|
||||
// CHECK: @OBJC_CLASS_NAME_{{[0-9]*}} = private unnamed_addr constant {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
|
||||
// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
|
||||
// CHECK: @OBJC_PROTOCOL_INSTANCE_METHODS_P = private global {{.*}}section "__OBJC,__cat_inst_meth,regular,no_dead_strip", align 4
|
||||
// CHECK: @OBJC_PROTOCOL_CLASS_METHODS_P = private global {{.*}}section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
|
||||
// CHECK: @OBJC_PROTOCOL_P = private global {{.*}}section "__OBJC,__protocol,regular,no_dead_strip", align 4
|
||||
|
|
Loading…
Reference in New Issue