[PATCH] D85666: [clang-tidy] IncludeInserter: allow <> in header name

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 05:18:29 PDT 2020


alexfh added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:31
                                                utils::IncludeSorter::IS_LLVM)),
-      MathHeader(Options.get("MathHeader", "math.h")) {}
+      MathHeader(Options.get("MathHeader", "<math.h>")) {}
 
----------------
hokein wrote:
> this looks like a bug fix, I think the check lit test didn't cover it before, maybe add a header verification in `test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp`.
I've already added this ;)


================
Comment at: clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp:98-103
+  assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "
+                      "registerPreprocessor()?");
+  bool IsAngled = Header.consume_front("<");
+  if (IsAngled != Header.consume_back(">"))
+    return llvm::None;
+  return createIncludeInsertion(SourceMgr->getMainFileID(), Header, IsAngled);
----------------
njames93 wrote:
> To save duplication could this not just dispatch to `createIncludeInsertion(FileID, StringRef)`
Good point! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85666



More information about the cfe-commits mailing list