[cfe-commits] [Patch][Review Request]Revised patch for PR7287
Ted Kremenek
kremenek at apple.com
Mon Nov 1 16:34:22 PDT 2010
Ah yes, your right. One can call a operator() function directly.
On Nov 1, 2010, at 4:31 PM, Douglas Gregor wrote:
>
> On Nov 1, 2010, at 4:25 PM, Ted Kremenek wrote:
>
>> Doug,
>>
>> This isn't the right fix. VisitCallExpr() should never be called with functions that don't have an identifier.
>
> Why not? Given this:
>
> struct X { };
> bool operator==(X, X);
> void f(X a, X b) { (void)operator==(a, b); }
>
> the correct AST for the call is:
>
> (CallExpr 0x5027270 <col:26, col:41> '_Bool'
> (ImplicitCastExpr 0x5027260 <col:26, <invalid sloc>> '_Bool (*)(struct X, struct X)' <FunctionToPointerDecay>
> (DeclRefExpr 0x502722c <col:26, <invalid sloc>> '_Bool (struct X, struct X)' FunctionDecl='operator==' 0x5027030))
> (CXXConstructExpr 0x5027460 <col:37> 'struct X''void (const struct X &) throw()'
> (ImplicitCastExpr 0x5027450 <col:37> 'const struct X' <NoOp> lvalue
> (DeclRefExpr 0x50271f4 <col:37> 'struct X' ParmVar='a' 0x50270a0)))
> (CXXConstructExpr 0x50274a0 <col:40> 'struct X''void (const struct X &) throw()'
> (ImplicitCastExpr 0x5027490 <col:40> 'const struct X' <NoOp> lvalue
> (DeclRefExpr 0x5027210 <col:40> 'struct X' ParmVar='b' 0x50270e0))))))
>
> - Doug
>
>> On Nov 1, 2010, at 4:18 PM, Douglas Gregor wrote:
>>
>>>
>>> On Nov 1, 2010, at 3:01 PM, Jim Goodnow II wrote:
>>>
>>>> Okay, how about this? :-)
>>>
>>> Thanks, committed as r117970.
>>>
>>> - Doug
>>>
>>>> Index: lib/Checker/CStringChecker.cpp
>>>> ===================================================================
>>>> --- lib/Checker/CStringChecker.cpp (revision 117853)
>>>> +++ lib/Checker/CStringChecker.cpp (working copy)
>>>> @@ -905,7 +905,10 @@
>>>> return false;
>>>>
>>>> // Get the name of the callee. If it's a builtin, strip off the prefix.
>>>> - llvm::StringRef Name = FD->getName();
>>>> + IdentifierInfo *II = FD->getIdentifier();
>>>> + if (!II) // if no idenifier, not a simple C function
>>>> + return false;
>>>> + llvm::StringRef Name = II->getName();
>>>> if (Name.startswith("__builtin_"))
>>>> Name = Name.substr(10);
>>>>
>>>> Index: lib/Checker/PthreadLockChecker.cpp
>>>> ===================================================================
>>>> --- lib/Checker/PthreadLockChecker.cpp (revision 117853)
>>>> +++ lib/Checker/PthreadLockChecker.cpp (working copy)
>>>> @@ -65,7 +65,10 @@
>>>> if (!R)
>>>> return;
>>>>
>>>> - llvm::StringRef FName = R->getDecl()->getName();
>>>> + IdentifierInfo *II = R->getDecl()->getIdentifier();
>>>> + if (!II) // if no idenifier, not a simple C function
>>>> + return;
>>>> + llvm::StringRef FName = II->getName();
>>>>
>>>> if (FName == "pthread_mutex_lock") {
>>>> if (CE->getNumArgs() != 1)<PR7287.b.patch>_______________________________________________
>>>> cfe-commits mailing list
>>>> cfe-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
More information about the cfe-commits
mailing list