[PATCH] D14592: Qt (version 4 or 5) signal/method checker

Evgeniy Dushistov via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 11 16:43:05 PST 2015


Dushistov added inline comments.

================
Comment at: lib/StaticAnalyzer/Checkers/QtSignalSlotChecker.cpp:114
@@ +113,3 @@
+                         printMethodNameWithPramaTypes(Out, C, FName, M, false);
+                         const std::string NS = qtNormalizeSignature(Out.str());
+                         if (NS == MethodWithParamsNorm)
----------------
jroelofs wrote:
> Why are you throwing away all the work that the parser did to build up the type signature as a QualType, pretty-printing it, and the re-parsing it by hand? ISTM it would be much better if qtNormalizeSignature had this type signature: `QualType qtNormalizeSignature(QualType)`.
Looks like `reviews` have no SMTP interface, so duplicate answer here:

First of all this code compare two things:                                                                                                     
1)QualType from clang,                                                                                                                         
2)string  that I get from                                                                                                                      
connect(obj1, "1f(unsgined int)", obj2, "2g(uint)");                                                                                           
                ^                          ^                                                                                                   
                here                       and here                                                                                            
                                                                                                                                               
so to simplify things I need compare QualType and data from                                                                                    
StringLiteral.                                                                                                                                 
                                                                                                                                               
The second thing, that should be menntioned,that                                                                                               
"Qt normalization" and converting output to string                                                                                             
(this normalization used by Qt when it compare at runtime                                                                                      
that signal match slot)                                                                                                                        
                                                                                                                                               
not match exactly to already existing in clang                                                                                                 
"print type functionality":                                                                                                                      
- it remove spaces every where, where possible                                                                                                 
- it print "uint" instead of "unsigned int"                                                                                                    
                                                                                                                                               
                                                                                                                                               
so I glad to have inteface like this                                                                                                           
`QualType qtNormalizeSignature(QualType)`                                                                                                      
but to use such interface I need convert StringLiteral conent                                                                                  
to function signature, in other words run parser inside parser,                                                                                
plus I have to hack PrintType from AST to make possible                                                                                        
print function signature in `Qt` way.                                                                                                          
                                                        


http://reviews.llvm.org/D14592





More information about the cfe-commits mailing list