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:                 [email protected]

www.evidente.se

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to