Skip to content

Instantly share code, notes, and snippets.

@ned14
Created May 30, 2014 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ned14/d4af40fb21487ec8c833 to your computer and use it in GitHub Desktop.
Save ned14/d4af40fb21487ec8c833 to your computer and use it in GitHub Desktop.
Things a clang AST precommit hook checker should check for:
1. Warn in presence of conversion constructor not marked as explicit unless annotated.
2. Warn if move constructors or move assignment is not noexcept where all the things it calls are noexcept (I really wish this was the default in the language actually, auto-propagating noexcept).
3. Warn if you have a copy or move constructor without matching copy and move assignment, unless annotated.
4. Warn if a type satisfies the requirements of use in unordered_map but provides no hash, unless annotated.
5. Warn where pair<> is used where optional<> is better.
6. Warn where exceptions are used where optional<> is better.
7. Error when operator new is used directly, unless annotated. Perhaps same for delete (except decorators)?
8. Warn use of C header when C++ is available, unless annotated.
9. (optional) use of else or else if without {
10. Use of std::shared_ptr (unique later perhaps) instead of make_shared, unless annotated
11. More than a single return from a function/method, unless annotated
12. Warn if a function is not marked constexpr yet only calls constexpr functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment