[PATCH][StaticAnalyzer] new check comparing equal expression
Daniel Marjamäki
Daniel.Marjamaki at evidente.se
Thu Sep 26 02:30:26 PDT 2013
Hello!
Thanks for your reviews.
I have seen a few comments about using "const". I am confused about this. To me it seems that const is avoided throughout llvm/clang.
Can somebody clarify for me when it's appropriate to use const?
Is "const" ok in the analyzer but not in other parts of llvm/clang?
Should const be used for function arguments also or is it just for auto variables?
Should a function be const if it has no side effects? For instance:
class X {
public:
int get123() const { return 123; }
};
Should a non-pointer be const? For instance:
void f() {
const unsigned NumArgs = Args.size();
.. do various stuff, the intention is that NumArgs should not be changed ..
}
Best regards,
Daniel Marjamäki
..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
Mobile: +46 (0)709 12 42 62
E-mail: Daniel.Marjamaki at evidente.se
www.evidente.se
More information about the cfe-commits
mailing list