From 5c0997f066958d65d9705126e0dce1262756b813 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 20 Jun 2012 08:39:33 +0000 Subject: [PATCH] Remove 'static' from inline functions defined in header files. There is a pretty staggering amount of this in LLVM's header files, this is not all of the instances I'm afraid. These include all of the functions that (in my build) are used by a non-static inline (or external) function. Specifically, these issues were caught by the new '-Winternal-linkage-in-inline' warning. I'll try to just clean up the remainder of the clearly redundant "static inline" cases on functions (not methods!) defined within headers if I can do so in a reliable way. There were even several cases of a missing 'inline' altogether, or my personal favorite "static bool inline". Go figure. ;] llvm-svn: 158800 --- llvm/include/llvm/ADT/STLExtras.h | 10 +++++----- llvm/include/llvm/Analysis/Dominators.h | 4 ++-- llvm/include/llvm/Analysis/LoopInfo.h | 2 +- llvm/include/llvm/Bitcode/ReaderWriter.h | 18 +++++++++--------- llvm/include/llvm/CodeGen/MachineInstrBundle.h | 4 ++-- llvm/include/llvm/Instructions.h | 2 +- llvm/include/llvm/Object/ObjectFile.h | 4 ++-- llvm/include/llvm/Support/AlignOf.h | 2 +- llvm/include/llvm/Support/Endian.h | 8 ++++---- llvm/include/llvm/Support/MathExtras.h | 4 ++-- llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h | 14 +++++++------- 11 files changed, 36 insertions(+), 36 deletions(-) diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index 58a23d886f8e..aee500d4fb6c 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -59,7 +59,7 @@ struct greater_ptr : public std::binary_function { // for_each(V.begin(), B.end(), deleter); // template -static inline void deleter(T *Ptr) { +inline void deleter(T *Ptr) { delete Ptr; } @@ -238,7 +238,7 @@ inline size_t array_lengthof(T (&)[N]) { /// array_pod_sort_comparator - This is helper function for array_pod_sort, /// which just uses operator< on T. template -static inline int array_pod_sort_comparator(const void *P1, const void *P2) { +inline int array_pod_sort_comparator(const void *P1, const void *P2) { if (*reinterpret_cast(P1) < *reinterpret_cast(P2)) return -1; if (*reinterpret_cast(P2) < *reinterpret_cast(P1)) @@ -249,7 +249,7 @@ static inline int array_pod_sort_comparator(const void *P1, const void *P2) { /// get_array_pad_sort_comparator - This is an internal helper function used to /// get type deduction of T right. template -static int (*get_array_pad_sort_comparator(const T &)) +inline int (*get_array_pad_sort_comparator(const T &)) (const void*, const void*) { return array_pod_sort_comparator; } @@ -270,7 +270,7 @@ static int (*get_array_pad_sort_comparator(const T &)) /// NOTE: If qsort_r were portable, we could allow a custom comparator and /// default to std::less. template -static inline void array_pod_sort(IteratorTy Start, IteratorTy End) { +inline void array_pod_sort(IteratorTy Start, IteratorTy End) { // Don't dereference start iterator of empty sequence. if (Start == End) return; qsort(&*Start, End-Start, sizeof(*Start), @@ -278,7 +278,7 @@ static inline void array_pod_sort(IteratorTy Start, IteratorTy End) { } template -static inline void array_pod_sort(IteratorTy Start, IteratorTy End, +inline void array_pod_sort(IteratorTy Start, IteratorTy End, int (*Compare)(const void*, const void*)) { // Don't dereference start iterator of empty sequence. if (Start == End) return; diff --git a/llvm/include/llvm/Analysis/Dominators.h b/llvm/include/llvm/Analysis/Dominators.h index 6e8e4246367e..45be59b97413 100644 --- a/llvm/include/llvm/Analysis/Dominators.h +++ b/llvm/include/llvm/Analysis/Dominators.h @@ -152,7 +152,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase); EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase); template -static raw_ostream &operator<<(raw_ostream &o, +inline raw_ostream &operator<<(raw_ostream &o, const DomTreeNodeBase *Node) { if (Node->getBlock()) WriteAsOperand(o, Node->getBlock(), false); @@ -165,7 +165,7 @@ static raw_ostream &operator<<(raw_ostream &o, } template -static void PrintDomTree(const DomTreeNodeBase *N, raw_ostream &o, +inline void PrintDomTree(const DomTreeNodeBase *N, raw_ostream &o, unsigned Lev) { o.indent(2*Lev) << "[" << Lev << "] " << N; for (typename DomTreeNodeBase::const_iterator I = N->begin(), diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index 329650e81f32..453633b3050d 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/include/llvm/Analysis/LoopInfo.h @@ -46,7 +46,7 @@ namespace llvm { template -static void RemoveFromVector(std::vector &V, T *N) { +inline void RemoveFromVector(std::vector &V, T *N) { typename std::vector::iterator I = std::find(V.begin(), V.end(), N); assert(I != V.end() && "N is not in this list!"); V.erase(I); diff --git a/llvm/include/llvm/Bitcode/ReaderWriter.h b/llvm/include/llvm/Bitcode/ReaderWriter.h index cc2b473f2c57..dd96b043fc95 100644 --- a/llvm/include/llvm/Bitcode/ReaderWriter.h +++ b/llvm/include/llvm/Bitcode/ReaderWriter.h @@ -71,8 +71,8 @@ namespace llvm { /// isBitcodeWrapper - Return true if the given bytes are the magic bytes /// for an LLVM IR bitcode wrapper. /// - static inline bool isBitcodeWrapper(const unsigned char *BufPtr, - const unsigned char *BufEnd) { + inline bool isBitcodeWrapper(const unsigned char *BufPtr, + const unsigned char *BufEnd) { // See if you can find the hidden message in the magic bytes :-). // (Hint: it's a little-endian encoding.) return BufPtr != BufEnd && @@ -85,8 +85,8 @@ namespace llvm { /// isRawBitcode - Return true if the given bytes are the magic bytes for /// raw LLVM IR bitcode (without a wrapper). /// - static inline bool isRawBitcode(const unsigned char *BufPtr, - const unsigned char *BufEnd) { + inline bool isRawBitcode(const unsigned char *BufPtr, + const unsigned char *BufEnd) { // These bytes sort of have a hidden message, but it's not in // little-endian this time, and it's a little redundant. return BufPtr != BufEnd && @@ -99,8 +99,8 @@ namespace llvm { /// isBitcode - Return true if the given bytes are the magic bytes for /// LLVM IR bitcode, either with or without a wrapper. /// - static bool inline isBitcode(const unsigned char *BufPtr, - const unsigned char *BufEnd) { + inline bool isBitcode(const unsigned char *BufPtr, + const unsigned char *BufEnd) { return isBitcodeWrapper(BufPtr, BufEnd) || isRawBitcode(BufPtr, BufEnd); } @@ -121,9 +121,9 @@ namespace llvm { /// BC file. /// If 'VerifyBufferSize' is true, check that the buffer is large enough to /// contain the whole bitcode file. - static inline bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr, - const unsigned char *&BufEnd, - bool VerifyBufferSize) { + inline bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr, + const unsigned char *&BufEnd, + bool VerifyBufferSize) { enum { KnownHeaderSize = 4*4, // Size of header we read. OffsetField = 2*4, // Offset in bytes to Offset field. diff --git a/llvm/include/llvm/CodeGen/MachineInstrBundle.h b/llvm/include/llvm/CodeGen/MachineInstrBundle.h index 0fb496982276..dc5f9a6ec82d 100644 --- a/llvm/include/llvm/CodeGen/MachineInstrBundle.h +++ b/llvm/include/llvm/CodeGen/MachineInstrBundle.h @@ -43,14 +43,14 @@ bool finalizeBundles(MachineFunction &MF); /// getBundleStart - Returns the first instruction in the bundle containing MI. /// -static inline MachineInstr *getBundleStart(MachineInstr *MI) { +inline MachineInstr *getBundleStart(MachineInstr *MI) { MachineBasicBlock::instr_iterator I = MI; while (I->isInsideBundle()) --I; return I; } -static inline const MachineInstr *getBundleStart(const MachineInstr *MI) { +inline const MachineInstr *getBundleStart(const MachineInstr *MI) { MachineBasicBlock::const_instr_iterator I = MI; while (I->isInsideBundle()) --I; diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h index f5a48cd47e09..955522539e01 100644 --- a/llvm/include/llvm/Instructions.h +++ b/llvm/include/llvm/Instructions.h @@ -701,7 +701,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(AtomicRMWInst, Value) // checkGEPType - Simple wrapper function to give a better assertion failure // message on bad indexes for a gep instruction. // -static inline Type *checkGEPType(Type *Ty) { +inline Type *checkGEPType(Type *Ty) { assert(Ty && "Invalid GetElementPtrInst indices for type!"); return Ty; } diff --git a/llvm/include/llvm/Object/ObjectFile.h b/llvm/include/llvm/Object/ObjectFile.h index 76b493eba326..2ec656b0124e 100644 --- a/llvm/include/llvm/Object/ObjectFile.h +++ b/llvm/include/llvm/Object/ObjectFile.h @@ -76,13 +76,13 @@ public: } }; -static bool operator ==(const DataRefImpl &a, const DataRefImpl &b) { +inline bool operator ==(const DataRefImpl &a, const DataRefImpl &b) { // Check bitwise identical. This is the only legal way to compare a union w/o // knowing which member is in use. return std::memcmp(&a, &b, sizeof(DataRefImpl)) == 0; } -static bool operator <(const DataRefImpl &a, const DataRefImpl &b) { +inline bool operator <(const DataRefImpl &a, const DataRefImpl &b) { // Check bitwise identical. This is the only legal way to compare a union w/o // knowing which member is in use. return std::memcmp(&a, &b, sizeof(DataRefImpl)) < 0; diff --git a/llvm/include/llvm/Support/AlignOf.h b/llvm/include/llvm/Support/AlignOf.h index b63e75fd662d..447b1a2e9f74 100644 --- a/llvm/include/llvm/Support/AlignOf.h +++ b/llvm/include/llvm/Support/AlignOf.h @@ -57,7 +57,7 @@ struct AlignOf { /// class besides some cosmetic cleanliness. Example usage: /// alignOf() returns the alignment of an int. template -static inline unsigned alignOf() { return AlignOf::Alignment; } +inline unsigned alignOf() { return AlignOf::Alignment; } /// \brief Helper for building an aligned character array type. diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h index 733ab7548fca..8d5649dc1f91 100644 --- a/llvm/include/llvm/Support/Endian.h +++ b/llvm/include/llvm/Support/Endian.h @@ -49,7 +49,7 @@ struct alignment_access_helper namespace endian { template - static value_type read_le(const void *memory) { + inline value_type read_le(const void *memory) { value_type t = reinterpret_cast *>(memory)->val; @@ -59,7 +59,7 @@ namespace endian { } template - static void write_le(void *memory, value_type value) { + inline void write_le(void *memory, value_type value) { if (sys::isBigEndianHost()) value = sys::SwapByteOrder(value); reinterpret_cast *> @@ -67,7 +67,7 @@ namespace endian { } template - static value_type read_be(const void *memory) { + inline value_type read_be(const void *memory) { value_type t = reinterpret_cast *>(memory)->val; @@ -77,7 +77,7 @@ namespace endian { } template - static void write_be(void *memory, value_type value) { + inline void write_be(void *memory, value_type value) { if (sys::isLittleEndianHost()) value = sys::SwapByteOrder(value); reinterpret_cast *> diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h index d085c94f2adc..4005161320d6 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -414,14 +414,14 @@ int IsInf(double d); /// MinAlign - A and B are either alignments or offsets. Return the minimum /// alignment that may be assumed after adding the two together. -static inline uint64_t MinAlign(uint64_t A, uint64_t B) { +inline uint64_t MinAlign(uint64_t A, uint64_t B) { // The largest power of 2 that divides both A and B. return (A | B) & -(A | B); } /// NextPowerOf2 - Returns the next power of two (in 64-bits) /// that is strictly greater than A. Returns zero on overflow. -static inline uint64_t NextPowerOf2(uint64_t A) { +inline uint64_t NextPowerOf2(uint64_t A) { A |= (A >> 1); A |= (A >> 2); A |= (A >> 4); diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h index 10046b29b188..db597fbfca9f 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h +++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h @@ -481,17 +481,17 @@ namespace X86II { // getBaseOpcodeFor - This function returns the "base" X86 opcode for the // specified machine instruction. // - static inline unsigned char getBaseOpcodeFor(uint64_t TSFlags) { + inline unsigned char getBaseOpcodeFor(uint64_t TSFlags) { return TSFlags >> X86II::OpcodeShift; } - static inline bool hasImm(uint64_t TSFlags) { + inline bool hasImm(uint64_t TSFlags) { return (TSFlags & X86II::ImmMask) != 0; } /// getSizeOfImm - Decode the "size of immediate" field from the TSFlags field /// of the specified instruction. - static inline unsigned getSizeOfImm(uint64_t TSFlags) { + inline unsigned getSizeOfImm(uint64_t TSFlags) { switch (TSFlags & X86II::ImmMask) { default: llvm_unreachable("Unknown immediate size"); case X86II::Imm8: @@ -506,7 +506,7 @@ namespace X86II { /// isImmPCRel - Return true if the immediate of the specified instruction's /// TSFlags indicates that it is pc relative. - static inline unsigned isImmPCRel(uint64_t TSFlags) { + inline unsigned isImmPCRel(uint64_t TSFlags) { switch (TSFlags & X86II::ImmMask) { default: llvm_unreachable("Unknown immediate size"); case X86II::Imm8PCRel: @@ -529,7 +529,7 @@ namespace X86II { /// is duplicated in the MCInst (e.g. "EAX = addl EAX, [mem]") it is only /// counted as one operand. /// - static inline int getMemoryOperandNo(uint64_t TSFlags, unsigned Opcode) { + inline int getMemoryOperandNo(uint64_t TSFlags, unsigned Opcode) { switch (TSFlags & X86II::FormMask) { case X86II::MRMInitReg: // FIXME: Remove this form. @@ -591,7 +591,7 @@ namespace X86II { /// isX86_64ExtendedReg - Is the MachineOperand a x86-64 extended (r8 or /// higher) register? e.g. r8, xmm8, xmm13, etc. - static inline bool isX86_64ExtendedReg(unsigned RegNo) { + inline bool isX86_64ExtendedReg(unsigned RegNo) { switch (RegNo) { default: break; case X86::R8: case X86::R9: case X86::R10: case X86::R11: @@ -613,7 +613,7 @@ namespace X86II { return false; } - static inline bool isX86_64NonExtLowByteReg(unsigned reg) { + inline bool isX86_64NonExtLowByteReg(unsigned reg) { return (reg == X86::SPL || reg == X86::BPL || reg == X86::SIL || reg == X86::DIL); }