aaron.ballman added a comment.

> ... which has the wrong precedence; an extra set of parens is necessary.
>  However, I don't want to add a set of parens if it isn't necessary. ...

One way to handle this is to not suggest the fixit if the container part of the 
equality check is not a DeclRefExpr (perhaps after ignoring implicit casts, 
etc). This means the fixit won't get suggested in some cases where it otherwise 
could, such as:

  std::vector<std::string> v;
  if (v[0] == "") {
  }

but it does mean that it will still catch the common cases.



================
Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:70
+      ignoringImpCasts(cxxBindTemporaryExpr(has(cxxConstructExpr(
+          hasDeclaration(cxxConstructorDecl(isDefaultConstructor())))))),
+      ignoringImplicit(cxxConstructExpr(
----------------
You should pull the 
`cxxConstructExpr(hasDeclaration(cxxConstructorDecl(isDefaultConstructor())))` 
into a separate variable and reuse it instead of spelling it out four times.


Repository:
  rL LLVM

https://reviews.llvm.org/D31542



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to