Replace startsWith functions with StringRef.
llvm-svn: 86774
This commit is contained in:
parent
9169a37daf
commit
045c92f812
|
|
@ -152,26 +152,6 @@ static std::vector<std::string> splitLines(const char *Str, unsigned Len,
|
||||||
return Lines;
|
return Lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Determine whether the string Haystack starts with the
|
|
||||||
/// substring Needle.
|
|
||||||
static bool startsWith(const std::string &Haystack, const char *Needle) {
|
|
||||||
for (unsigned I = 0, N = Haystack.size(); Needle[I] != 0; ++I) {
|
|
||||||
if (I == N)
|
|
||||||
return false;
|
|
||||||
if (Haystack[I] != Needle[I])
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Determine whether the string Haystack starts with the
|
|
||||||
/// substring Needle.
|
|
||||||
static inline bool startsWith(const std::string &Haystack,
|
|
||||||
const std::string &Needle) {
|
|
||||||
return startsWith(Haystack, Needle.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
|
bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
|
||||||
unsigned PCHPredefLen,
|
unsigned PCHPredefLen,
|
||||||
FileID PCHBufferID,
|
FileID PCHBufferID,
|
||||||
|
|
@ -207,7 +187,7 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
|
||||||
bool ConflictingDefines = false;
|
bool ConflictingDefines = false;
|
||||||
for (unsigned I = 0, N = MissingPredefines.size(); I != N; ++I) {
|
for (unsigned I = 0, N = MissingPredefines.size(); I != N; ++I) {
|
||||||
const std::string &Missing = MissingPredefines[I];
|
const std::string &Missing = MissingPredefines[I];
|
||||||
if (!startsWith(Missing, "#define ") != 0) {
|
if (!llvm::StringRef(Missing).startswith("#define ")) {
|
||||||
Reader.Diag(diag::warn_pch_compiler_options_mismatch);
|
Reader.Diag(diag::warn_pch_compiler_options_mismatch);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +210,7 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
|
||||||
= std::lower_bound(CmdLineLines.begin(), CmdLineLines.end(),
|
= std::lower_bound(CmdLineLines.begin(), CmdLineLines.end(),
|
||||||
MacroDefStart);
|
MacroDefStart);
|
||||||
for (; ConflictPos != CmdLineLines.end(); ++ConflictPos) {
|
for (; ConflictPos != CmdLineLines.end(); ++ConflictPos) {
|
||||||
if (!startsWith(*ConflictPos, MacroDefStart)) {
|
if (!llvm::StringRef(*ConflictPos).startswith(MacroDefStart)) {
|
||||||
// Different macro; we're done.
|
// Different macro; we're done.
|
||||||
ConflictPos = CmdLineLines.end();
|
ConflictPos = CmdLineLines.end();
|
||||||
break;
|
break;
|
||||||
|
|
@ -296,7 +276,7 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
|
||||||
std::back_inserter(ExtraPredefines));
|
std::back_inserter(ExtraPredefines));
|
||||||
for (unsigned I = 0, N = ExtraPredefines.size(); I != N; ++I) {
|
for (unsigned I = 0, N = ExtraPredefines.size(); I != N; ++I) {
|
||||||
const std::string &Extra = ExtraPredefines[I];
|
const std::string &Extra = ExtraPredefines[I];
|
||||||
if (!startsWith(Extra, "#define ") != 0) {
|
if (!llvm::StringRef(Extra).startswith("#define ")) {
|
||||||
Reader.Diag(diag::warn_pch_compiler_options_mismatch);
|
Reader.Diag(diag::warn_pch_compiler_options_mismatch);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -316,8 +296,7 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
|
||||||
// the PCH file.
|
// the PCH file.
|
||||||
if (IdentifierInfo *II = Reader.get(MacroName.c_str(),
|
if (IdentifierInfo *II = Reader.get(MacroName.c_str(),
|
||||||
MacroName.c_str() + MacroName.size())) {
|
MacroName.c_str() + MacroName.size())) {
|
||||||
Reader.Diag(diag::warn_macro_name_used_in_pch)
|
Reader.Diag(diag::warn_macro_name_used_in_pch) << II;
|
||||||
<< II;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue