[llvm] r264598 - Fix Clang-tidy modernize-deprecated-headers warnings in some files; other minor fixes.
Eugene Zelenko via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 10:40:08 PDT 2016
Author: eugenezelenko
Date: Mon Mar 28 12:40:08 2016
New Revision: 264598
URL: http://llvm.org/viewvc/llvm-project?rev=264598&view=rev
Log:
Fix Clang-tidy modernize-deprecated-headers warnings in some files; other minor fixes.
Differential revision: http://reviews.llvm.org/D18469
Modified:
llvm/trunk/include/llvm-c/Disassembler.h
llvm/trunk/include/llvm-c/lto.h
llvm/trunk/include/llvm/ADT/Statistic.h
llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h
llvm/trunk/include/llvm/Support/DataTypes.h.cmake
llvm/trunk/include/llvm/Support/Valgrind.h
llvm/trunk/include/llvm/Target/TargetCallingConv.h
llvm/trunk/include/llvm/Transforms/IPO/LowerBitSets.h
llvm/trunk/include/llvm/Transforms/IPO/WholeProgramDevirt.h
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/trunk/lib/LineEditor/LineEditor.cpp
Modified: llvm/trunk/include/llvm-c/Disassembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Disassembler.h?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Disassembler.h (original)
+++ llvm/trunk/include/llvm-c/Disassembler.h Mon Mar 28 12:40:08 2016
@@ -16,7 +16,11 @@
#define LLVM_C_DISASSEMBLER_H
#include "llvm/Support/DataTypes.h"
+#ifdef __cplusplus
+#include <cstddef>
+#else
#include <stddef.h>
+#endif
/**
* @defgroup LLVMCDisassembler Disassembler
@@ -251,4 +255,4 @@ size_t LLVMDisasmInstruction(LLVMDisasmC
}
#endif /* !defined(__cplusplus) */
-#endif /* !defined(LLVM_C_DISASSEMBLER_H) */
+#endif /* LLVM_C_DISASSEMBLER_H */
Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Mon Mar 28 12:40:08 2016
@@ -16,7 +16,11 @@
#ifndef LLVM_C_LTO_H
#define LLVM_C_LTO_H
+#ifdef __cplusplus
+#include <cstddef>
+#else
#include <stddef.h>
+#endif
#include <sys/types.h>
#ifndef __cplusplus
@@ -105,7 +109,6 @@ extern "C" {
extern const char*
lto_get_version(void);
-
/**
* Returns the last error string or NULL if last operation was successful.
*
@@ -122,7 +125,6 @@ lto_get_error_message(void);
extern lto_bool_t
lto_module_is_object_file(const char* path);
-
/**
* Checks if a file is a loadable object compiled for requested target.
*
@@ -132,7 +134,6 @@ extern lto_bool_t
lto_module_is_object_file_for_target(const char* path,
const char* target_triple_prefix);
-
/**
* Checks if a buffer is a loadable object file.
*
@@ -141,7 +142,6 @@ lto_module_is_object_file_for_target(con
extern lto_bool_t
lto_module_is_object_file_in_memory(const void* mem, size_t length);
-
/**
* Checks if a buffer is a loadable object compiled for requested target.
*
@@ -151,7 +151,6 @@ extern lto_bool_t
lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length,
const char* target_triple_prefix);
-
/**
* Loads an object file from disk.
* Returns NULL on error (check lto_get_error_message() for details).
@@ -161,7 +160,6 @@ lto_module_is_object_file_in_memory_for_
extern lto_module_t
lto_module_create(const char* path);
-
/**
* Loads an object file from memory.
* Returns NULL on error (check lto_get_error_message() for details).
@@ -254,7 +252,6 @@ lto_module_get_target_triple(lto_module_
extern void
lto_module_set_target_triple(lto_module_t mod, const char *triple);
-
/**
* Returns the number of symbols in the object module.
*
@@ -263,7 +260,6 @@ lto_module_set_target_triple(lto_module_
extern unsigned int
lto_module_get_num_symbols(lto_module_t mod);
-
/**
* Returns the name of the ith symbol in the object module.
*
@@ -272,7 +268,6 @@ lto_module_get_num_symbols(lto_module_t
extern const char*
lto_module_get_symbol_name(lto_module_t mod, unsigned int index);
-
/**
* Returns the attributes of the ith symbol in the object module.
*
@@ -281,7 +276,6 @@ lto_module_get_symbol_name(lto_module_t
extern lto_symbol_attributes
lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index);
-
/**
* Returns the module's linker options.
*
@@ -293,7 +287,6 @@ lto_module_get_symbol_attribute(lto_modu
extern const char*
lto_module_get_linkeropts(lto_module_t mod);
-
/**
* Diagnostic severity.
*
@@ -395,7 +388,6 @@ lto_codegen_set_module(lto_code_gen_t cg
extern lto_bool_t
lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model);
-
/**
* Sets which PIC code model to generated.
* Returns true on error (check lto_get_error_message() for details).
@@ -405,7 +397,6 @@ lto_codegen_set_debug_model(lto_code_gen
extern lto_bool_t
lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model);
-
/**
* Sets the cpu to generate code for.
*
@@ -414,7 +405,6 @@ lto_codegen_set_pic_model(lto_code_gen_t
extern void
lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu);
-
/**
* Sets the location of the assembler tool to run. If not set, libLTO
* will use gcc to invoke the assembler.
@@ -773,4 +763,4 @@ extern void thinlto_codegen_add_cross_re
* @}
*/
-#endif
+#endif /* LLVM_C_LTO_H */
Modified: llvm/trunk/include/llvm/ADT/Statistic.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Statistic.h?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Statistic.h (original)
+++ llvm/trunk/include/llvm/ADT/Statistic.h Mon Mar 28 12:40:08 2016
@@ -27,7 +27,7 @@
#define LLVM_ADT_STATISTIC_H
#include "llvm/Support/Atomic.h"
-#include "llvm/Support/Valgrind.h"
+#include "llvm/Support/Compiler.h"
#include <memory>
namespace llvm {
@@ -181,6 +181,6 @@ void PrintStatistics();
/// \brief Print statistics to the given output stream.
void PrintStatistics(raw_ostream &OS);
-} // End llvm namespace
+} // end llvm namespace
-#endif
+#endif // LLVM_ADT_STATISTIC_H
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h Mon Mar 28 12:40:08 2016
@@ -14,7 +14,8 @@
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/Support/Endian.h"
#include <functional>
-#include <stdint.h>
+#include <cstdint>
+#include <cstring>
namespace llvm {
@@ -382,9 +383,11 @@ struct Variant {
uint64_t UInt64;
char *String;
} Value;
+
#define VARIANT_EQUAL_CASE(Enum) \
case PDB_VariantType::Enum: \
return Value.Enum == Other.Value.Enum;
+
bool operator==(const Variant &Other) const {
if (Type != Other.Type)
return false;
@@ -405,7 +408,9 @@ struct Variant {
return true;
}
}
+
#undef VARIANT_EQUAL_CASE
+
bool operator!=(const Variant &Other) const { return !(*this == Other); }
Variant &operator=(const Variant &Other) {
if (this == &Other)
@@ -450,9 +455,9 @@ struct SuperBlock {
// This contains the block # of the block map.
support::ulittle32_t BlockMapAddr;
};
-}
+} // end namespace PDB
-} // namespace llvm
+} // end namespace llvm
namespace std {
template <> struct hash<llvm::PDB_SymType> {
@@ -463,7 +468,6 @@ template <> struct hash<llvm::PDB_SymTyp
return std::hash<int>()(static_cast<int>(Arg));
}
};
-}
-
+} // end namespace std
-#endif
+#endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H
Modified: llvm/trunk/include/llvm/Support/DataTypes.h.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DataTypes.h.cmake?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/DataTypes.h.cmake (original)
+++ llvm/trunk/include/llvm/Support/DataTypes.h.cmake Mon Mar 28 12:40:08 2016
@@ -35,15 +35,23 @@
#include <math.h>
#endif
+#ifdef __cplusplus
+#include <cinttypes>
+#else
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
+#endif
+#ifdef __cplusplus
+#include <cstdint>
+#else
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#error "Compiler must provide an implementation of stdint.h"
#endif
+#endif
#ifndef _MSC_VER
@@ -79,14 +87,14 @@ typedef u_int64_t uint64_t;
#endif
#else /* _MSC_VER */
-#include <stdlib.h>
-#include <stddef.h>
-#include <sys/types.h>
#ifdef __cplusplus
-#include <cmath>
+#include <cstdlib>
+#include <cstddef>
#else
-#include <math.h>
+#include <stdlib.h>
+#include <stddef.h>
#endif
+#include <sys/types.h>
#if defined(_WIN64)
typedef signed __int64 ssize_t;
@@ -127,4 +135,4 @@ typedef signed int ssize_t;
#define HUGE_VALF (float)HUGE_VAL
#endif
-#endif /* SUPPORT_DATATYPES_H */
+#endif /* SUPPORT_DATATYPES_H */
Modified: llvm/trunk/include/llvm/Support/Valgrind.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Valgrind.h?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Valgrind.h (original)
+++ llvm/trunk/include/llvm/Support/Valgrind.h Mon Mar 28 12:40:08 2016
@@ -1,4 +1,4 @@
-//===- llvm/Support/Valgrind.h - Communication with Valgrind -----*- C++ -*-===//
+//===- llvm/Support/Valgrind.h - Communication with Valgrind ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,9 +16,7 @@
#ifndef LLVM_SUPPORT_VALGRIND_H
#define LLVM_SUPPORT_VALGRIND_H
-#include "llvm/Config/llvm-config.h"
-#include "llvm/Support/Compiler.h"
-#include <stddef.h>
+#include <cstddef>
namespace llvm {
namespace sys {
@@ -28,7 +26,7 @@ namespace sys {
// Discard valgrind's translation of code in the range [Addr .. Addr + Len).
// Otherwise valgrind may continue to execute the old version of the code.
void ValgrindDiscardTranslations(const void *Addr, size_t Len);
-}
-}
+} // namespace sys
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_VALGRIND_H
Modified: llvm/trunk/include/llvm/Target/TargetCallingConv.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetCallingConv.h?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetCallingConv.h (original)
+++ llvm/trunk/include/llvm/Target/TargetCallingConv.h Mon Mar 28 12:40:08 2016
@@ -18,7 +18,7 @@
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/MathExtras.h"
#include <string>
-#include <limits.h>
+#include <limits>
namespace llvm {
@@ -60,6 +60,7 @@ namespace ISD {
static const uint64_t One = 1ULL; ///< 1 of this type, for shifts
uint64_t Flags;
+
public:
ArgFlagsTy() : Flags(0) { }
@@ -141,7 +142,7 @@ namespace ISD {
/// Index original Function's argument.
unsigned OrigArgIndex;
/// Sentinel value for implicit machine-level input arguments.
- static const unsigned NoArgIndex = UINT_MAX;
+ static const unsigned NoArgIndex = std::numeric_limits<uint32_t>::max();
/// Offset in bytes of current input value relative to the beginning of
/// original argument. E.g. if argument was splitted into four 32 bit
@@ -195,8 +196,8 @@ namespace ISD {
ArgVT = argvt;
}
};
-}
+} // end namespace ISD
} // end llvm namespace
-#endif
+#endif // LLVM_TARGET_TARGETCALLINGCONV_H
Modified: llvm/trunk/include/llvm/Transforms/IPO/LowerBitSets.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/LowerBitSets.h?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/LowerBitSets.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/LowerBitSets.h Mon Mar 28 12:40:08 2016
@@ -18,7 +18,8 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
-#include <stdint.h>
+#include <cstdint>
+#include <cstring>
#include <limits>
#include <set>
#include <vector>
@@ -196,6 +197,6 @@ struct ByteArrayBuilder {
uint64_t &AllocByteOffset, uint8_t &AllocMask);
};
-} // namespace llvm
+} // end namespace llvm
-#endif
+#endif // LLVM_TRANSFORMS_IPO_LOWERBITSETS_H
Modified: llvm/trunk/include/llvm/Transforms/IPO/WholeProgramDevirt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/WholeProgramDevirt.h?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/WholeProgramDevirt.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/WholeProgramDevirt.h Mon Mar 28 12:40:08 2016
@@ -16,11 +16,10 @@
#define LLVM_TRANSFORMS_IPO_WHOLEPROGRAMDEVIRT_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMapInfo.h"
+#include <cassert>
+#include <cstdint>
#include <utility>
#include <vector>
-#include <assert.h>
-#include <stdint.h>
namespace llvm {
@@ -209,7 +208,7 @@ void setAfterReturnValues(MutableArrayRe
uint64_t AllocAfter, unsigned BitWidth,
int64_t &OffsetByte, uint64_t &OffsetBit);
-}
-}
+} // end namespace wholeprogramdevirt
+} // end namespace llvm
-#endif
+#endif // LLVM_TRANSFORMS_IPO_WHOLEPROGRAMDEVIRT_H
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Mar 28 12:40:08 2016
@@ -34,15 +34,16 @@
#include "llvm/IR/Operator.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
+#include <cassert>
#include <cerrno>
+#include <cfenv>
#include <cmath>
-
-#ifdef HAVE_FENV_H
-#include <fenv.h>
-#endif
+#include <limits>
using namespace llvm;
+namespace {
+
//===----------------------------------------------------------------------===//
// Constant Folding internal helper functions
//===----------------------------------------------------------------------===//
@@ -50,7 +51,7 @@ using namespace llvm;
/// Constant fold bitcast, symbolically evaluating it with DataLayout.
/// This always returns a non-null constant, but it may be a
/// ConstantExpr if unfoldable.
-static Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
+Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
// Catch the obvious splat cases.
if (C->isNullValue() && !DestTy->isX86_MMXTy())
return Constant::getNullValue(DestTy);
@@ -230,11 +231,10 @@ static Constant *FoldBitCast(Constant *C
return ConstantVector::get(Result);
}
-
/// If this constant is a constant offset from a global, return the global and
/// the constant. Because of constantexprs, this function is recursive.
-static bool IsConstantOffsetFromGlobal(Constant *C, GlobalValue *&GV,
- APInt &Offset, const DataLayout &DL) {
+bool IsConstantOffsetFromGlobal(Constant *C, GlobalValue *&GV, APInt &Offset,
+ const DataLayout &DL) {
// Trivial case, constant is the global.
if ((GV = dyn_cast<GlobalValue>(C))) {
unsigned BitWidth = DL.getPointerTypeSizeInBits(GV->getType());
@@ -275,9 +275,8 @@ static bool IsConstantOffsetFromGlobal(C
/// out of. ByteOffset is an offset into C. CurPtr is the pointer to copy
/// results into and BytesLeft is the number of bytes left in
/// the CurPtr buffer. DL is the DataLayout.
-static bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset,
- unsigned char *CurPtr, unsigned BytesLeft,
- const DataLayout &DL) {
+bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset, unsigned char *CurPtr,
+ unsigned BytesLeft, const DataLayout &DL) {
assert(ByteOffset <= DL.getTypeAllocSize(C->getType()) &&
"Out of range access");
@@ -398,9 +397,8 @@ static bool ReadDataFromGlobal(Constant
return false;
}
-static Constant *FoldReinterpretLoadFromConstPtr(Constant *C,
- Type *LoadTy,
- const DataLayout &DL) {
+Constant *FoldReinterpretLoadFromConstPtr(Constant *C, Type *LoadTy,
+ const DataLayout &DL) {
PointerType *PTy = cast<PointerType>(C->getType());
IntegerType *IntType = dyn_cast<IntegerType>(LoadTy);
@@ -478,9 +476,8 @@ static Constant *FoldReinterpretLoadFrom
return ConstantInt::get(IntType->getContext(), ResultVal);
}
-static Constant *ConstantFoldLoadThroughBitcast(ConstantExpr *CE,
- Type *DestTy,
- const DataLayout &DL) {
+Constant *ConstantFoldLoadThroughBitcast(ConstantExpr *CE, Type *DestTy,
+ const DataLayout &DL) {
auto *SrcPtr = CE->getOperand(0);
auto *SrcPtrTy = dyn_cast<PointerType>(SrcPtr->getType());
if (!SrcPtrTy)
@@ -524,6 +521,8 @@ static Constant *ConstantFoldLoadThrough
return nullptr;
}
+} // end anonymous namespace
+
Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
const DataLayout &DL) {
// First, try the easy cases:
@@ -568,12 +567,14 @@ Constant *llvm::ConstantFoldLoadFromCons
APInt SingleChar(NumBits, 0);
if (DL.isLittleEndian()) {
for (signed i = StrLen-1; i >= 0; i--) {
- SingleChar = (uint64_t) Str[i] & UCHAR_MAX;
+ SingleChar = (uint64_t) Str[i] &
+ std::numeric_limits<unsigned char>::max();
StrVal = (StrVal << 8) | SingleChar;
}
} else {
for (unsigned i = 0; i < StrLen; i++) {
- SingleChar = (uint64_t) Str[i] & UCHAR_MAX;
+ SingleChar = (uint64_t) Str[i] &
+ std::numeric_limits<unsigned char>::max();
StrVal = (StrVal << 8) | SingleChar;
}
// Append NULL at the end.
@@ -604,8 +605,9 @@ Constant *llvm::ConstantFoldLoadFromCons
return FoldReinterpretLoadFromConstPtr(CE, Ty, DL);
}
-static Constant *ConstantFoldLoadInst(const LoadInst *LI,
- const DataLayout &DL) {
+namespace {
+
+Constant *ConstantFoldLoadInst(const LoadInst *LI, const DataLayout &DL) {
if (LI->isVolatile()) return nullptr;
if (Constant *C = dyn_cast<Constant>(LI->getOperand(0)))
@@ -618,9 +620,8 @@ static Constant *ConstantFoldLoadInst(co
/// Attempt to symbolically evaluate the result of a binary operator merging
/// these together. If target data info is available, it is provided as DL,
/// otherwise DL is null.
-static Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0,
- Constant *Op1,
- const DataLayout &DL) {
+Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0, Constant *Op1,
+ const DataLayout &DL) {
// SROA
// Fold (and 0xffffffff00000000, (shl x, 32)) -> shl.
@@ -672,9 +673,9 @@ static Constant *SymbolicallyEvaluateBin
/// If array indices are not pointer-sized integers, explicitly cast them so
/// that they aren't implicitly casted by the getelementptr.
-static Constant *CastGEPIndices(Type *SrcElemTy, ArrayRef<Constant *> Ops,
- Type *ResultTy, const DataLayout &DL,
- const TargetLibraryInfo *TLI) {
+Constant *CastGEPIndices(Type *SrcElemTy, ArrayRef<Constant *> Ops,
+ Type *ResultTy, const DataLayout &DL,
+ const TargetLibraryInfo *TLI) {
Type *IntPtrTy = DL.getIntPtrType(ResultTy);
bool Any = false;
@@ -707,7 +708,7 @@ static Constant *CastGEPIndices(Type *Sr
}
/// Strip the pointer casts, but preserve the address space information.
-static Constant* StripPtrCastKeepAS(Constant* Ptr, Type *&ElemTy) {
+Constant* StripPtrCastKeepAS(Constant* Ptr, Type *&ElemTy) {
assert(Ptr->getType()->isPointerTy() && "Not a pointer type");
PointerType *OldPtrTy = cast<PointerType>(Ptr->getType());
Ptr = Ptr->stripPointerCasts();
@@ -724,10 +725,10 @@ static Constant* StripPtrCastKeepAS(Cons
}
/// If we can symbolically evaluate the GEP constant expression, do so.
-static Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
- ArrayRef<Constant *> Ops,
- const DataLayout &DL,
- const TargetLibraryInfo *TLI) {
+Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
+ ArrayRef<Constant *> Ops,
+ const DataLayout &DL,
+ const TargetLibraryInfo *TLI) {
Type *SrcElemTy = GEP->getSourceElementType();
Type *ResElemTy = GEP->getResultElementType();
Type *ResTy = GEP->getType();
@@ -901,12 +902,11 @@ static Constant *SymbolicallyEvaluateGEP
/// information, due to only being passed an opcode and operands. Constant
/// folding using this function strips this information.
///
-static Constant *ConstantFoldInstOperandsImpl(const Value *InstOrCE,
- Type *DestTy,
- unsigned Opcode,
- ArrayRef<Constant *> Ops,
- const DataLayout &DL,
- const TargetLibraryInfo *TLI) {
+Constant *ConstantFoldInstOperandsImpl(const Value *InstOrCE, Type *DestTy,
+ unsigned Opcode,
+ ArrayRef<Constant *> Ops,
+ const DataLayout &DL,
+ const TargetLibraryInfo *TLI) {
// Handle easy binops first.
if (Instruction::isBinaryOp(Opcode))
return ConstantFoldBinaryOpOperands(Opcode, Ops[0], Ops[1], DL);
@@ -942,7 +942,7 @@ static Constant *ConstantFoldInstOperand
}
}
-
+} // end anonymous namespace
//===----------------------------------------------------------------------===//
// Constant Folding public APIs
@@ -1018,7 +1018,9 @@ Constant *llvm::ConstantFoldInstruction(
return ConstantFoldInstOperands(I, Ops, DL, TLI);
}
-static Constant *
+namespace {
+
+Constant *
ConstantFoldConstantExpressionImpl(const ConstantExpr *CE, const DataLayout &DL,
const TargetLibraryInfo *TLI,
SmallPtrSetImpl<ConstantExpr *> &FoldedOps) {
@@ -1043,6 +1045,8 @@ ConstantFoldConstantExpressionImpl(const
DL, TLI);
}
+} // end anonymous namespace
+
Constant *llvm::ConstantFoldConstantExpression(const ConstantExpr *CE,
const DataLayout &DL,
const TargetLibraryInfo *TLI) {
@@ -1245,7 +1249,6 @@ Constant *llvm::ConstantFoldLoadThroughG
return C;
}
-
//===----------------------------------------------------------------------===//
// Constant Folding for Calls
//
@@ -1336,7 +1339,9 @@ bool llvm::canConstantFoldCallTo(const F
}
}
-static Constant *GetConstantFoldFPValue(double V, Type *Ty) {
+namespace {
+
+Constant *GetConstantFoldFPValue(double V, Type *Ty) {
if (Ty->isHalfTy()) {
APFloat APF(V);
bool unused;
@@ -1348,12 +1353,10 @@ static Constant *GetConstantFoldFPValue(
if (Ty->isDoubleTy())
return ConstantFP::get(Ty->getContext(), APFloat(V));
llvm_unreachable("Can only constant fold half/float/double");
-
}
-namespace {
/// Clear the floating-point exception state.
-static inline void llvm_fenv_clearexcept() {
+inline void llvm_fenv_clearexcept() {
#if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT
feclearexcept(FE_ALL_EXCEPT);
#endif
@@ -1361,7 +1364,7 @@ static inline void llvm_fenv_clearexcept
}
/// Test if a floating-point exception was raised.
-static inline bool llvm_fenv_testexcept() {
+inline bool llvm_fenv_testexcept() {
int errno_val = errno;
if (errno_val == ERANGE || errno_val == EDOM)
return true;
@@ -1371,10 +1374,8 @@ static inline bool llvm_fenv_testexcept(
#endif
return false;
}
-} // End namespace
-static Constant *ConstantFoldFP(double (*NativeFP)(double), double V,
- Type *Ty) {
+Constant *ConstantFoldFP(double (*NativeFP)(double), double V, Type *Ty) {
llvm_fenv_clearexcept();
V = NativeFP(V);
if (llvm_fenv_testexcept()) {
@@ -1385,8 +1386,8 @@ static Constant *ConstantFoldFP(double (
return GetConstantFoldFPValue(V, Ty);
}
-static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double),
- double V, double W, Type *Ty) {
+Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double), double V,
+ double W, Type *Ty) {
llvm_fenv_clearexcept();
V = NativeFP(V, W);
if (llvm_fenv_testexcept()) {
@@ -1404,8 +1405,8 @@ static Constant *ConstantFoldBinaryFP(do
/// integer type Ty is used to select how many bits are available for the
/// result. Returns null if the conversion cannot be performed, otherwise
/// returns the Constant value resulting from the conversion.
-static Constant *ConstantFoldConvertToInt(const APFloat &Val,
- bool roundTowardZero, Type *Ty) {
+Constant *ConstantFoldConvertToInt(const APFloat &Val, bool roundTowardZero,
+ Type *Ty) {
// All of these conversion intrinsics form an integer of at most 64bits.
unsigned ResultWidth = Ty->getIntegerBitWidth();
assert(ResultWidth <= 64 &&
@@ -1423,7 +1424,7 @@ static Constant *ConstantFoldConvertToIn
return ConstantInt::get(Ty, UIntVal, /*isSigned=*/true);
}
-static double getValueAsDouble(ConstantFP *Op) {
+double getValueAsDouble(ConstantFP *Op) {
Type *Ty = Op->getType();
if (Ty->isFloatTy())
@@ -1438,9 +1439,9 @@ static double getValueAsDouble(ConstantF
return APF.convertToDouble();
}
-static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID,
- Type *Ty, ArrayRef<Constant *> Operands,
- const TargetLibraryInfo *TLI) {
+Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty,
+ ArrayRef<Constant *> Operands,
+ const TargetLibraryInfo *TLI) {
if (Operands.size() == 1) {
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
if (IntrinsicID == Intrinsic::convert_to_fp16) {
@@ -1817,10 +1818,9 @@ static Constant *ConstantFoldScalarCall(
return nullptr;
}
-static Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID,
- VectorType *VTy,
- ArrayRef<Constant *> Operands,
- const TargetLibraryInfo *TLI) {
+Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID,
+ VectorType *VTy, ArrayRef<Constant *> Operands,
+ const TargetLibraryInfo *TLI) {
SmallVector<Constant *, 4> Result(VTy->getNumElements());
SmallVector<Constant *, 4> Lane(Operands.size());
Type *Ty = VTy->getElementType();
@@ -1845,6 +1845,8 @@ static Constant *ConstantFoldVectorCall(
return ConstantVector::get(Result);
}
+} // end anonymous namespace
+
Constant *
llvm::ConstantFoldCall(Function *F, ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI) {
Modified: llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp (original)
+++ llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp Mon Mar 28 12:40:08 2016
@@ -31,7 +31,10 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
-#include <stdlib.h>
+#include <algorithm>
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
#if defined(_MSC_VER)
#include <Windows.h>
@@ -116,11 +119,12 @@ void LLVMSymbolizer::flush() {
Modules.clear();
}
+namespace {
+
// For Path="/path/to/foo" and Basename="foo" assume that debug info is in
// /path/to/foo.dSYM/Contents/Resources/DWARF/foo.
// For Path="/path/to/bar.dSYM" and Basename="foo" assume that debug info is in
// /path/to/bar.dSYM/Contents/Resources/DWARF/foo.
-static
std::string getDarwinDWARFResourceForPath(
const std::string &Path, const std::string &Basename) {
SmallString<16> ResourceName = StringRef(Path);
@@ -132,7 +136,7 @@ std::string getDarwinDWARFResourceForPat
return ResourceName.str();
}
-static bool checkFileCRC(StringRef Path, uint32_t CRCHash) {
+bool checkFileCRC(StringRef Path, uint32_t CRCHash) {
ErrorOr<std::unique_ptr<MemoryBuffer>> MB =
MemoryBuffer::getFileOrSTDIN(Path);
if (!MB)
@@ -140,9 +144,9 @@ static bool checkFileCRC(StringRef Path,
return !zlib::isAvailable() || CRCHash == zlib::crc32(MB.get()->getBuffer());
}
-static bool findDebugBinary(const std::string &OrigPath,
- const std::string &DebuglinkName, uint32_t CRCHash,
- std::string &Result) {
+bool findDebugBinary(const std::string &OrigPath,
+ const std::string &DebuglinkName, uint32_t CRCHash,
+ std::string &Result) {
std::string OrigRealPath = OrigPath;
#if defined(HAVE_REALPATH)
if (char *RP = realpath(OrigPath.c_str(), nullptr)) {
@@ -177,8 +181,8 @@ static bool findDebugBinary(const std::s
return false;
}
-static bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName,
- uint32_t &CRCHash) {
+bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName,
+ uint32_t &CRCHash) {
if (!Obj)
return false;
for (const SectionRef &Section : Obj->sections()) {
@@ -205,7 +209,6 @@ static bool getGNUDebuglinkContents(cons
return false;
}
-static
bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj,
const MachOObjectFile *Obj) {
ArrayRef<uint8_t> dbg_uuid = DbgObj->getUuid();
@@ -215,6 +218,8 @@ bool darwinDsymMatchesBinary(const MachO
return !memcmp(dbg_uuid.data(), bin_uuid.data(), dbg_uuid.size());
}
+} // end anonymous namespace
+
ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,
const MachOObjectFile *MachExeObj, const std::string &ArchName) {
// On Darwin we may find DWARF in separate object file in
@@ -383,13 +388,15 @@ LLVMSymbolizer::getOrCreateModuleInfo(co
return InsertResult.first->second->get();
}
+namespace {
+
// Undo these various manglings for Win32 extern "C" functions:
// cdecl - _foo
// stdcall - _foo at 12
// fastcall - @foo at 12
// vectorcall - foo@@12
// These are all different linkage names for 'foo'.
-static StringRef demanglePE32ExternCFunc(StringRef SymbolName) {
+StringRef demanglePE32ExternCFunc(StringRef SymbolName) {
// Remove any '_' or '@' prefix.
char Front = SymbolName.empty() ? '\0' : SymbolName[0];
if (Front == '_' || Front == '@')
@@ -412,6 +419,8 @@ static StringRef demanglePE32ExternCFunc
return SymbolName;
}
+} // end anonymous namespace
+
#if !defined(_MSC_VER)
// Assume that __cxa_demangle is provided by libcxxabi (except for Windows).
extern "C" char *__cxa_demangle(const char *mangled_name, char *output_buffer,
Modified: llvm/trunk/lib/LineEditor/LineEditor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LineEditor/LineEditor.cpp?rev=264598&r1=264597&r2=264598&view=diff
==============================================================================
--- llvm/trunk/lib/LineEditor/LineEditor.cpp (original)
+++ llvm/trunk/lib/LineEditor/LineEditor.cpp Mon Mar 28 12:40:08 2016
@@ -12,7 +12,9 @@
#include "llvm/Config/config.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-#include <stdio.h>
+#include <algorithm>
+#include <cassert>
+#include <cstdio>
#ifdef HAVE_LIBEDIT
#include <histedit.h>
#endif
@@ -106,7 +108,9 @@ struct LineEditor::InternalData {
FILE *Out;
};
-static const char *ElGetPromptFn(EditLine *EL) {
+namespace {
+
+const char *ElGetPromptFn(EditLine *EL) {
LineEditor::InternalData *Data;
if (el_get(EL, EL_CLIENTDATA, &Data) == 0)
return Data->LE->getPrompt().c_str();
@@ -117,7 +121,7 @@ static const char *ElGetPromptFn(EditLin
//
// This function is really horrible. But since the alternative is to get into
// the line editor business, here we are.
-static unsigned char ElCompletionFn(EditLine *EL, int ch) {
+unsigned char ElCompletionFn(EditLine *EL, int ch) {
LineEditor::InternalData *Data;
if (el_get(EL, EL_CLIENTDATA, &Data) == 0) {
if (!Data->ContinuationOutput.empty()) {
@@ -190,6 +194,8 @@ static unsigned char ElCompletionFn(Edit
return CC_ERROR;
}
+} // end anonymous namespace
+
LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In,
FILE *Out, FILE *Err)
: Prompt((ProgName + "> ").str()), HistoryPath(HistoryPath),
@@ -269,7 +275,7 @@ Optional<std::string> LineEditor::readLi
return std::string(Line, LineLen);
}
-#else
+#else // HAVE_LIBEDIT
// Simple fgets-based implementation.
@@ -316,4 +322,4 @@ Optional<std::string> LineEditor::readLi
return Line;
}
-#endif
+#endif // HAVE_LIBEDIT
More information about the llvm-commits
mailing list