• Richard's avatar
    [clang-tidy] Add readability-duplicate-include check · d2e8fb33
    Richard authored
    Looks for duplicate includes and removes them.
    
    Every time an include directive is processed, check a vector of filenames
    to see if the included file has already been included.  If so, it issues
    a warning and a replacement to remove the entire line containing the
    duplicated include directive.
    
    When a macro is defined or undefined, the vector of filenames is cleared.
    This enables including the same file multiple times, but getting
    different expansions based on the set of active macros at the time of
    inclusion.  For example:
    
      #undef NDEBUG
      #include "assertion.h"
      // ...code with assertions enabled
    
      #define NDEBUG
      #include "assertion.h"
      // ...code with assertions disabled
    
    Since macros are redefined between the inclusion of assertion.h,
    they are not flagged as redundant.
    
    Differential Revision: https://reviews.llvm.org/D7982
    d2e8fb33
ReleaseNotes.rst 7.11 KB