[PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 7 05:55:36 PST 2016


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for working on this!


================
Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:21
@@ +20,3 @@
+
+   // Warning.
+   int g() {
----------------
hokein wrote:
> > For the static and const declarations I can see some benefit to ignoring for now, but the unnamed namespace in a header file is sufficiently nasty that many coding guidelines explicitly forbid it because of ODR violations (it really doesn't do what users think it will do). It's especially strange that we will warn about using a *named* namespace in a header file, but not an *unnamed* namespace, which is decidedly more behaviorally strange. I would prefer to see the check catch at least unnamed namespaces, if not static or const variable declarations.
> 
> Done.
> 
> > Also, I would be interested in hearing what "a lot of such usages in Google" means in more concrete terms for static or const definitions in header files, if you're able to share those numbers. I don't foresee that changing the requirements for this patch, but I'd still be curious to know for when I work on CERT's secure coding rules.
> 
> Yes, the const/static definitions are used widely in header files. The number is  ~200,000 including third-party projects.
> Yes, the const/static definitions are used widely in header files. The number is ~200,000 including third-party projects.

Yoiks, that is annoyingly high. Thank you for the numbers.


http://reviews.llvm.org/D15710





More information about the cfe-commits mailing list