summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-06-01 20:00:16 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-06-01 20:00:16 +0000
commitc0f18a91ac8e8adef08e8a3a8e5c0f7a99fdbdf9 (patch)
tree8edcfcc3d745722af3308c8d601ffcb963ecd370 /clang
parent015455848e5145079e041510b2e54a4eb3d11b1e (diff)
downloadbcm5719-llvm-c0f18a91ac8e8adef08e8a3a8e5c0f7a99fdbdf9.tar.gz
bcm5719-llvm-c0f18a91ac8e8adef08e8a3a8e5c0f7a99fdbdf9.zip
Replace a few std::string& with StringRef. NFC.
Patch by Косов Евгений! llvm-svn: 238774
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Lex/Lexer.h2
-rw-r--r--clang/include/clang/Lex/PPCallbacks.h17
-rw-r--r--clang/include/clang/Lex/PTHManager.h2
-rw-r--r--clang/include/clang/Lex/Preprocessor.h2
-rw-r--r--clang/lib/Frontend/PrintPreprocessedOutput.cpp6
-rw-r--r--clang/lib/Lex/Lexer.cpp2
-rw-r--r--clang/lib/Lex/PTHLexer.cpp3
7 files changed, 16 insertions, 18 deletions
diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h
index 07564b9de78..12565d0b14b 100644
--- a/clang/include/clang/Lex/Lexer.h
+++ b/clang/include/clang/Lex/Lexer.h
@@ -228,7 +228,7 @@ public:
/// Stringify - Convert the specified string into a C string by escaping '\'
/// and " characters. This does not add surrounding ""'s to the string.
/// If Charify is true, this escapes the ' character instead of ".
- static std::string Stringify(const std::string &Str, bool Charify = false);
+ static std::string Stringify(StringRef Str, bool Charify = false);
/// Stringify - Convert the specified string into a C string by escaping '\'
/// and " characters. This does not add surrounding ""'s to the string.
diff --git a/clang/include/clang/Lex/PPCallbacks.h b/clang/include/clang/Lex/PPCallbacks.h
index 1ddb5d61eff..3803533b49b 100644
--- a/clang/include/clang/Lex/PPCallbacks.h
+++ b/clang/include/clang/Lex/PPCallbacks.h
@@ -155,7 +155,7 @@ public:
/// \param Loc The location of the directive.
/// \param str The text of the directive.
///
- virtual void Ident(SourceLocation Loc, const std::string &str) {
+ virtual void Ident(SourceLocation Loc, StringRef str) {
}
/// \brief Callback invoked when start reading any pragma directive.
@@ -165,14 +165,13 @@ public:
/// \brief Callback invoked when a \#pragma comment directive is read.
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
- const std::string &Str) {
+ StringRef Str) {
}
/// \brief Callback invoked when a \#pragma detect_mismatch directive is
/// read.
- virtual void PragmaDetectMismatch(SourceLocation Loc,
- const std::string &Name,
- const std::string &Value) {
+ virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
+ StringRef Value) {
}
/// \brief Callback invoked when a \#pragma clang __debug directive is read.
@@ -375,19 +374,19 @@ public:
Second->EndOfMainFile();
}
- void Ident(SourceLocation Loc, const std::string &str) override {
+ void Ident(SourceLocation Loc, StringRef str) override {
First->Ident(Loc, str);
Second->Ident(Loc, str);
}
void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
- const std::string &Str) override {
+ StringRef Str) override {
First->PragmaComment(Loc, Kind, Str);
Second->PragmaComment(Loc, Kind, Str);
}
- void PragmaDetectMismatch(SourceLocation Loc, const std::string &Name,
- const std::string &Value) override {
+ void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
+ StringRef Value) override {
First->PragmaDetectMismatch(Loc, Name, Value);
Second->PragmaDetectMismatch(Loc, Name, Value);
}
diff --git a/clang/include/clang/Lex/PTHManager.h b/clang/include/clang/Lex/PTHManager.h
index a4198f890e1..26178eddf36 100644
--- a/clang/include/clang/Lex/PTHManager.h
+++ b/clang/include/clang/Lex/PTHManager.h
@@ -129,7 +129,7 @@ public:
/// Create - This method creates PTHManager objects. The 'file' argument
/// is the name of the PTH file. This method returns NULL upon failure.
- static PTHManager *Create(const std::string& file, DiagnosticsEngine &Diags);
+ static PTHManager *Create(StringRef file, DiagnosticsEngine &Diags);
void setPreprocessor(Preprocessor *pp) { PP = pp; }
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index e0e09199123..f6e61c0e7ad 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -890,7 +890,7 @@ public:
///
/// These predefines are automatically injected when parsing the main file.
void setPredefines(const char *P) { Predefines = P; }
- void setPredefines(const std::string &P) { Predefines = P; }
+ void setPredefines(StringRef P) { Predefines = P; }
/// Return information about the specified preprocessor
/// identifier token.
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index 037a6a525e2..6192554299a 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -128,7 +128,7 @@ public:
CharSourceRange FilenameRange, const FileEntry *File,
StringRef SearchPath, StringRef RelativePath,
const Module *Imported) override;
- void Ident(SourceLocation Loc, const std::string &str) override;
+ void Ident(SourceLocation Loc, StringRef str) override;
void PragmaMessage(SourceLocation Loc, StringRef Namespace,
PragmaMessageKind Kind, StringRef Str) override;
void PragmaDebug(SourceLocation Loc, StringRef DebugType) override;
@@ -337,11 +337,11 @@ void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc,
/// Ident - Handle #ident directives when read by the preprocessor.
///
-void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, const std::string &S) {
+void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, StringRef S) {
MoveToLine(Loc);
OS.write("#ident ", strlen("#ident "));
- OS.write(&S[0], S.size());
+ OS.write(S.begin(), S.size());
EmittedTokensOnThisLine = true;
}
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 3f89ea649cb..4007914b6c0 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -199,7 +199,7 @@ Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc,
/// Stringify - Convert the specified string into a C string, with surrounding
/// ""'s, and with escaped \ and " characters.
-std::string Lexer::Stringify(const std::string &Str, bool Charify) {
+std::string Lexer::Stringify(StringRef Str, bool Charify) {
std::string Result = Str;
char Quote = Charify ? '\'' : '"';
for (unsigned i = 0, e = Result.size(); i != e; ++i) {
diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp
index af7a15384e3..5f63d35c5be 100644
--- a/clang/lib/Lex/PTHLexer.cpp
+++ b/clang/lib/Lex/PTHLexer.cpp
@@ -431,8 +431,7 @@ static void InvalidPTH(DiagnosticsEngine &Diags, const char *Msg) {
Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error, "%0")) << Msg;
}
-PTHManager *PTHManager::Create(const std::string &file,
- DiagnosticsEngine &Diags) {
+PTHManager *PTHManager::Create(StringRef file, DiagnosticsEngine &Diags) {
// Memory map the PTH file.
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileOrErr =
llvm::MemoryBuffer::getFile(file);
OpenPOWER on IntegriCloud