[PATCH] D63288: [clang-tidy] Generalize TransformerClangTidyCheck to take a rule generator.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 11:32:42 PDT 2019


ymandel marked 2 inline comments as done.
ymandel added inline comments.


================
Comment at: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp:92
+  const std::string Input = "void log(int);";
+  EXPECT_EQ(Input, test::runCheckOnCode<NeedsC99Check>(Input));
+}
----------------
ymandel wrote:
> gribozavr wrote:
> > Would adding `-std=c99` to `ExtraArgs`, and setting `Filename` to `input.c` work?
> No, nothing seems to work. I can't find a way to ever set bits in LangOptions. I'm rather confused why that's the case...
I found the answer: getLangOpts() is not guaranteed to work at check-creation time. This makes sense, since a single check may be run against many different files.  I'd say its a flaw in the API though since it seems like a feature of the check, when its really a feature of the file. We should update the API to warn about this and possibly improve it to avoid the confusion.

I'll update the code to save the std::function and invoke at registerMatchers() time instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63288





More information about the cfe-commits mailing list