[PATCH] D18914: [clang-tidy] new readability-redundant-inline

Samuel Benzaquen via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 11 09:29:55 PDT 2016


sbenza added inline comments.

================
Comment at: clang-tidy/readability/RedundantInlineCheck.cpp:59
@@ +58,3 @@
+  while (!RawLexer.LexFromRawLexer(Tok)) {
+    if (Tok.is(tok::semi) || Tok.is(tok::l_brace))
+      break;
----------------
Parsing C++ is hard.
Stopping at the first `{` means you will have a false negative here:

```
    template <bool> struct S{};
    S<bool{}> inline foo() { return {}; }

```
I think we should just continue until we find the 'inline' keyword. We already know it is there from the matching.

We could also limit the search until functionDecl->getLocation(). We don't have to look until LocEnd() because we won't find it after the function name.

================
Comment at: clang-tidy/readability/RedundantInlineCheck.cpp:105
@@ +104,3 @@
+  // each FunctionDecl.
+  SmallVector<Token, 16> Tokens = ParseTokens(FileRange, Result);
+  for (Token Tok : Tokens) {
----------------
Maybe ParseTokens should just return the specific token we are looking for.

================
Comment at: docs/clang-tidy/checks/readability-redundant-inline.rst:12
@@ +11,3 @@
+    inline int f() {
+	  return 0;
+	}
----------------
bad alignment


http://reviews.llvm.org/D18914





More information about the cfe-commits mailing list