Index: llvm/trunk/include/llvm-c/Disassembler.h =================================================================== --- llvm/trunk/include/llvm-c/Disassembler.h +++ llvm/trunk/include/llvm-c/Disassembler.h @@ -16,7 +16,11 @@ #define LLVM_C_DISASSEMBLER_H #include "llvm/Support/DataTypes.h" +#ifdef __cplusplus +#include +#else #include +#endif /** * @defgroup LLVMCDisassembler Disassembler @@ -251,4 +255,4 @@ } #endif /* !defined(__cplusplus) */ -#endif /* !defined(LLVM_C_DISASSEMBLER_H) */ +#endif /* LLVM_C_DISASSEMBLER_H */ Index: llvm/trunk/include/llvm-c/lto.h =================================================================== --- llvm/trunk/include/llvm-c/lto.h +++ llvm/trunk/include/llvm-c/lto.h @@ -16,7 +16,11 @@ #ifndef LLVM_C_LTO_H #define LLVM_C_LTO_H +#ifdef __cplusplus +#include +#else #include +#endif #include #ifndef __cplusplus @@ -105,7 +109,6 @@ extern const char* lto_get_version(void); - /** * Returns the last error string or NULL if last operation was successful. * @@ -122,7 +125,6 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ extern const char* lto_module_get_linkeropts(lto_module_t mod); - /** * Diagnostic severity. * @@ -395,7 +388,6 @@ 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 @@ 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 @@ 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 @@ * @} */ -#endif +#endif /* LLVM_C_LTO_H */ Index: llvm/trunk/include/llvm/ADT/Statistic.h =================================================================== --- llvm/trunk/include/llvm/ADT/Statistic.h +++ llvm/trunk/include/llvm/ADT/Statistic.h @@ -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 namespace llvm { @@ -181,6 +181,6 @@ /// \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 Index: llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h +++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h @@ -14,7 +14,8 @@ #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/Support/Endian.h" #include -#include +#include +#include namespace llvm { @@ -382,9 +383,11 @@ 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 @@ 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 @@ // 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 { @@ -463,7 +468,6 @@ return std::hash()(static_cast(Arg)); } }; -} - +} // end namespace std -#endif +#endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H Index: llvm/trunk/include/llvm/Support/DataTypes.h.cmake =================================================================== --- llvm/trunk/include/llvm/Support/DataTypes.h.cmake +++ llvm/trunk/include/llvm/Support/DataTypes.h.cmake @@ -35,15 +35,23 @@ #include #endif +#ifdef __cplusplus +#include +#else #ifdef HAVE_INTTYPES_H #include #endif +#endif +#ifdef __cplusplus +#include +#else #ifdef HAVE_STDINT_H #include #else #error "Compiler must provide an implementation of stdint.h" #endif +#endif #ifndef _MSC_VER @@ -79,14 +87,14 @@ #endif #else /* _MSC_VER */ -#include -#include -#include #ifdef __cplusplus -#include +#include +#include #else -#include +#include +#include #endif +#include #if defined(_WIN64) typedef signed __int64 ssize_t; @@ -127,4 +135,4 @@ #define HUGE_VALF (float)HUGE_VAL #endif -#endif /* SUPPORT_DATATYPES_H */ +#endif /* SUPPORT_DATATYPES_H */ Index: llvm/trunk/include/llvm/Support/Valgrind.h =================================================================== --- llvm/trunk/include/llvm/Support/Valgrind.h +++ llvm/trunk/include/llvm/Support/Valgrind.h @@ -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 +#include namespace llvm { namespace sys { @@ -28,7 +26,7 @@ // 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 Index: llvm/trunk/include/llvm/Target/TargetCallingConv.h =================================================================== --- llvm/trunk/include/llvm/Target/TargetCallingConv.h +++ llvm/trunk/include/llvm/Target/TargetCallingConv.h @@ -18,7 +18,7 @@ #include "llvm/Support/DataTypes.h" #include "llvm/Support/MathExtras.h" #include -#include +#include namespace llvm { @@ -60,6 +60,7 @@ static const uint64_t One = 1ULL; ///< 1 of this type, for shifts uint64_t Flags; + public: ArgFlagsTy() : Flags(0) { } @@ -141,7 +142,7 @@ /// 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::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 @@ ArgVT = argvt; } }; -} +} // end namespace ISD } // end llvm namespace -#endif +#endif // LLVM_TARGET_TARGETCALLINGCONV_H Index: llvm/trunk/include/llvm/Transforms/IPO/LowerBitSets.h =================================================================== --- llvm/trunk/include/llvm/Transforms/IPO/LowerBitSets.h +++ llvm/trunk/include/llvm/Transforms/IPO/LowerBitSets.h @@ -18,7 +18,8 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" -#include +#include +#include #include #include #include @@ -196,6 +197,6 @@ uint64_t &AllocByteOffset, uint8_t &AllocMask); }; -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_TRANSFORMS_IPO_LOWERBITSETS_H Index: llvm/trunk/include/llvm/Transforms/IPO/WholeProgramDevirt.h =================================================================== --- llvm/trunk/include/llvm/Transforms/IPO/WholeProgramDevirt.h +++ llvm/trunk/include/llvm/Transforms/IPO/WholeProgramDevirt.h @@ -16,11 +16,10 @@ #define LLVM_TRANSFORMS_IPO_WHOLEPROGRAMDEVIRT_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseMapInfo.h" +#include +#include #include #include -#include -#include namespace llvm { @@ -209,7 +208,7 @@ uint64_t AllocAfter, unsigned BitWidth, int64_t &OffsetByte, uint64_t &OffsetBit); -} -} +} // end namespace wholeprogramdevirt +} // end namespace llvm -#endif +#endif // LLVM_TRANSFORMS_IPO_WHOLEPROGRAMDEVIRT_H Index: llvm/trunk/lib/Analysis/ConstantFolding.cpp =================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp @@ -34,15 +34,16 @@ #include "llvm/IR/Operator.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" +#include #include +#include #include - -#ifdef HAVE_FENV_H -#include -#endif +#include using namespace llvm; +namespace { + //===----------------------------------------------------------------------===// // Constant Folding internal helper functions //===----------------------------------------------------------------------===// @@ -50,7 +51,7 @@ /// 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 @@ 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(C))) { unsigned BitWidth = DL.getPointerTypeSizeInBits(GV->getType()); @@ -275,9 +275,8 @@ /// 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 @@ return false; } -static Constant *FoldReinterpretLoadFromConstPtr(Constant *C, - Type *LoadTy, - const DataLayout &DL) { +Constant *FoldReinterpretLoadFromConstPtr(Constant *C, Type *LoadTy, + const DataLayout &DL) { PointerType *PTy = cast(C->getType()); IntegerType *IntType = dyn_cast(LoadTy); @@ -478,9 +476,8 @@ 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(SrcPtr->getType()); if (!SrcPtrTy) @@ -524,6 +521,8 @@ return nullptr; } +} // end anonymous namespace + Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty, const DataLayout &DL) { // First, try the easy cases: @@ -568,12 +567,14 @@ 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::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::max(); StrVal = (StrVal << 8) | SingleChar; } // Append NULL at the end. @@ -604,8 +605,9 @@ 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(LI->getOperand(0))) @@ -618,9 +620,8 @@ /// 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 @@ /// 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 Ops, - Type *ResultTy, const DataLayout &DL, - const TargetLibraryInfo *TLI) { +Constant *CastGEPIndices(Type *SrcElemTy, ArrayRef Ops, + Type *ResultTy, const DataLayout &DL, + const TargetLibraryInfo *TLI) { Type *IntPtrTy = DL.getIntPtrType(ResultTy); bool Any = false; @@ -707,7 +708,7 @@ } /// 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(Ptr->getType()); Ptr = Ptr->stripPointerCasts(); @@ -724,10 +725,10 @@ } /// If we can symbolically evaluate the GEP constant expression, do so. -static Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, - ArrayRef Ops, - const DataLayout &DL, - const TargetLibraryInfo *TLI) { +Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, + ArrayRef Ops, + const DataLayout &DL, + const TargetLibraryInfo *TLI) { Type *SrcElemTy = GEP->getSourceElementType(); Type *ResElemTy = GEP->getResultElementType(); Type *ResTy = GEP->getType(); @@ -901,12 +902,11 @@ /// 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 Ops, - const DataLayout &DL, - const TargetLibraryInfo *TLI) { +Constant *ConstantFoldInstOperandsImpl(const Value *InstOrCE, Type *DestTy, + unsigned Opcode, + ArrayRef 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 @@ } } - +} // end anonymous namespace //===----------------------------------------------------------------------===// // Constant Folding public APIs @@ -1018,7 +1018,9 @@ return ConstantFoldInstOperands(I, Ops, DL, TLI); } -static Constant * +namespace { + +Constant * ConstantFoldConstantExpressionImpl(const ConstantExpr *CE, const DataLayout &DL, const TargetLibraryInfo *TLI, SmallPtrSetImpl &FoldedOps) { @@ -1043,6 +1045,8 @@ DL, TLI); } +} // end anonymous namespace + Constant *llvm::ConstantFoldConstantExpression(const ConstantExpr *CE, const DataLayout &DL, const TargetLibraryInfo *TLI) { @@ -1245,7 +1249,6 @@ return C; } - //===----------------------------------------------------------------------===// // Constant Folding for Calls // @@ -1336,7 +1339,9 @@ } } -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 @@ 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 @@ } /// 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 @@ #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 @@ 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 @@ /// 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 @@ 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 @@ return APF.convertToDouble(); } -static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, - Type *Ty, ArrayRef Operands, - const TargetLibraryInfo *TLI) { +Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty, + ArrayRef Operands, + const TargetLibraryInfo *TLI) { if (Operands.size() == 1) { if (ConstantFP *Op = dyn_cast(Operands[0])) { if (IntrinsicID == Intrinsic::convert_to_fp16) { @@ -1817,10 +1818,9 @@ return nullptr; } -static Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID, - VectorType *VTy, - ArrayRef Operands, - const TargetLibraryInfo *TLI) { +Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID, + VectorType *VTy, ArrayRef Operands, + const TargetLibraryInfo *TLI) { SmallVector Result(VTy->getNumElements()); SmallVector Lane(Operands.size()); Type *Ty = VTy->getElementType(); @@ -1845,6 +1845,8 @@ return ConstantVector::get(Result); } +} // end anonymous namespace + Constant * llvm::ConstantFoldCall(Function *F, ArrayRef Operands, const TargetLibraryInfo *TLI) { Index: llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp +++ llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -31,7 +31,10 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" -#include +#include +#include +#include +#include #if defined(_MSC_VER) #include @@ -116,11 +119,12 @@ 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 @@ return ResourceName.str(); } -static bool checkFileCRC(StringRef Path, uint32_t CRCHash) { +bool checkFileCRC(StringRef Path, uint32_t CRCHash) { ErrorOr> MB = MemoryBuffer::getFileOrSTDIN(Path); if (!MB) @@ -140,9 +144,9 @@ 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 @@ 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 @@ return false; } -static bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj, const MachOObjectFile *Obj) { ArrayRef dbg_uuid = DbgObj->getUuid(); @@ -215,6 +218,8 @@ 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 @@ return InsertResult.first->second->get(); } +namespace { + // Undo these various manglings for Win32 extern "C" functions: // cdecl - _foo // stdcall - _foo@12 // fastcall - @foo@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 @@ 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, Index: llvm/trunk/lib/LineEditor/LineEditor.cpp =================================================================== --- llvm/trunk/lib/LineEditor/LineEditor.cpp +++ llvm/trunk/lib/LineEditor/LineEditor.cpp @@ -12,7 +12,9 @@ #include "llvm/Config/config.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" -#include +#include +#include +#include #ifdef HAVE_LIBEDIT #include #endif @@ -106,7 +108,9 @@ 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 @@ // // 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 @@ 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 @@ return std::string(Line, LineLen); } -#else +#else // HAVE_LIBEDIT // Simple fgets-based implementation. @@ -316,4 +322,4 @@ return Line; } -#endif +#endif // HAVE_LIBEDIT