[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 22 16:30:08 PDT 2019


nickdesaulniers added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:8107
+            return true;
+          Pedantic |= ImplicitMatch == analyze_printf::ArgType::NoMatchPedantic;
+        }
----------------
At this point `ImplicitMatch` can only have the value `analyze_printf::ArgType::NoMatchPedantic` as `ArgType::MatchKind` is an enum with only 3 values (see `clang/include/clang/AST/FormatString.h`).

Rather than have conditional/ternaries for each case, I think 2 conditionals are maybe simpler:

```
if (ImplicitMatch == analyze_printf::ArgType::Match)
  return true;
else if (ImplicitMatch == analyze_printf::ArgType::NoMatchPedantic)
  Pedantic = true;
```

The `|=` is kind of more complicated than simple assignment.

Then you don't need a block for `if (ImplicitMatch)`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66186/new/

https://reviews.llvm.org/D66186





More information about the cfe-commits mailing list