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

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 7 11:16:51 PST 2016


alexfh added inline comments.

================
Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:115
@@ +114,3 @@
+    diag(VD->getLocation(),
+         "variable definition is not allowed in header file");
+  }
----------------
alexfh wrote:
> Maybe add the name of the variable to the message? This would help users to understand the cause of the warning easier in case of macros, for example.
> 
> Same for the other message.
Also, we shouldn't say `not allowed` (not allowed by whom/what? Google C++ style guide? this check is not Google-specific, so it shouldn't rely on the user knowing/caring about Google C++ style). The message doesn't make it clear that variable definitions in header files are dangerous in general, not only this specific definition.

I'd phrase the message along the lines of "variable '%0' defined in a header file; variable definitions in header files can lead to ODR violations".


http://reviews.llvm.org/D15710





More information about the cfe-commits mailing list