[PATCH] D42728: Add more warnings for implict conversions (e.g. double truncation to float).
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 12:27:13 PST 2018
ABataev added inline comments.
================
Comment at: lib/Sema/SemaChecking.cpp:9152
+static bool ShouldWarnFloatPrecision(Sema &S, Expr *E,
+ const BuiltinType *SourceBT,
----------------
Function names should follow coding standard, `shouldWarnFloatPrecision`.
================
Comment at: lib/Sema/SemaChecking.cpp:9158
+ // representable in the target type.
+ Expr::EvalResult result;
+ if (E->EvaluateAsRValue(result, S.Context)) {
----------------
The names of the variables should start from capital letter, `Result`
================
Comment at: lib/Sema/SemaChecking.cpp:9166-9167
+ }
+ if (S.SourceMgr.isInSystemMacro(CC))
+ return true;
+ return true;
----------------
Do you need this check? With or without it you just return `true`.
================
Comment at: lib/Sema/SemaChecking.cpp:9215
+/// floating-point precision.
+static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) {
+ assert(E->isAssignmentOp() && (E->getOpcode() != BO_Assign) &&
----------------
Start from small letter function names.
================
Comment at: lib/Sema/SemaChecking.cpp:9221
+ QualType T = E->getLHS()->getType();
+ const BuiltinType *SourceBT = dyn_cast<BuiltinType>(
+ S.Context.getCanonicalType(E->getRHS()->getType()).getTypePtr());
----------------
`const BuiltinType *`->`const auto *`
================
Comment at: lib/Sema/SemaChecking.cpp:9223
+ S.Context.getCanonicalType(E->getRHS()->getType()).getTypePtr());
+ const BuiltinType *TargetBT =
+ dyn_cast<BuiltinType>(S.Context.getCanonicalType(T).getTypePtr());
----------------
`const BuiltinType *`->`const auto *`
https://reviews.llvm.org/D42728
More information about the llvm-commits
mailing list