summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-01 04:51:17 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-01 04:51:17 +0000
commit91766fe066efe6e0969ba805a2e3726a70ed34a3 (patch)
tree4341aed84ba24607ccb4c8426dfd695b2e484abb /include/llvm
parentde5e5ec3045a73a06b1054417f9ac6c02929e9ce (diff)
downloadllvm-91766fe066efe6e0969ba805a2e3726a70ed34a3.tar.gz
llvm-91766fe066efe6e0969ba805a2e3726a70ed34a3.tar.bz2
llvm-91766fe066efe6e0969ba805a2e3726a70ed34a3.tar.xz
Revert Chris' commits up to r149348 that started causing VMCoreTests unit test to fail.
These are: r149348 r149351 r149352 r149354 r149356 r149357 r149361 r149362 r149364 r149365 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149470 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Analysis/ValueTracking.h18
-rw-r--r--include/llvm/Constants.h36
2 files changed, 47 insertions, 7 deletions
diff --git a/include/llvm/Analysis/ValueTracking.h b/include/llvm/Analysis/ValueTracking.h
index 25150cdb0f..300f51df37 100644
--- a/include/llvm/Analysis/ValueTracking.h
+++ b/include/llvm/Analysis/ValueTracking.h
@@ -17,13 +17,14 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/DataTypes.h"
+#include <string>
namespace llvm {
+ template <typename T> class SmallVectorImpl;
class Value;
class Instruction;
class APInt;
class TargetData;
- class StringRef;
/// ComputeMaskedBits - Determine which of the bits specified in Mask are
/// known to be either zero or one and return them in the KnownZero/KnownOne
@@ -124,13 +125,16 @@ namespace llvm {
return GetPointerBaseWithConstantOffset(const_cast<Value*>(Ptr), Offset,TD);
}
- /// getConstantStringInfo - This function computes the length of a
+ /// GetConstantStringInfo - This function computes the length of a
/// null-terminated C string pointed to by V. If successful, it returns true
- /// and returns the string in Str. If unsuccessful, it returns false. This
- /// does not include the trailing nul character.
- bool getConstantStringInfo(const Value *V, StringRef &Str,
- uint64_t Offset = 0);
-
+ /// and returns the string in Str. If unsuccessful, it returns false. If
+ /// StopAtNul is set to true (the default), the returned string is truncated
+ /// by a nul character in the global. If StopAtNul is false, the nul
+ /// character is included in the result string.
+ bool GetConstantStringInfo(const Value *V, std::string &Str,
+ uint64_t Offset = 0,
+ bool StopAtNul = true);
+
/// GetStringLength - If we can compute the length of the string pointed to by
/// the specified pointer, return 'len+1'. If we can't, return 0.
uint64_t GetStringLength(Value *V);
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index a4723d37f0..43f625a68f 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -352,6 +352,17 @@ public:
// ConstantArray accessors
static Constant *get(ArrayType *T, ArrayRef<Constant*> V);
+ /// This method constructs a ConstantArray and initializes it with a text
+ /// string. The default behavior (AddNull==true) causes a null terminator to
+ /// be placed at the end of the array. This effectively increases the length
+ /// of the array by one (you've been warned). However, in some situations
+ /// this is not desired so if AddNull==false then the string is copied without
+ /// null termination.
+
+ // FIXME Remove this.
+ static Constant *get(LLVMContext &Context, StringRef Initializer,
+ bool AddNull = true);
+
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
@@ -362,6 +373,31 @@ public:
return reinterpret_cast<ArrayType*>(Value::getType());
}
+ // FIXME: String methods will eventually be removed.
+
+
+ /// isString - This method returns true if the array is an array of i8 and
+ /// the elements of the array are all ConstantInt's.
+ bool isString() const;
+
+ /// isCString - This method returns true if the array is a string (see
+ /// @verbatim
+ /// isString) and it ends in a null byte \0 and does not contains any other
+ /// @endverbatim
+ /// null bytes except its terminator.
+ bool isCString() const;
+
+ /// getAsString - If this array is isString(), then this method converts the
+ /// array to an std::string and returns it. Otherwise, it asserts out.
+ ///
+ std::string getAsString() const;
+
+ /// getAsCString - If this array is isCString(), then this method converts the
+ /// array (without the trailing null byte) to an std::string and returns it.
+ /// Otherwise, it asserts out.
+ ///
+ std::string getAsCString() const;
+
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);