aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2009-09-05 09:49:39 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2009-09-05 09:49:39 +0000
commit458fb10ef5ba2d7b375c6c64095c1458af0a5be3 (patch)
tree243b4912f88f6653120aca8c88582041ffed8828
parenta18df0ec71c5c95fb6809d4a80050f7b218f38b5 (diff)
Replace some instances of std::string with StringRefs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81079 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/FileManager.h12
-rw-r--r--include/clang/Frontend/InitHeaderSearch.h6
-rw-r--r--lib/Basic/FileManager.cpp3
-rw-r--r--lib/Frontend/InitHeaderSearch.cpp17
4 files changed, 18 insertions, 20 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h
index d6a0cf34d9..d684449c85 100644
--- a/include/clang/Basic/FileManager.h
+++ b/include/clang/Basic/FileManager.h
@@ -15,12 +15,10 @@
#define LLVM_CLANG_FILEMANAGER_H
#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Config/config.h" // for mode_t
-#include <map>
-#include <set>
-#include <string>
// FIXME: Enhance libsystem to support inode and other fields in stat.
#include <sys/types.h>
#include <sys/stat.h>
@@ -156,16 +154,16 @@ public:
/// getDirectory - Lookup, cache, and verify the specified directory. This
/// returns null if the directory doesn't exist.
///
- const DirectoryEntry *getDirectory(const std::string &Filename) {
- return getDirectory(&Filename[0], &Filename[0] + Filename.size());
+ const DirectoryEntry *getDirectory(const llvm::StringRef &Filename) {
+ return getDirectory(Filename.begin(), Filename.end());
}
const DirectoryEntry *getDirectory(const char *FileStart,const char *FileEnd);
/// getFile - Lookup, cache, and verify the specified file. This returns null
/// if the file doesn't exist.
///
- const FileEntry *getFile(const std::string &Filename) {
- return getFile(&Filename[0], &Filename[0] + Filename.size());
+ const FileEntry *getFile(const llvm::StringRef &Filename) {
+ return getFile(Filename.begin(), Filename.end());
}
const FileEntry *getFile(const char *FilenameStart,
const char *FilenameEnd);
diff --git a/include/clang/Frontend/InitHeaderSearch.h b/include/clang/Frontend/InitHeaderSearch.h
index 51516661c9..23499c641b 100644
--- a/include/clang/Frontend/InitHeaderSearch.h
+++ b/include/clang/Frontend/InitHeaderSearch.h
@@ -14,11 +14,11 @@
#ifndef LLVM_CLANG_FRONTEND_INIT_HEADER_SEARCH_H_
#define LLVM_CLANG_FRONTEND_INIT_HEADER_SEARCH_H_
+#include "clang/Lex/DirectoryLookup.h"
+#include "llvm/ADT/StringRef.h"
#include <string>
#include <vector>
-#include "clang/Lex/DirectoryLookup.h"
-
namespace clang {
class HeaderSearch;
@@ -48,7 +48,7 @@ public:
: Headers(HS), Verbose(verbose), isysroot(iSysroot) {}
/// AddPath - Add the specified path to the specified group list.
- void AddPath(const std::string &Path, IncludeDirGroup Group,
+ void AddPath(const llvm::StringRef &Path, IncludeDirGroup Group,
bool isCXXAware, bool isUserSupplied,
bool isFramework, bool IgnoreSysRoot = false);
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index afc9284554..aadafa5584 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -22,6 +22,9 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
#include "llvm/Config/config.h"
+#include <map>
+#include <set>
+#include <string>
using namespace clang;
// FIXME: Enhance libsystem to support inode and other fields.
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index 2172f61a37..8674261570 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -23,9 +23,10 @@
#include <cstdio>
using namespace clang;
-void InitHeaderSearch::AddPath(const std::string &Path, IncludeDirGroup Group,
- bool isCXXAware, bool isUserSupplied,
- bool isFramework, bool IgnoreSysRoot) {
+void InitHeaderSearch::AddPath(const llvm::StringRef &Path,
+ IncludeDirGroup Group, bool isCXXAware,
+ bool isUserSupplied, bool isFramework,
+ bool IgnoreSysRoot) {
assert(!Path.empty() && "can't handle empty path here");
FileManager &FM = Headers.getFileMgr();
@@ -53,9 +54,7 @@ void InitHeaderSearch::AddPath(const std::string &Path, IncludeDirGroup Group,
// If the directory exists, add it.
- if (const DirectoryEntry *DE = FM.getDirectory(&MappedPath[0],
- &MappedPath[0]+
- MappedPath.size())) {
+ if (const DirectoryEntry *DE = FM.getDirectory(MappedPath.str())) {
IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied,
isFramework));
return;
@@ -64,8 +63,7 @@ void InitHeaderSearch::AddPath(const std::string &Path, IncludeDirGroup Group,
// Check to see if this is an apple-style headermap (which are not allowed to
// be frameworks).
if (!isFramework) {
- if (const FileEntry *FE = FM.getFile(&MappedPath[0],
- &MappedPath[0]+MappedPath.size())) {
+ if (const FileEntry *FE = FM.getFile(MappedPath.str())) {
if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) {
// It is a headermap, add it to the search path.
IncludeGroup[Group].push_back(DirectoryLookup(HM, Type,isUserSupplied));
@@ -90,8 +88,7 @@ void InitHeaderSearch::AddEnvVarPaths(const char *Name) {
if (delim-at == 0)
AddPath(".", Angled, false, true, false);
else
- AddPath(std::string(at, std::string::size_type(delim-at)), Angled, false,
- true, false);
+ AddPath(llvm::StringRef(at, delim-at), Angled, false, true, false);
at = delim + 1;
delim = strchr(at, llvm::sys::PathSeparator);
}