[cfe-commits] r84341 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Daniel Dunbar
daniel at zuster.org
Sat Oct 17 11:12:46 PDT 2009
Author: ddunbar
Date: Sat Oct 17 13:12:45 2009
New Revision: 84341
URL: http://llvm.org/viewvc/llvm-project?rev=84341&view=rev
Log:
Simplify.
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=84341&r1=84340&r2=84341&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Sat Oct 17 13:12:45 2009
@@ -81,7 +81,7 @@
if (!II)
return NoConvention;
- const char *s = II->getName();
+ const char *s = II->getNameStart();
// A method/function name may contain a prefix. We don't know it is there,
// however, until we encounter the first '_'.
@@ -208,35 +208,14 @@
// Type querying functions.
//===----------------------------------------------------------------------===//
-static bool hasPrefix(const char* s, const char* prefix) {
- if (!prefix)
- return true;
-
- char c = *s;
- char cP = *prefix;
-
- while (c != '\0' && cP != '\0') {
- if (c != cP) break;
- c = *(++s);
- cP = *(++prefix);
- }
-
- return cP == '\0';
-}
-
-static bool hasSuffix(const char* s, const char* suffix) {
- const char* loc = strstr(s, suffix);
- return loc && strcmp(suffix, loc) == 0;
-}
-
static bool isRefType(QualType RetTy, const char* prefix,
ASTContext* Ctx = 0, const char* name = 0) {
// Recursively walk the typedef stack, allowing typedefs of reference types.
while (1) {
if (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
- const char* TDName = TD->getDecl()->getIdentifier()->getName();
- if (hasPrefix(TDName, prefix) && hasSuffix(TDName, "Ref"))
+ llvm::StringRef TDName = TD->getDecl()->getIdentifier()->getNameStr();
+ if (TDName.startswith(prefix) && TDName.endswith("Ref"))
return true;
RetTy = TD->getDecl()->getUnderlyingType();
@@ -254,7 +233,7 @@
return false;
// Does the name start with the prefix?
- return hasPrefix(name, prefix);
+ return llvm::StringRef(name).startswith(prefix);
}
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list