librustc_llvm: use #[deriving(Copy)]

This commit is contained in:
Jorge Aparicio 2014-12-14 23:09:35 -05:00
parent db45be2616
commit 463475b7fa
2 changed files with 22 additions and 49 deletions

View file

@ -17,6 +17,7 @@ use libc::c_char;
use {ValueRef, TwineRef, DebugLocRef, DiagnosticInfoRef};
#[deriving(Copy)]
pub enum OptimizationDiagnosticKind {
OptimizationRemark,
OptimizationMissed,
@ -24,8 +25,6 @@ pub enum OptimizationDiagnosticKind {
OptimizationFailure,
}
impl Copy for OptimizationDiagnosticKind {}
impl OptimizationDiagnosticKind {
pub fn describe(self) -> &'static str {
match self {
@ -69,6 +68,7 @@ impl OptimizationDiagnostic {
}
}
#[deriving(Copy)]
pub enum Diagnostic {
Optimization(OptimizationDiagnostic),
@ -76,8 +76,6 @@ pub enum Diagnostic {
UnknownDiagnostic(DiagnosticInfoRef),
}
impl Copy for Diagnostic {}
impl Diagnostic {
pub unsafe fn unpack(di: DiagnosticInfoRef) -> Diagnostic {
let kind = super::LLVMGetDiagInfoKind(di);

View file

@ -68,7 +68,7 @@ pub const False: Bool = 0 as Bool;
// Consts for the LLVM CallConv type, pre-cast to uint.
#[deriving(PartialEq)]
#[deriving(Copy, PartialEq)]
pub enum CallConv {
CCallConv = 0,
FastCallConv = 8,
@ -78,20 +78,18 @@ pub enum CallConv {
X86_64_Win64 = 79,
}
impl Copy for CallConv {}
#[deriving(Copy)]
pub enum Visibility {
LLVMDefaultVisibility = 0,
HiddenVisibility = 1,
ProtectedVisibility = 2,
}
impl Copy for Visibility {}
// This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
// DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
// LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
// they've been removed in upstream LLVM commit r203866.
#[deriving(Copy)]
pub enum Linkage {
ExternalLinkage = 0,
AvailableExternallyLinkage = 1,
@ -106,10 +104,8 @@ pub enum Linkage {
CommonLinkage = 14,
}
impl Copy for Linkage {}
#[repr(C)]
#[deriving(Show)]
#[deriving(Copy, Show)]
pub enum DiagnosticSeverity {
Error,
Warning,
@ -117,8 +113,6 @@ pub enum DiagnosticSeverity {
Note,
}
impl Copy for DiagnosticSeverity {}
bitflags! {
flags Attribute : u32 {
const ZExtAttribute = 1 << 0,
@ -152,6 +146,7 @@ bitflags! {
#[repr(u64)]
#[deriving(Copy)]
pub enum OtherAttribute {
// The following are not really exposed in
// the LLVM c api so instead to add these
@ -172,22 +167,18 @@ pub enum OtherAttribute {
NonNullAttribute = 1 << 44,
}
impl Copy for OtherAttribute {}
#[deriving(Copy)]
pub enum SpecialAttribute {
DereferenceableAttribute(u64)
}
impl Copy for SpecialAttribute {}
#[repr(C)]
#[deriving(Copy)]
pub enum AttributeSet {
ReturnIndex = 0,
FunctionIndex = !0
}
impl Copy for AttributeSet {}
pub trait AttrHelper {
fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
@ -274,6 +265,7 @@ impl AttrBuilder {
}
// enum for the LLVM IntPredicate type
#[deriving(Copy)]
pub enum IntPredicate {
IntEQ = 32,
IntNE = 33,
@ -287,9 +279,8 @@ pub enum IntPredicate {
IntSLE = 41,
}
impl Copy for IntPredicate {}
// enum for the LLVM RealPredicate type
#[deriving(Copy)]
pub enum RealPredicate {
RealPredicateFalse = 0,
RealOEQ = 1,
@ -309,11 +300,9 @@ pub enum RealPredicate {
RealPredicateTrue = 15,
}
impl Copy for RealPredicate {}
// The LLVM TypeKind type - must stay in sync with the def of
// LLVMTypeKind in llvm/include/llvm-c/Core.h
#[deriving(PartialEq)]
#[deriving(Copy, PartialEq)]
#[repr(C)]
pub enum TypeKind {
Void = 0,
@ -334,9 +323,8 @@ pub enum TypeKind {
X86_MMX = 15,
}
impl Copy for TypeKind {}
#[repr(C)]
#[deriving(Copy)]
pub enum AtomicBinOp {
AtomicXchg = 0,
AtomicAdd = 1,
@ -351,9 +339,8 @@ pub enum AtomicBinOp {
AtomicUMin = 10,
}
impl Copy for AtomicBinOp {}
#[repr(C)]
#[deriving(Copy)]
pub enum AtomicOrdering {
NotAtomic = 0,
Unordered = 1,
@ -365,17 +352,15 @@ pub enum AtomicOrdering {
SequentiallyConsistent = 7
}
impl Copy for AtomicOrdering {}
// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
#[repr(C)]
#[deriving(Copy)]
pub enum FileType {
AssemblyFileType = 0,
ObjectFileType = 1
}
impl Copy for FileType {}
#[deriving(Copy)]
pub enum MetadataType {
MD_dbg = 0,
MD_tbaa = 1,
@ -385,17 +370,14 @@ pub enum MetadataType {
MD_tbaa_struct = 5
}
impl Copy for MetadataType {}
// Inline Asm Dialect
#[deriving(Copy)]
pub enum AsmDialect {
AD_ATT = 0,
AD_Intel = 1
}
impl Copy for AsmDialect {}
#[deriving(PartialEq, Clone)]
#[deriving(Copy, PartialEq, Clone)]
#[repr(C)]
pub enum CodeGenOptLevel {
CodeGenLevelNone = 0,
@ -404,9 +386,7 @@ pub enum CodeGenOptLevel {
CodeGenLevelAggressive = 3,
}
impl Copy for CodeGenOptLevel {}
#[deriving(PartialEq)]
#[deriving(Copy, PartialEq)]
#[repr(C)]
pub enum RelocMode {
RelocDefault = 0,
@ -415,9 +395,8 @@ pub enum RelocMode {
RelocDynamicNoPic = 3,
}
impl Copy for RelocMode {}
#[repr(C)]
#[deriving(Copy)]
pub enum CodeGenModel {
CodeModelDefault = 0,
CodeModelJITDefault = 1,
@ -427,9 +406,8 @@ pub enum CodeGenModel {
CodeModelLarge = 5,
}
impl Copy for CodeGenModel {}
#[repr(C)]
#[deriving(Copy)]
pub enum DiagnosticKind {
DK_InlineAsm = 0,
DK_StackSize,
@ -441,8 +419,6 @@ pub enum DiagnosticKind {
DK_OptimizationFailure,
}
impl Copy for DiagnosticKind {}
// Opaque pointer types
#[allow(missing_copy_implementations)]
pub enum Module_opaque {}
@ -537,6 +513,7 @@ pub mod debuginfo {
pub type DIArray = DIDescriptor;
pub type DISubrange = DIDescriptor;
#[deriving(Copy)]
pub enum DIDescriptorFlags {
FlagPrivate = 1 << 0,
FlagProtected = 1 << 1,
@ -555,8 +532,6 @@ pub mod debuginfo {
FlagLValueReference = 1 << 14,
FlagRValueReference = 1 << 15
}
impl Copy for DIDescriptorFlags {}
}