[cfe-commits] r108375 - in /cfe/trunk: include/clang/Basic/FileManager.h include/clang/Rewrite/Rewriter.h lib/Basic/FileManager.cpp lib/Checker/LLVMConventionsChecker.cpp lib/Frontend/PCHReader.cpp lib/Rewrite/Rewriter.cpp
Benjamin Kramer
benny.kra at googlemail.com
Wed Jul 14 16:19:41 PDT 2010
Author: d0k
Date: Wed Jul 14 18:19:41 2010
New Revision: 108375
URL: http://llvm.org/viewvc/llvm-project?rev=108375&view=rev
Log:
Pass StringRefs by value.
Modified:
cfe/trunk/include/clang/Basic/FileManager.h
cfe/trunk/include/clang/Rewrite/Rewriter.h
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Checker/LLVMConventionsChecker.cpp
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Rewrite/Rewriter.cpp
Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=108375&r1=108374&r2=108375&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Wed Jul 14 18:19:41 2010
@@ -189,7 +189,7 @@
/// getDirectory - Lookup, cache, and verify the specified directory. This
/// returns null if the directory doesn't exist.
///
- const DirectoryEntry *getDirectory(const llvm::StringRef &Filename) {
+ const DirectoryEntry *getDirectory(llvm::StringRef Filename) {
return getDirectory(Filename.begin(), Filename.end());
}
const DirectoryEntry *getDirectory(const char *FileStart,const char *FileEnd);
@@ -197,7 +197,7 @@
/// getFile - Lookup, cache, and verify the specified file. This returns null
/// if the file doesn't exist.
///
- const FileEntry *getFile(const llvm::StringRef &Filename) {
+ const FileEntry *getFile(llvm::StringRef Filename) {
return getFile(Filename.begin(), Filename.end());
}
const FileEntry *getFile(const char *FilenameStart,
@@ -206,8 +206,8 @@
/// \brief Retrieve a file entry for a "virtual" file that acts as
/// if there were a file with the given name on disk. The file
/// itself is not accessed.
- const FileEntry *getVirtualFile(const llvm::StringRef &Filename,
- off_t Size, time_t ModificationTime);
+ const FileEntry *getVirtualFile(llvm::StringRef Filename, off_t Size,
+ time_t ModificationTime);
void PrintStats() const;
};
Modified: cfe/trunk/include/clang/Rewrite/Rewriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Rewriter.h?rev=108375&r1=108374&r2=108375&view=diff
==============================================================================
--- cfe/trunk/include/clang/Rewrite/Rewriter.h (original)
+++ cfe/trunk/include/clang/Rewrite/Rewriter.h Wed Jul 14 18:19:41 2010
@@ -64,7 +64,7 @@
/// the buffer is specified relative to the original SourceBuffer. The
/// text is inserted after the specified location.
///
- void InsertText(unsigned OrigOffset, const llvm::StringRef &Str,
+ void InsertText(unsigned OrigOffset, llvm::StringRef Str,
bool InsertAfter = true);
@@ -72,14 +72,14 @@
/// offset in the buffer is specified relative to the original
/// SourceBuffer. The text is inserted before the specified location. This is
/// method is the same as InsertText with "InsertAfter == false".
- void InsertTextBefore(unsigned OrigOffset, const llvm::StringRef &Str) {
+ void InsertTextBefore(unsigned OrigOffset, llvm::StringRef Str) {
InsertText(OrigOffset, Str, false);
}
/// InsertTextAfter - Insert some text at the specified point, where the
/// offset in the buffer is specified relative to the original SourceBuffer.
/// The text is inserted after the specified location.
- void InsertTextAfter(unsigned OrigOffset, const llvm::StringRef &Str) {
+ void InsertTextAfter(unsigned OrigOffset, llvm::StringRef Str) {
InsertText(OrigOffset, Str);
}
@@ -87,7 +87,7 @@
/// buffer with a new string. This is effectively a combined "remove/insert"
/// operation.
void ReplaceText(unsigned OrigOffset, unsigned OrigLength,
- const llvm::StringRef &NewStr);
+ llvm::StringRef NewStr);
private: // Methods only usable by Rewriter.
@@ -164,7 +164,7 @@
/// InsertText - Insert the specified string at the specified location in the
/// original buffer. This method returns true (and does nothing) if the input
/// location was not rewritable, false otherwise.
- bool InsertText(SourceLocation Loc, const llvm::StringRef &Str,
+ bool InsertText(SourceLocation Loc, llvm::StringRef Str,
bool InsertAfter = true);
/// InsertTextAfter - Insert the specified string at the specified location in
@@ -172,7 +172,7 @@
/// the input location was not rewritable, false otherwise. Text is
/// inserted after any other text that has been previously inserted
/// at the some point (the default behavior for InsertText).
- bool InsertTextAfter(SourceLocation Loc, const llvm::StringRef &Str) {
+ bool InsertTextAfter(SourceLocation Loc, llvm::StringRef Str) {
return InsertText(Loc, Str);
}
@@ -181,7 +181,7 @@
/// location was not rewritable, false otherwise. Text is
/// inserted before any other text that has been previously inserted
/// at the some point.
- bool InsertTextBefore(SourceLocation Loc, const llvm::StringRef &Str) {
+ bool InsertTextBefore(SourceLocation Loc, llvm::StringRef Str) {
return InsertText(Loc, Str, false);
}
@@ -192,7 +192,7 @@
/// buffer with a new string. This is effectively a combined "remove/insert"
/// operation.
bool ReplaceText(SourceLocation Start, unsigned OrigLength,
- const llvm::StringRef &NewStr);
+ llvm::StringRef NewStr);
/// ReplaceStmt - This replaces a Stmt/Expr with another, using the pretty
/// printer to generate the replacement code. This returns true if the input
Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=108375&r1=108374&r2=108375&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Wed Jul 14 18:19:41 2010
@@ -331,8 +331,8 @@
}
const FileEntry *
-FileManager::getVirtualFile(const llvm::StringRef &Filename,
- off_t Size, time_t ModificationTime) {
+FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size,
+ time_t ModificationTime) {
const char *NameStart = Filename.begin(), *NameEnd = Filename.end();
++NumFileLookups;
Modified: cfe/trunk/lib/Checker/LLVMConventionsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/LLVMConventionsChecker.cpp?rev=108375&r1=108374&r2=108375&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/LLVMConventionsChecker.cpp (original)
+++ cfe/trunk/lib/Checker/LLVMConventionsChecker.cpp Wed Jul 14 18:19:41 2010
@@ -36,7 +36,7 @@
/// Check whether the declaration is semantically inside the top-level
/// namespace named by ns.
-static bool InNamespace(const Decl *D, const llvm::StringRef &NS) {
+static bool InNamespace(const Decl *D, llvm::StringRef NS) {
const DeclContext *DC = D->getDeclContext();
const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(D->getDeclContext());
if (!ND)
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=108375&r1=108374&r2=108375&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Wed Jul 14 18:19:41 2010
@@ -141,7 +141,7 @@
}
struct EmptyStringRef {
- bool operator ()(const llvm::StringRef &r) const { return r.empty(); }
+ bool operator ()(llvm::StringRef r) const { return r.empty(); }
};
struct EmptyBlock {
bool operator ()(const PCHPredefinesBlock &r) const { return r.Data.empty(); }
Modified: cfe/trunk/lib/Rewrite/Rewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Rewriter.cpp?rev=108375&r1=108374&r2=108375&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Rewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Rewriter.cpp Wed Jul 14 18:19:41 2010
@@ -40,7 +40,7 @@
AddReplaceDelta(OrigOffset, -Size);
}
-void RewriteBuffer::InsertText(unsigned OrigOffset, const llvm::StringRef &Str,
+void RewriteBuffer::InsertText(unsigned OrigOffset, llvm::StringRef Str,
bool InsertAfter) {
// Nothing to insert, exit early.
@@ -57,7 +57,7 @@
/// buffer with a new string. This is effectively a combined "remove+insert"
/// operation.
void RewriteBuffer::ReplaceText(unsigned OrigOffset, unsigned OrigLength,
- const llvm::StringRef &NewStr) {
+ llvm::StringRef NewStr) {
unsigned RealOffset = getMappedOffset(OrigOffset, true);
Buffer.erase(RealOffset, OrigLength);
Buffer.insert(RealOffset, NewStr.begin(), NewStr.end());
@@ -185,7 +185,7 @@
/// InsertText - Insert the specified string at the specified location in the
/// original buffer.
-bool Rewriter::InsertText(SourceLocation Loc, const llvm::StringRef &Str,
+bool Rewriter::InsertText(SourceLocation Loc, llvm::StringRef Str,
bool InsertAfter) {
if (!isRewritable(Loc)) return true;
FileID FID;
@@ -207,7 +207,7 @@
/// buffer with a new string. This is effectively a combined "remove/insert"
/// operation.
bool Rewriter::ReplaceText(SourceLocation Start, unsigned OrigLength,
- const llvm::StringRef &NewStr) {
+ llvm::StringRef NewStr) {
if (!isRewritable(Start)) return true;
FileID StartFileID;
unsigned StartOffs = getLocationOffsetAndFileID(Start, StartFileID);
More information about the cfe-commits
mailing list