diff --git a/include/Token/Token.h b/include/Token/Token.h index 9dea750..af18552 100644 --- a/include/Token/Token.h +++ b/include/Token/Token.h @@ -10,6 +10,7 @@ #include "llvm/IR/Type.h" #include "llvm/IR/Value.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/IR/Constants.h" namespace spatial { @@ -68,6 +69,7 @@ class Token { bool isValPointerType() const; std::string getHash() const; bool isPointerType() const; + bool isNullPointer() const; bool operator<(const Token &TheToken) const; bool operator==(const Token &TheToken) const; diff --git a/lib/Token/Token.cpp b/lib/Token/Token.cpp index 48964af..b63e219 100644 --- a/lib/Token/Token.cpp +++ b/lib/Token/Token.cpp @@ -12,6 +12,8 @@ void Token::set(llvm::Value *Val, unsigned int Kind, std::string Index, this->IsGlobal = Global; if (!Func) this->IsGlobal = true; + if(llvm::isa(Val)) + this->name = "NULL"; } void Token::set(llvm::Type *Ty, unsigned int Kind, std::string Index) { @@ -161,6 +163,8 @@ std::ostream &operator<<(std::ostream &OS, const Token &A) { /// function etc llvm::StringRef Token::getName() const { if (this->Kind == 0) { + if(this->name != "") + return this->name; return this->Val->getName(); } else if (this->Kind == 2) { return this->Arg->getName(); @@ -234,6 +238,11 @@ bool Token::isValPointerType() const { return false; } +/// isNullPointer - Return true if token is a nullptr +bool Token::isNullPointer() const { + return this->name == "NULL"; +} + /// getHash - Calculates the hash for alias to avoid multiple enteries of same /// alias std::string Token::getHash() const {