Exemplo n.º 1
0
Arquivo: lexer.cpp Projeto: aep/clay
static bool identStr(llvm::SmallString<16> &x) {
    char c;
    if (!identChar1(c)) return false;
    x.clear();
    x.push_back(c);
    while (true) {
        const char *p = save();
        if (!identChar2(c)) {
            restore(p);
            break;
        }
        x.push_back(c);
    }
    return true;
}
Exemplo n.º 2
0
/// \brief Compute the relative path that names the given file relative to
/// the given directory.
static void computeRelativePath(FileManager &FM, const DirectoryEntry *Dir,
                                const FileEntry *File,
                                llvm::SmallString<128> &Result) {
  Result.clear();

  StringRef FilePath = File->getDir()->getName();
  StringRef Path = FilePath;
  while (!Path.empty()) {
    if (const DirectoryEntry *CurDir = FM.getDirectory(Path)) {
      if (CurDir == Dir) {
        Result = FilePath.substr(Path.size());
        llvm::sys::path::append(Result, 
                                llvm::sys::path::filename(File->getName()));
        return;
      }
    }
    
    Path = llvm::sys::path::parent_path(Path);
  }
  
  Result = File->getName();
}