llvm.org GIT mirror llvm / 305b515
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. ;] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158800 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 8 years ago
11 changed file(s) with 36 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
5858 // for_each(V.begin(), B.end(), deleter);
5959 //
6060 template
61 static inline void deleter(T *Ptr) {
61 inline void deleter(T *Ptr) {
6262 delete Ptr;
6363 }
6464
237237 /// array_pod_sort_comparator - This is helper function for array_pod_sort,
238238 /// which just uses operator< on T.
239239 template
240 static inline int array_pod_sort_comparator(const void *P1, const void *P2) {
240 inline int array_pod_sort_comparator(const void *P1, const void *P2) {
241241 if (*reinterpret_cast(P1) < *reinterpret_cast(P2))
242242 return -1;
243243 if (*reinterpret_cast(P2) < *reinterpret_cast(P1))
248248 /// get_array_pad_sort_comparator - This is an internal helper function used to
249249 /// get type deduction of T right.
250250 template
251 static int (*get_array_pad_sort_comparator(const T &))
251 inline int (*get_array_pad_sort_comparator(const T &))
252252 (const void*, const void*) {
253253 return array_pod_sort_comparator;
254254 }
269269 /// NOTE: If qsort_r were portable, we could allow a custom comparator and
270270 /// default to std::less.
271271 template
272 static inline void array_pod_sort(IteratorTy Start, IteratorTy End) {
272 inline void array_pod_sort(IteratorTy Start, IteratorTy End) {
273273 // Don't dereference start iterator of empty sequence.
274274 if (Start == End) return;
275275 qsort(&*Start, End-Start, sizeof(*Start),
277277 }
278278
279279 template
280 static inline void array_pod_sort(IteratorTy Start, IteratorTy End,
280 inline void array_pod_sort(IteratorTy Start, IteratorTy End,
281281 int (*Compare)(const void*, const void*)) {
282282 // Don't dereference start iterator of empty sequence.
283283 if (Start == End) return;
151151 EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase);
152152
153153 template
154 static raw_ostream &operator<<(raw_ostream &o,
154 inline raw_ostream &operator<<(raw_ostream &o,
155155 const DomTreeNodeBase *Node) {
156156 if (Node->getBlock())
157157 WriteAsOperand(o, Node->getBlock(), false);
164164 }
165165
166166 template
167 static void PrintDomTree(const DomTreeNodeBase *N, raw_ostream &o,
167 inline void PrintDomTree(const DomTreeNodeBase *N, raw_ostream &o,
168168 unsigned Lev) {
169169 o.indent(2*Lev) << "[" << Lev << "] " << N;
170170 for (typename DomTreeNodeBase::const_iterator I = N->begin(),
4545 namespace llvm {
4646
4747 template
48 static void RemoveFromVector(std::vector &V, T *N) {
48 inline void RemoveFromVector(std::vector &V, T *N) {
4949 typename std::vector::iterator I = std::find(V.begin(), V.end(), N);
5050 assert(I != V.end() && "N is not in this list!");
5151 V.erase(I);
7070 /// isBitcodeWrapper - Return true if the given bytes are the magic bytes
7171 /// for an LLVM IR bitcode wrapper.
7272 ///
73 static inline bool isBitcodeWrapper(const unsigned char *BufPtr,
74 const unsigned char *BufEnd) {
73 inline bool isBitcodeWrapper(const unsigned char *BufPtr,
74 const unsigned char *BufEnd) {
7575 // See if you can find the hidden message in the magic bytes :-).
7676 // (Hint: it's a little-endian encoding.)
7777 return BufPtr != BufEnd &&
8484 /// isRawBitcode - Return true if the given bytes are the magic bytes for
8585 /// raw LLVM IR bitcode (without a wrapper).
8686 ///
87 static inline bool isRawBitcode(const unsigned char *BufPtr,
88 const unsigned char *BufEnd) {
87 inline bool isRawBitcode(const unsigned char *BufPtr,
88 const unsigned char *BufEnd) {
8989 // These bytes sort of have a hidden message, but it's not in
9090 // little-endian this time, and it's a little redundant.
9191 return BufPtr != BufEnd &&
9898 /// isBitcode - Return true if the given bytes are the magic bytes for
9999 /// LLVM IR bitcode, either with or without a wrapper.
100100 ///
101 static bool inline isBitcode(const unsigned char *BufPtr,
102 const unsigned char *BufEnd) {
101 inline bool isBitcode(const unsigned char *BufPtr,
102 const unsigned char *BufEnd) {
103103 return isBitcodeWrapper(BufPtr, BufEnd) ||
104104 isRawBitcode(BufPtr, BufEnd);
105105 }
120120 /// BC file.
121121 /// If 'VerifyBufferSize' is true, check that the buffer is large enough to
122122 /// contain the whole bitcode file.
123 static inline bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr,
124 const unsigned char *&BufEnd,
125 bool VerifyBufferSize) {
123 inline bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr,
124 const unsigned char *&BufEnd,
125 bool VerifyBufferSize) {
126126 enum {
127127 KnownHeaderSize = 4*4, // Size of header we read.
128128 OffsetField = 2*4, // Offset in bytes to Offset field.
4242
4343 /// getBundleStart - Returns the first instruction in the bundle containing MI.
4444 ///
45 static inline MachineInstr *getBundleStart(MachineInstr *MI) {
45 inline MachineInstr *getBundleStart(MachineInstr *MI) {
4646 MachineBasicBlock::instr_iterator I = MI;
4747 while (I->isInsideBundle())
4848 --I;
4949 return I;
5050 }
5151
52 static inline const MachineInstr *getBundleStart(const MachineInstr *MI) {
52 inline const MachineInstr *getBundleStart(const MachineInstr *MI) {
5353 MachineBasicBlock::const_instr_iterator I = MI;
5454 while (I->isInsideBundle())
5555 --I;
700700 // checkGEPType - Simple wrapper function to give a better assertion failure
701701 // message on bad indexes for a gep instruction.
702702 //
703 static inline Type *checkGEPType(Type *Ty) {
703 inline Type *checkGEPType(Type *Ty) {
704704 assert(Ty && "Invalid GetElementPtrInst indices for type!");
705705 return Ty;
706706 }
7575 }
7676 };
7777
78 static bool operator ==(const DataRefImpl &a, const DataRefImpl &b) {
78 inline bool operator ==(const DataRefImpl &a, const DataRefImpl &b) {
7979 // Check bitwise identical. This is the only legal way to compare a union w/o
8080 // knowing which member is in use.
8181 return std::memcmp(&a, &b, sizeof(DataRefImpl)) == 0;
8282 }
8383
84 static bool operator <(const DataRefImpl &a, const DataRefImpl &b) {
84 inline bool operator <(const DataRefImpl &a, const DataRefImpl &b) {
8585 // Check bitwise identical. This is the only legal way to compare a union w/o
8686 // knowing which member is in use.
8787 return std::memcmp(&a, &b, sizeof(DataRefImpl)) < 0;
5656 /// class besides some cosmetic cleanliness. Example usage:
5757 /// alignOf() returns the alignment of an int.
5858 template
59 static inline unsigned alignOf() { return AlignOf::Alignment; }
59 inline unsigned alignOf() { return AlignOf::Alignment; }
6060
6161
6262 /// \brief Helper for building an aligned character array type.
4848
4949 namespace endian {
5050 template
51 static value_type read_le(const void *memory) {
51 inline value_type read_le(const void *memory) {
5252 value_type t =
5353 reinterpret_cast
5454 *>(memory)->val;
5858 }
5959
6060 template
61 static void write_le(void *memory, value_type value) {
61 inline void write_le(void *memory, value_type value) {
6262 if (sys::isBigEndianHost())
6363 value = sys::SwapByteOrder(value);
6464 reinterpret_cast *>
6666 }
6767
6868 template
69 static value_type read_be(const void *memory) {
69 inline value_type read_be(const void *memory) {
7070 value_type t =
7171 reinterpret_cast
7272 *>(memory)->val;
7676 }
7777
7878 template
79 static void write_be(void *memory, value_type value) {
79 inline void write_be(void *memory, value_type value) {
8080 if (sys::isLittleEndianHost())
8181 value = sys::SwapByteOrder(value);
8282 reinterpret_cast *>
413413
414414 /// MinAlign - A and B are either alignments or offsets. Return the minimum
415415 /// alignment that may be assumed after adding the two together.
416 static inline uint64_t MinAlign(uint64_t A, uint64_t B) {
416 inline uint64_t MinAlign(uint64_t A, uint64_t B) {
417417 // The largest power of 2 that divides both A and B.
418418 return (A | B) & -(A | B);
419419 }
420420
421421 /// NextPowerOf2 - Returns the next power of two (in 64-bits)
422422 /// that is strictly greater than A. Returns zero on overflow.
423 static inline uint64_t NextPowerOf2(uint64_t A) {
423 inline uint64_t NextPowerOf2(uint64_t A) {
424424 A |= (A >> 1);
425425 A |= (A >> 2);
426426 A |= (A >> 4);
480480 // getBaseOpcodeFor - This function returns the "base" X86 opcode for the
481481 // specified machine instruction.
482482 //
483 static inline unsigned char getBaseOpcodeFor(uint64_t TSFlags) {
483 inline unsigned char getBaseOpcodeFor(uint64_t TSFlags) {
484484 return TSFlags >> X86II::OpcodeShift;
485485 }
486486
487 static inline bool hasImm(uint64_t TSFlags) {
487 inline bool hasImm(uint64_t TSFlags) {
488488 return (TSFlags & X86II::ImmMask) != 0;
489489 }
490490
491491 /// getSizeOfImm - Decode the "size of immediate" field from the TSFlags field
492492 /// of the specified instruction.
493 static inline unsigned getSizeOfImm(uint64_t TSFlags) {
493 inline unsigned getSizeOfImm(uint64_t TSFlags) {
494494 switch (TSFlags & X86II::ImmMask) {
495495 default: llvm_unreachable("Unknown immediate size");
496496 case X86II::Imm8:
505505
506506 /// isImmPCRel - Return true if the immediate of the specified instruction's
507507 /// TSFlags indicates that it is pc relative.
508 static inline unsigned isImmPCRel(uint64_t TSFlags) {
508 inline unsigned isImmPCRel(uint64_t TSFlags) {
509509 switch (TSFlags & X86II::ImmMask) {
510510 default: llvm_unreachable("Unknown immediate size");
511511 case X86II::Imm8PCRel:
528528 /// is duplicated in the MCInst (e.g. "EAX = addl EAX, [mem]") it is only
529529 /// counted as one operand.
530530 ///
531 static inline int getMemoryOperandNo(uint64_t TSFlags, unsigned Opcode) {
531 inline int getMemoryOperandNo(uint64_t TSFlags, unsigned Opcode) {
532532 switch (TSFlags & X86II::FormMask) {
533533 case X86II::MRMInitReg:
534534 // FIXME: Remove this form.
590590
591591 /// isX86_64ExtendedReg - Is the MachineOperand a x86-64 extended (r8 or
592592 /// higher) register? e.g. r8, xmm8, xmm13, etc.
593 static inline bool isX86_64ExtendedReg(unsigned RegNo) {
593 inline bool isX86_64ExtendedReg(unsigned RegNo) {
594594 switch (RegNo) {
595595 default: break;
596596 case X86::R8: case X86::R9: case X86::R10: case X86::R11:
612612 return false;
613613 }
614614
615 static inline bool isX86_64NonExtLowByteReg(unsigned reg) {
615 inline bool isX86_64NonExtLowByteReg(unsigned reg) {
616616 return (reg == X86::SPL || reg == X86::BPL ||
617617 reg == X86::SIL || reg == X86::DIL);
618618 }