Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/Token/Token.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions lib/Token/Token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<llvm::ConstantPointerNull>(Val))
this->name = "NULL";
}

void Token::set(llvm::Type *Ty, unsigned int Kind, std::string Index) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down