summaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-04-06 15:52:58 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-04-06 15:52:58 +0000
commit5f970ec96e421f64db6b1c6509a902ea73d98cc7 (patch)
tree0dd020f28a4846707f8d60717d9b2921ea187bd8 /include/llvm/Support
parent62cc576dca6a6aa62c0424f0a1e93a0a679d4c8a (diff)
downloadFreeBSD-src-5f970ec96e421f64db6b1c6509a902ea73d98cc7.zip
FreeBSD-src-5f970ec96e421f64db6b1c6509a902ea73d98cc7.tar.gz
Update LLVM to r100520.
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/Allocator.h2
-rw-r--r--include/llvm/Support/IRBuilder.h5
-rw-r--r--include/llvm/Support/IRReader.h10
-rw-r--r--include/llvm/Support/MathExtras.h8
-rw-r--r--include/llvm/Support/MemoryBuffer.h4
-rw-r--r--include/llvm/Support/SourceMgr.h37
6 files changed, 52 insertions, 14 deletions
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h
index eb6c2d1..148d47e 100644
--- a/include/llvm/Support/Allocator.h
+++ b/include/llvm/Support/Allocator.h
@@ -202,7 +202,7 @@ public:
(char *)Slab + Slab->Size;
for (char *Ptr = (char*)(Slab+1); Ptr < End; Ptr += sizeof(T)) {
Ptr = Allocator.AlignPtr(Ptr, alignof<T>());
- if (Ptr + sizeof(T) <= End)
+ if (Ptr + sizeof(T) <= End)
reinterpret_cast<T*>(Ptr)->~T();
}
Slab = Slab->NextPtr;
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h
index faa8fa3..660c9f8 100644
--- a/include/llvm/Support/IRBuilder.h
+++ b/include/llvm/Support/IRBuilder.h
@@ -917,6 +917,11 @@ public:
Value *Args[] = { Arg1, Arg2, Arg3, Arg4 };
return Insert(CallInst::Create(Callee, Args, Args+4), Name);
}
+ CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
+ Value *Arg4, Value *Arg5, const Twine &Name = "") {
+ Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 };
+ return Insert(CallInst::Create(Callee, Args, Args+5), Name);
+ }
template<typename InputIterator>
CallInst *CreateCall(Value *Callee, InputIterator ArgBegin,
diff --git a/include/llvm/Support/IRReader.h b/include/llvm/Support/IRReader.h
index 66314e0..2a43c5f 100644
--- a/include/llvm/Support/IRReader.h
+++ b/include/llvm/Support/IRReader.h
@@ -38,7 +38,8 @@ namespace llvm {
std::string ErrMsg;
Module *M = getLazyBitcodeModule(Buffer, Context, &ErrMsg);
if (M == 0) {
- Err = SMDiagnostic(Buffer->getBufferIdentifier(), -1, -1, ErrMsg, "");
+ Err = SMDiagnostic(SMLoc(), Buffer->getBufferIdentifier(), -1, -1,
+ ErrMsg, "");
// ParseBitcodeFile does not take ownership of the Buffer in the
// case of an error.
delete Buffer;
@@ -59,7 +60,7 @@ namespace llvm {
std::string ErrMsg;
MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg);
if (F == 0) {
- Err = SMDiagnostic(Filename, -1, -1,
+ Err = SMDiagnostic(SMLoc(), Filename, -1, -1,
"Could not open input file '" + Filename + "'", "");
return 0;
}
@@ -81,7 +82,8 @@ namespace llvm {
// ParseBitcodeFile does not take ownership of the Buffer.
delete Buffer;
if (M == 0)
- Err = SMDiagnostic(Buffer->getBufferIdentifier(), -1, -1, ErrMsg, "");
+ Err = SMDiagnostic(SMLoc(), Buffer->getBufferIdentifier(),
+ -1, -1, ErrMsg, "");
return M;
}
@@ -97,7 +99,7 @@ namespace llvm {
std::string ErrMsg;
MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg);
if (F == 0) {
- Err = SMDiagnostic(Filename, -1, -1,
+ Err = SMDiagnostic(SMLoc(), Filename, -1, -1,
"Could not open input file '" + Filename + "'", "");
return 0;
}
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index f56241c..80d11ae 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -459,14 +459,14 @@ inline int64_t abs64(int64_t x) {
/// SignExtend32 - Sign extend B-bit number x to 32-bit int.
/// Usage int32_t r = SignExtend32<5>(x);
-template <unsigned B> inline int32_t SignExtend32(int32_t x) {
- return (x << (32 - B)) >> (32 - B);
+template <unsigned B> inline int32_t SignExtend32(uint32_t x) {
+ return int32_t(x << (32 - B)) >> (32 - B);
}
/// SignExtend64 - Sign extend B-bit number x to 64-bit int.
/// Usage int64_t r = SignExtend64<5>(x);
-template <unsigned B> inline int64_t SignExtend64(int32_t x) {
- return (x << (64 - B)) >> (64 - B);
+template <unsigned B> inline int64_t SignExtend64(uint64_t x) {
+ return int64_t(x << (64 - B)) >> (64 - B);
}
} // End llvm namespace
diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h
index fcea5d2..ef7af69 100644
--- a/include/llvm/Support/MemoryBuffer.h
+++ b/include/llvm/Support/MemoryBuffer.h
@@ -65,13 +65,13 @@ public:
/// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note
/// that EndPtr[0] must be a null byte and be accessible!
- static MemoryBuffer *getMemBuffer(const char *StartPtr, const char *EndPtr,
+ static MemoryBuffer *getMemBuffer(StringRef InputData,
const char *BufferName = "");
/// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,
/// copying the contents and taking ownership of it. This has no requirements
/// on EndPtr[0].
- static MemoryBuffer *getMemBufferCopy(const char *StartPtr,const char *EndPtr,
+ static MemoryBuffer *getMemBufferCopy(StringRef InputData,
const char *BufferName = "");
/// getNewMemBuffer - Allocate a new MemoryBuffer of the specified size that
diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h
index fd56b16..3e66762 100644
--- a/include/llvm/Support/SourceMgr.h
+++ b/include/llvm/Support/SourceMgr.h
@@ -31,6 +31,13 @@ namespace llvm {
/// SourceMgr - This owns the files read by a parser, handles include stacks,
/// and handles diagnostic wrangling.
class SourceMgr {
+public:
+ /// DiagHandlerTy - Clients that want to handle their own diagnostics in a
+ /// custom way can register a function pointer+context as a diagnostic
+ /// handler. It gets called each time PrintMessage is invoked.
+ typedef void (*DiagHandlerTy)(const SMDiagnostic&, void *Context,
+ unsigned LocCookie);
+private:
struct SrcBuffer {
/// Buffer - The memory buffer for the file.
MemoryBuffer *Buffer;
@@ -51,16 +58,29 @@ class SourceMgr {
/// is really private to SourceMgr.cpp.
mutable void *LineNoCache;
+ DiagHandlerTy DiagHandler;
+ void *DiagContext;
+ unsigned DiagLocCookie;
+
SourceMgr(const SourceMgr&); // DO NOT IMPLEMENT
void operator=(const SourceMgr&); // DO NOT IMPLEMENT
public:
- SourceMgr() : LineNoCache(0) {}
+ SourceMgr() : LineNoCache(0), DiagHandler(0), DiagContext(0) {}
~SourceMgr();
void setIncludeDirs(const std::vector<std::string> &Dirs) {
IncludeDirectories = Dirs;
}
+ /// setDiagHandler - Specify a diagnostic handler to be invoked every time
+ /// PrintMessage is called. Ctx and Cookie are passed into the handler when
+ /// it is invoked.
+ void setDiagHandler(DiagHandlerTy DH, void *Ctx = 0, unsigned Cookie = 0) {
+ DiagHandler = DH;
+ DiagContext = Ctx;
+ DiagLocCookie = Cookie;
+ }
+
const SrcBuffer &getBufferInfo(unsigned i) const {
assert(i < Buffers.size() && "Invalid Buffer ID!");
return Buffers[i];
@@ -76,6 +96,8 @@ public:
return Buffers[i].IncludeLoc;
}
+ /// AddNewSourceBuffer - Add a new source buffer to this source manager. This
+ /// takes ownership of the memory buffer.
unsigned AddNewSourceBuffer(MemoryBuffer *F, SMLoc IncludeLoc) {
SrcBuffer NB;
NB.Buffer = F;
@@ -126,6 +148,7 @@ private:
/// SMDiagnostic - Instances of this class encapsulate one diagnostic report,
/// allowing printing to a raw_ostream as a caret diagnostic.
class SMDiagnostic {
+ SMLoc Loc;
std::string Filename;
int LineNo, ColumnNo;
std::string Message, LineContents;
@@ -133,12 +156,20 @@ class SMDiagnostic {
public:
SMDiagnostic() : LineNo(0), ColumnNo(0), ShowLine(0) {}
- SMDiagnostic(const std::string &FN, int Line, int Col,
+ SMDiagnostic(SMLoc L, const std::string &FN, int Line, int Col,
const std::string &Msg, const std::string &LineStr,
bool showline = true)
- : Filename(FN), LineNo(Line), ColumnNo(Col), Message(Msg),
+ : Loc(L), Filename(FN), LineNo(Line), ColumnNo(Col), Message(Msg),
LineContents(LineStr), ShowLine(showline) {}
+ SMLoc getLoc() const { return Loc; }
+ const std::string getFilename() { return Filename; }
+ int getLineNo() const { return LineNo; }
+ int getColumnNo() const { return ColumnNo; }
+ const std::string &getMessage() const { return Message; }
+ const std::string &getLineContents() const { return LineContents; }
+ bool getShowLine() const { return ShowLine; }
+
void Print(const char *ProgName, raw_ostream &S) const;
};
OpenPOWER on IntegriCloud