C++ 使用llvm生成链接器时出错
我正在努力建造。我得到了链接错误,我无法找出原因。这是源文件:C++ 使用llvm生成链接器时出错,c++,llvm,linker-errors,C++,Llvm,Linker Errors,我正在努力建造。我得到了链接错误,我无法找出原因。这是源文件: #pragma once #include <llvm/Support/Debug.h> #include <llvm/Support/ConstantRange.h> // llvm::ConstantRange fixup. class CRange : public llvm::ConstantRange { typedef llvm::APInt APInt; typedef ll
#pragma once
#include <llvm/Support/Debug.h>
#include <llvm/Support/ConstantRange.h>
// llvm::ConstantRange fixup.
class CRange : public llvm::ConstantRange {
typedef llvm::APInt APInt;
typedef llvm::ConstantRange super;
public:
CRange(uint32_t BitWidth, bool isFullSet) : super(BitWidth, isFullSet) {}
// Constructors.
CRange(const super &CR) : super(CR) {}
CRange(const APInt &Value)
: super(Value) {}
CRange(const APInt &Lower, const APInt &Upper)
: super(Lower, Upper) {}
static CRange makeFullSet(uint32_t BitWidth) {
return CRange(BitWidth, true);
}
static CRange makeEmptySet(uint32_t BitWidth) {
return CRange(BitWidth, false);
}
static CRange makeICmpRegion(unsigned Pred, const CRange &other) {
return super::makeICmpRegion(Pred, other);
}
void match(const CRange &R) {
if (this->getBitWidth() != R.getBitWidth()) {
llvm::dbgs() << "warning: range " << *this << " "
<< this->getBitWidth() << " and " << R << " "
<< R.getBitWidth() << " unmatch\n";
*this = this->zextOrTrunc(R.getBitWidth());
}
}
bool safeUnion(const CRange &R) {
CRange V = R, Old = *this;
V.match(*this);
*this = this->unionWith(V);
return Old != *this;
}
CRange sdiv(const CRange &RHS) const {
if (isEmptySet() || RHS.isEmptySet())
return makeEmptySet(getBitWidth());
// FIXME: too conservative.
return makeFullSet(getBitWidth());
}
};
但是,llvm::ConstantRange::ConstantRange(llvm::APInt const&)
已经在llvm中定义。这是llvm中ConstantRange.h
的源代码
#if LLVM_HAS_RVALUE_REFERENCES
// If we have move semantics, pass APInts by value and move them into place.
typedef APInt APIntMoveTy;
#else
// Otherwise pass by const ref to save one copy.
typedef const APInt &APIntMoveTy;
#endif
public:
/// Initialize a full (the default) or empty set for the specified bit width.
///
explicit ConstantRange(uint32_t BitWidth, bool isFullSet = true);
/// Initialize a range to hold the single specified value.
///
ConstantRange(APIntMoveTy Value);
/// @brief Initialize a range of values explicitly. This will assert out if
/// Lower==Upper and Lower != Min or Max value for its type. It will also
/// assert out if the two APInt's are not the same bit width.
ConstantRange(APIntMoveTy Lower, APIntMoveTy Upper);
我已经尝试使用LLVM3.4和LLVM3.5。我使用的是GCC4.8.2。我找不到任何无法生成的原因?我猜您的代码和使用未定义/定义的
llvm\u值编译的llvm代码具有\u正确的值\u引用
尝试定义LLVM\u在代码中有\u正确的值\u引用
基本上,您要求(T const&)
,但llvm有(T)
#if LLVM_HAS_RVALUE_REFERENCES
// If we have move semantics, pass APInts by value and move them into place.
typedef APInt APIntMoveTy;
#else
// Otherwise pass by const ref to save one copy.
typedef const APInt &APIntMoveTy;
#endif
public:
/// Initialize a full (the default) or empty set for the specified bit width.
///
explicit ConstantRange(uint32_t BitWidth, bool isFullSet = true);
/// Initialize a range to hold the single specified value.
///
ConstantRange(APIntMoveTy Value);
/// @brief Initialize a range of values explicitly. This will assert out if
/// Lower==Upper and Lower != Min or Max value for its type. It will also
/// assert out if the two APInt's are not the same bit width.
ConstantRange(APIntMoveTy Lower, APIntMoveTy Upper);