[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 14 06:21:06 PST 2018


aaron.ballman added inline comments.


================
Comment at: lib/Sema/SemaChecking.cpp:113-115
+static void PrettyPrintFloat(const llvm::APFloat &floatValue,
+                             const llvm::fltSemantics &floatSem,
+                             SmallVectorImpl<char> &prettyFloatValue) {
----------------
Parameter names should be in PascalCase, not camelCase.


================
Comment at: lib/Sema/SemaChecking.cpp:10920-10921
+    if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+      if (S.SourceMgr.isInSystemMacro(CC))
+        return;
+      const llvm::fltSemantics &FloatSemantics =
----------------
It seems wrong to early return here -- that means none of the later checks are run on system macros, but we've also not diagnosed anything as being wrong with the user's code yet.


================
Comment at: lib/Sema/SemaChecking.cpp:10938
+                << E->getSourceRange() << clang::SourceRange(CC));
+        return;
+      }
----------------
This doesn't seem like something we need to early return for?


https://reviews.llvm.org/D52835





More information about the cfe-commits mailing list