blob: 9c4d76392704901c060947d9dc95a21475475655 [file] [log] [blame]
//===-- TVSnapshot.h - Wrapper class for llvm-tv snapshots -------*- C++ -*-==//
//
// The gui for llvm-tv.
//
//===----------------------------------------------------------------------===//
#ifndef TVSNAPSHOT_H
#define TVSNAPSHOT_H
#include <string>
#include <vector>
#include <libgen.h>
#include "llvm/Module.h"
using namespace llvm;
/// TVSnapshot - Wrapper class for snapshots.
///
class TVSnapshot {
Module *M;
std::string filename;
std::string myLabel;
void readBytecodeFile ();
void fixLabel () { myLabel = basename ((char*)myLabel.c_str ()) ; }
public:
explicit TVSnapshot (const std::string &_name)
: M (0), filename (_name), myLabel (filename) { fixLabel(); }
explicit TVSnapshot (const char *_name)
: M (0), filename (_name), myLabel (filename) { fixLabel(); }
~TVSnapshot() { delete M; }
const char *label () const { return myLabel.c_str (); }
unsigned getTimestamp () const { return (unsigned) strtol (label(), 0, 0); }
bool operator < (const TVSnapshot &s) const {
return getTimestamp () < s.getTimestamp ();
}
Module *getModule () {
if (!M)
readBytecodeFile ();
return M;
}
};
#endif // TVSNAPSHOT_H