[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
This revision was automatically updated to reflect the committed changes. Closed by commit rG7f6e0052a97f: [clang-tidy] Add misc-header-include-cycle check (authored by PiotrZSL). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,59 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: cp %s %T/header-include-cycle.cpp +// RUN: clang-tidy %T/header-include-cycle.cpp -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES "-implicit-check-not={{note|warning|error}}:" --dump-input=fail +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include "header-include-cycle.cpp" +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: direct self-inclusion of header file 'header-include-cycle.cpp' [misc-header-include-cycle] + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: :[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES:
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 534183. PiotrZSL added a comment. Reorder warnigns & copy .cpp file to Output Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,59 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: cp %s %T/header-include-cycle.cpp +// RUN: clang-tidy %T/header-include-cycle.cpp -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES "-implicit-check-not={{note|warning|error}}:" --dump-input=fail +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include "header-include-cycle.cpp" +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: direct self-inclusion of header file 'header-include-cycle.cpp' [misc-header-include-cycle] + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: :[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
This revision was automatically updated to reflect the committed changes. Closed by commit rGf3aa6cc0f5d5: [clang-tidy] Add misc-header-include-cycle check (authored by PiotrZSL). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES "-implicit-check-not={{note|warning|error}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: :[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note:
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 533952. PiotrZSL added a comment. This revision is now accepted and ready to land. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES "-implicit-check-not={{note|warning|error}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: :[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note: 'header-include-cycle.second.hpp' included from here +//
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL planned changes to this revision. PiotrZSL added a comment. TODO: Split tests into multiple files (to isolate issue). If possible remove usage of FileCheck. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL added a comment. To be honest I have no idea why it failed, simply because there is CHECK-MESSAGES for that log. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 513898. PiotrZSL added a comment. Small changes remove, file name Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: :[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note: 'header-include-cycle.second.hpp' included from here +// CHECK-MESSAGES: :[[@LINE-5]]:10: note:
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
thakis added a comment. This breaks tests: http://45.33.8.238/linux/104455/step_8.txt Please take a look and revert for now if it takes a while to fix. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG9ece8753d5e6: [clang-tidy] Add misc-header-include-cycle check (authored by PiotrZSL). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +//
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 513896. PiotrZSL marked an inline comment as done. PiotrZSL added a comment. Fix one small nit. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note: 'header-include-cycle.second.hpp'
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
njames93 accepted this revision. njames93 added a comment. This revision is now accepted and ready to land. LGTM: Just one small nit. Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:148-150 +return std::any_of( +IgnoredFilesRegexes.begin(), IgnoredFilesRegexes.end(), +[&](const llvm::Regex ) { return It.match(FileName); }); Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 513886. PiotrZSL marked 3 inline comments as done. PiotrZSL added a comment. Small redesign (review comments) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note:
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL marked 4 inline comments as done. PiotrZSL added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:134-135 +do { + if (CurrentIt->Name.empty()) +continue; + njames93 wrote: > Is this a case that can ever come up? > If it does come up, surely any notes emitted after that would be garbage, in > which case wouldn't it make more sense to break rather than continue? I will remove this... Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:146 + if (Location.isInvalid()) +continue; + njames93 wrote: > Again whats the rationale for using continue over break here? Idea is to provide any information, even if it could be missing something. Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:148-150 + Check.diag(Location, "'%0' included from command line", + DiagnosticIDs::Note) + << CurrentIt->Name; njames93 wrote: > Is this a case that is expected to come up, if so can there be a test added. > Likewise if we do have a file that was included from the command line, > surely we should break after emitting that diagnostic, It's not like the > command line can be included from another file. I didn't found any case it could be, added this as an preclusion. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
njames93 added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:134-135 +do { + if (CurrentIt->Name.empty()) +continue; + Is this a case that can ever come up? If it does come up, surely any notes emitted after that would be garbage, in which case wouldn't it make more sense to break rather than continue? Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:146 + if (Location.isInvalid()) +continue; + Again whats the rationale for using continue over break here? Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:148-150 + Check.diag(Location, "'%0' included from command line", + DiagnosticIDs::Note) + << CurrentIt->Name; Is this a case that is expected to come up, if so can there be a test added. Likewise if we do have a file that was included from the command line, surely we should break after emitting that diagnostic, It's not like the command line can be included from another file. Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:154-161 + static llvm::StringRef getFileName(llvm::StringRef FilePath) { +llvm::StringRef FileName = FilePath; +if (FileName.contains('/')) + FileName = FileName.rsplit('/').second; +if (FileName.contains('\\')) + FileName = FileName.rsplit('\\').second; +return FileName; Dont reinvent the wheel - `llvm::sys::path::filename` does the same thing Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 513694. PiotrZSL added a comment. Ping + Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note: 'header-include-cycle.second.hpp' included from here +// CHECK-MESSAGES:
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 503251. PiotrZSL added a comment. Rebase due to broken baseline Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note: 'header-include-cycle.second.hpp' included from here +// CHECK-MESSAGES:
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 503144. PiotrZSL added a comment. Rebase due to failed clangd tests on windows Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note: 'header-include-cycle.second.hpp' included from here +//
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 503122. PiotrZSL added a comment. Ready for review, added new check option. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-e.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,58 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* \ +// RUN: -config="{CheckOptions: [{key: misc-header-include-cycle.IgnoredFilesList, value: 'header-include-cycle.self-e.hpp'}]}" \ +// RUN: -- -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note: 'header-include-cycle.second.hpp' included from here +//
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL planned changes to this revision. PiotrZSL added a comment. Option need to be added Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL added a comment. TODO: Add option: ExcludeHeadersRegexp Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL updated this revision to Diff 502464. PiotrZSL added a comment. Added support for --include Added support for self-include of source file Added more tests Reworked include stack. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.h clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.first.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.fourth.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.second.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-i.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-n.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self-o.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.self.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third-d.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/header-include-cycle.third.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.first-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.fourth-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.second-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.self-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/system/header-include-cycle.third-s.hpp clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp === --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp @@ -0,0 +1,54 @@ +// RUN: rm -rf %T/misc-header-include-cycle-headers +// RUN: mkdir %T/misc-header-include-cycle-headers +// RUN: cp -r %S/Inputs/header-include-cycle* %T/misc-header-include-cycle-headers/ +// RUN: mkdir %T/misc-header-include-cycle-headers/system +// RUN: cp -r %S/Inputs/system/header-include-cycle* %T/misc-header-include-cycle-headers/system +// RUN: clang-tidy %s -checks='-*,misc-header-include-cycle' -header-filter=.* -- \ +// RUN: -I%T/misc-header-include-cycle-headers -isystem %T/misc-header-include-cycle-headers/system \ +// RUN: --include %T/misc-header-include-cycle-headers/header-include-cycle.self-i.hpp | FileCheck %s \ +// RUN: -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error|note}}:" +// RUN: rm -rf %T/misc-header-include-cycle-headers + +#ifndef MAIN_GUARD +#define MAIN_GUARD + +#include +// CHECK-MESSAGES: header-include-cycle.fourth-d.hpp:3:10: warning: circular header file dependency detected while including 'header-include-cycle.first-d.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third-d.hpp:3:10: note: 'header-include-cycle.fourth-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second-d.hpp:3:10: note: 'header-include-cycle.third-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first-d.hpp:3:10: note: 'header-include-cycle.second-d.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first-d.hpp' included from here + +#include +// CHECK-MESSAGES: header-include-cycle.fourth.hpp:2:10: warning: circular header file dependency detected while including 'header-include-cycle.first.hpp', please check the include path [misc-header-include-cycle] +// CHECK-MESSAGES: header-include-cycle.third.hpp:2:10: note: 'header-include-cycle.fourth.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.second.hpp:2:10: note: 'header-include-cycle.third.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.first.hpp:2:10: note: 'header-include-cycle.second.hpp' included from here +// CHECK-MESSAGES: header-include-cycle.cpp:[[@LINE-5]]:10: note: 'header-include-cycle.first.hpp' included from here + +#include +// CHECK-MESSAGES:
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL marked 4 inline comments as done. PiotrZSL added a comment. "But maybe when we emit a warning for a specified include, we could put it in a set to not warn on that include again" I don't think so, in such case we hide include paths, and most of the time header guards should help here in reduction of cyclic dependences. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:106-110 +if (History.size() == 2U) { + Check.diag(Loc, "direct self-inclusion of header file '%0'") + << History.back(); + return; +} njames93 wrote: > How does this handle this case where an include includes a file that self > includes itself. > ```lang=c++ > // Foo.hpp > #pragma once > #include "Foo.hpp" > > // Bar.hpp > #pragma once > #include Foo.hpp > > // Main.cpp > #include "Bar.hpp" > ``` > Where will the warning be emitted, it should appear in `Foo.hpp` but the > logic here says it won't and would just be reported as a circular dependency > below. > Can you make sure the warning is emitted in `Foo.hpp` and add test cases that > test for this, The current tests just check include a file that self > references itself with no intermediate files. > > in theory it should raise an issue for self-include here.. and issue should be raised in Foo.hpp, can add check for this... Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:112-122 +std::string IncludePath; +for (const llvm::StringRef : History) { + IncludePath += '\''; + IncludePath += Name; + IncludePath += "' -> "; +} + njames93 wrote: > Rather than just printing out the include path, can you emit each include > location as a note. > `OtherInclude.h:5:1: note: 'ThisInclude.h' included here` > You can pass `DiagnosticLevel::Note` as the 3rd parameter to `Check::diag` to > emit a note. Just have to make sure you emit the note after you emit the > warning. > > Notes have better support for front end diagnostics parsing. yes I wanted to do that, but at the point of FileChanged, where I fill up stack, i don't have an proper info where such file wre included. It's possible, would need just to somehow connect info from InclusionDirective, assuming that when we got include, we go in such file, then probably keeping last processed include should be sufficient... Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:134 +private: + SmallVector Files; + HeaderIncludeCycleCheck njames93 wrote: > 1024 entries is pushing the boat out for a small vector. Thats just 4KB of memory pre-allocated to avoid re-allocations. Small is "muten" here. Comment at: clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst:63 + +**Catch header cycles before they catch you - Try this Clang-tidy check today!** njames93 wrote: > This tag line is just unnecessary maybe it is unnecessary, but I just wanted to put some advertisement slogan for a check ... Doesn't need to be bold... But it's is catchy... Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
njames93 added a comment. This is a great check that I've been meaning to work on for ages but never had time. It mostly looks good but there are a few issues I feel there is another issue that this can be very spammy with diagnostics(though clang-tidy is likely suppressing the duplicated ones). But maybe when we emit a warning for a specified include, we could put it in a set to not warn on that include again Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:106-110 +if (History.size() == 2U) { + Check.diag(Loc, "direct self-inclusion of header file '%0'") + << History.back(); + return; +} How does this handle this case where an include includes a file that self includes itself. ```lang=c++ // Foo.hpp #pragma once #include "Foo.hpp" // Bar.hpp #pragma once #include Foo.hpp // Main.cpp #include "Bar.hpp" ``` Where will the warning be emitted, it should appear in `Foo.hpp` but the logic here says it won't and would just be reported as a circular dependency below. Can you make sure the warning is emitted in `Foo.hpp` and add test cases that test for this, The current tests just check include a file that self references itself with no intermediate files. Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:112-122 +std::string IncludePath; +for (const llvm::StringRef : History) { + IncludePath += '\''; + IncludePath += Name; + IncludePath += "' -> "; +} + Rather than just printing out the include path, can you emit each include location as a note. `OtherInclude.h:5:1: note: 'ThisInclude.h' included here` You can pass `DiagnosticLevel::Note` as the 3rd parameter to `Check::diag` to emit a note. Just have to make sure you emit the note after you emit the warning. Notes have better support for front end diagnostics parsing. Comment at: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp:134 +private: + SmallVector Files; + HeaderIncludeCycleCheck 1024 entries is pushing the boat out for a small vector. Comment at: clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst:63 + +**Catch header cycles before they catch you - Try this Clang-tidy check today!** This tag line is just unnecessary Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144828/new/ https://reviews.llvm.org/D144828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144828: [clang-tidy] Add misc-header-include-cycle check
PiotrZSL created this revision. Herald added subscribers: carlosgalvezp, xazax.hun. Herald added a reviewer: njames93. Herald added a project: All. PiotrZSL updated this revision to Diff 500591. PiotrZSL added a comment. Eugene.Zelenko added reviewers: aaron.ballman, carlosgalvezp. Eugene.Zelenko added a project: clang-tools-extra. PiotrZSL updated this revision to Diff 501040. PiotrZSL published this revision for review. Herald added a subscriber: cfe-commits. Typo fix. PiotrZSL added a comment. Fixes PiotrZSL added a comment. Findings on llvm: clang-tools-extra/unittests/clang-doc/ClangDocTest.h:12:10: warning: direct self-inclusion of header file 'ClangDocTest.h' [misc-header-include-cycle] libc/src/__support/FPUtil/x86_64/LongDoubleBits.h:21:10: warning: circular header file dependency detected while including 'FPBits.h', please check the include path: 'FPBits.h' -> 'LongDoubleBits.h' -> 'FPBits.h' [misc-header-include-cycle] lldb/include/lldb/API/SBAddress.h:13:10: warning: circular header file dependency detected while including 'SBModule.h', please check the include path: 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBBlock.h' -> 'SBTarget.h' -> 'SBAddress.h' -> 'SBModule.h' [misc-header-include-cycle] lldb/include/lldb/API/SBBlock.h:14:10: warning: circular header file dependency detected while including 'SBTarget.h', please check the include path: 'SBTarget.h' -> 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBBlock.h' -> 'SBTarget.h' [misc-header-include-cycle] lldb/include/lldb/API/SBFunction.h:12:10: warning: circular header file dependency detected while including 'SBAddress.h', please check the include path: 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBFunction.h' -> 'SBAddress.h' [misc-header-include-cycle] lldb/include/lldb/API/SBLineEntry.h:12:10: warning: circular header file dependency detected while including 'SBAddress.h', please check the include path: 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBLineEntry.h' -> 'SBAddress.h' [misc-header-include-cycle] lldb/include/lldb/API/SBModule.h:15:10: warning: circular header file dependency detected while including 'SBSymbolContext.h', please check the include path: 'SBSymbolContext.h' -> 'SBBlock.h' -> 'SBTarget.h' -> 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' [misc-header-include-cycle] lldb/include/lldb/API/SBSymbol.h:12:10: warning: circular header file dependency detected while including 'SBAddress.h', please check the include path: 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBSymbol.h' -> 'SBAddress.h' [misc-header-include-cycle] lldb/include/lldb/API/SBSymbol.h:15:10: warning: circular header file dependency detected while including 'SBTarget.h', please check the include path: 'SBTarget.h' -> 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBSymbol.h' -> 'SBTarget.h' [misc-header-include-cycle] lldb/include/lldb/API/SBSymbolContext.h:12:10: warning: circular header file dependency detected while including 'SBBlock.h', please check the include path: 'SBBlock.h' -> 'SBTarget.h' -> 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBBlock.h' [misc-header-include-cycle] lldb/include/lldb/API/SBSymbolContext.h:15:10: warning: circular header file dependency detected while including 'SBFunction.h', please check the include path: 'SBFunction.h' -> 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBFunction.h' [misc-header-include-cycle] lldb/include/lldb/API/SBSymbolContext.h:16:10: warning: circular header file dependency detected while including 'SBLineEntry.h', please check the include path: 'SBLineEntry.h' -> 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBLineEntry.h' [misc-header-include-cycle] lldb/include/lldb/API/SBSymbolContext.h:17:10: warning: circular header file dependency detected while including 'SBModule.h', please check the include path: 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBModule.h' [misc-header-include-cycle] lldb/include/lldb/API/SBSymbolContext.h:18:10: warning: circular header file dependency detected while including 'SBSymbol.h', please check the include path: 'SBSymbol.h' -> 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBSymbol.h' [misc-header-include-cycle] lldb/include/lldb/API/SBSymbolContextList.h:13:10: warning: circular header file dependency detected while including 'SBSymbolContext.h', please check the include path: 'SBSymbolContext.h' -> 'SBBlock.h' -> 'SBTarget.h' -> 'SBSymbolContextList.h' -> 'SBSymbolContext.h' [misc-header-include-cycle] lldb/include/lldb/API/SBTarget.h:12:10: warning: circular header file dependency detected while including 'SBAddress.h', please check the include path: 'SBAddress.h' -> 'SBModule.h' -> 'SBSymbolContext.h' -> 'SBBlock.h' -> 'SBTarget.h' -> 'SBAddress.h' [misc-header-include-cycle] lldb/include/lldb/API/SBTarget.h:20:10: warning: circular header file dependency detected while