diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-02-08 19:51:59 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-02-08 19:51:59 +0000 |
commit | 064fb20e7a29d00f29bf10f9d7f54d36456a2449 (patch) | |
tree | 348d7db9df353322b45116bc0e5199be572a423f /lib/Checker/BasicObjCFoundationChecks.cpp | |
parent | 39d67117f896c6e2faa727671ef64b3c04b0e3fe (diff) |
Simplify another switch/strcmp construct. No functionality/performance change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95561 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/BasicObjCFoundationChecks.cpp')
-rw-r--r-- | lib/Checker/BasicObjCFoundationChecks.cpp | 71 |
1 files changed, 16 insertions, 55 deletions
diff --git a/lib/Checker/BasicObjCFoundationChecks.cpp b/lib/Checker/BasicObjCFoundationChecks.cpp index b1ecfeb144..d6c09a2e04 100644 --- a/lib/Checker/BasicObjCFoundationChecks.cpp +++ b/lib/Checker/BasicObjCFoundationChecks.cpp @@ -163,61 +163,22 @@ bool BasicObjCFoundationChecks::AuditNSString(ExplodedNode* N, // FIXME: This is going to be really slow doing these checks with // lexical comparisons. - std::string name = S.getAsString(); - assert (!name.empty()); - const char* cstr = &name[0]; - unsigned len = name.size(); - - switch (len) { - default: - break; - case 8: - if (!strcmp(cstr, "compare:")) - return CheckNilArg(N, 0); - - break; - - case 15: - // FIXME: Checking for initWithFormat: will not work in most cases - // yet because [NSString alloc] returns id, not NSString*. We will - // need support for tracking expected-type information in the analyzer - // to find these errors. - if (!strcmp(cstr, "initWithFormat:")) - return CheckNilArg(N, 0); - - break; - - case 16: - if (!strcmp(cstr, "compare:options:")) - return CheckNilArg(N, 0); - - break; - - case 22: - if (!strcmp(cstr, "compare:options:range:")) - return CheckNilArg(N, 0); - - break; - - case 23: - - if (!strcmp(cstr, "caseInsensitiveCompare:")) - return CheckNilArg(N, 0); - - break; - - case 29: - if (!strcmp(cstr, "compare:options:range:locale:")) - return CheckNilArg(N, 0); - - break; - - case 37: - if (!strcmp(cstr, "componentsSeparatedByCharactersInSet:")) - return CheckNilArg(N, 0); - - break; - } + std::string NameStr = S.getAsString(); + llvm::StringRef Name(NameStr); + assert(!Name.empty()); + + // FIXME: Checking for initWithFormat: will not work in most cases + // yet because [NSString alloc] returns id, not NSString*. We will + // need support for tracking expected-type information in the analyzer + // to find these errors. + if (Name == "caseInsensitiveCompare:" || + Name == "compare:" || + Name == "compare:options:" || + Name == "compare:options:range:" || + Name == "compare:options:range:locale:" || + Name == "componentsSeparatedByCharactersInSet:" || + Name == "initWithFormat:") + return CheckNilArg(N, 0); return false; } |