[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
This revision was automatically updated to reflect the committed changes. Closed by commit rL339437: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix (authored by lebedevri, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D36892?vs=160107=160108#toc Repository: rL LLVM https://reviews.llvm.org/D36892 Files: clang-tools-extra/trunk/docs/clang-tidy/index.rst clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp Index: clang-tools-extra/trunk/docs/clang-tidy/index.rst === --- clang-tools-extra/trunk/docs/clang-tidy/index.rst +++ clang-tools-extra/trunk/docs/clang-tidy/index.rst @@ -650,7 +650,8 @@ An additional check enabled by ``check_clang_tidy.py`` ensures that if `CHECK-MESSAGES:` is used in a file then every warning or error -must have an associated CHECK in that file. +must have an associated CHECK in that file. Or, you can use ``CHECK-NOTES:`` +instead, if you want to **also** ensure that all the notes are checked. To use the ``check_clang_tidy.py`` script, put a .cpp file with the appropriate ``RUN`` line in the ``test/clang-tidy`` directory. Use Index: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py === --- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py +++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py @@ -78,6 +78,7 @@ file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else '' check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix + check_notes_prefix = 'CHECK-NOTES' + file_check_suffix # Tests should not rely on STL being available, and instead provide mock # implementations of relevant APIs. @@ -91,9 +92,11 @@ has_check_fixes = check_fixes_prefix in input_text has_check_messages = check_messages_prefix in input_text + has_check_notes = check_notes_prefix in input_text - if not has_check_fixes and not has_check_messages: -sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) ) + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('%s, %s or %s not found in the input' % (check_fixes_prefix, + check_messages_prefix, check_notes_prefix) ) # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -156,5 +159,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +notes_file = temp_file_name + '.notes' +write_file(notes_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + notes_file, input_file_name, + '-check-prefix=' + check_notes_prefix, + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() Index: clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp === --- clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp @@ -20,28 +20,28 @@ void problematic() { try { throw int(42); -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' } catch (int e) { } throw int(42); - // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception' + // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception' try { throw 12; -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' } catch (...) { throw; // Ok, even if the type is not known, conforming code can never rethrow a non-std::exception object. } try { throw non_derived_exception(); -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 9:1: note: type defined here +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' +//
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
JonasToth added a comment. LGTM Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri updated this revision to Diff 160107. lebedev.ri added a comment. Add docs note. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 Files: docs/clang-tidy/index.rst test/clang-tidy/check_clang_tidy.py test/clang-tidy/hicpp-exception-baseclass.cpp Index: test/clang-tidy/hicpp-exception-baseclass.cpp === --- test/clang-tidy/hicpp-exception-baseclass.cpp +++ test/clang-tidy/hicpp-exception-baseclass.cpp @@ -20,28 +20,28 @@ void problematic() { try { throw int(42); -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' } catch (int e) { } throw int(42); - // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception' + // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception' try { throw 12; -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' } catch (...) { throw; // Ok, even if the type is not known, conforming code can never rethrow a non-std::exception object. } try { throw non_derived_exception(); -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 9:1: note: type defined here +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' +// CHECK-NOTES: 9:1: note: type defined here } catch (non_derived_exception ) { } throw non_derived_exception(); - // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' - // CHECK-MESSAGES: 9:1: note: type defined here + // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' + // CHECK-NOTES: 9:1: note: type defined here // FIXME: More complicated kinds of inheritance should be checked later, but there is // currently no way use ASTMatchers for this kind of task. @@ -100,15 +100,15 @@ // Templated function that throws exception based on template type template void ThrowException() { throw T(); } -// CHECK-MESSAGES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 120:1: note: type defined here -// CHECK-MESSAGES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 120:1: note: type defined here -// CHECK-MESSAGES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 123:1: note: type defined here -// CHECK-MESSAGES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception' -// CHECK-MESSAGES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 9:1: note: type defined here +// CHECK-NOTES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' +// CHECK-NOTES: 120:1: note: type defined here +// CHECK-NOTES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' +// CHECK-NOTES: 120:1: note: type defined here +// CHECK-NOTES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception' +// CHECK-NOTES: 123:1: note: type defined here +// CHECK-NOTES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception' +// CHECK-NOTES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' +// CHECK-NOTES: 9:1: note: type defined here #define THROW_EXCEPTION(CLASS) ThrowException() #define THROW_BAD_EXCEPTION throw int(42); #define THROW_GOOD_EXCEPTION throw std::exception(); @@ -134,25 +134,28 @@ THROW_EXCEPTION(deep_hierarchy);// Ok THROW_BAD_EXCEPTION; - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception' - // CHECK-MESSAGES: [[@LINE-25]]:35: note: expanded from macro 'THROW_BAD_EXCEPTION' + // CHECK-NOTES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception' + //
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri updated this revision to Diff 160106. lebedev.ri added a comment. Rebase (ugh, bitrot), port `test/clang-tidy/hicpp-exception-baseclass.cpp`. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 Files: test/clang-tidy/check_clang_tidy.py test/clang-tidy/hicpp-exception-baseclass.cpp Index: test/clang-tidy/hicpp-exception-baseclass.cpp === --- test/clang-tidy/hicpp-exception-baseclass.cpp +++ test/clang-tidy/hicpp-exception-baseclass.cpp @@ -20,28 +20,28 @@ void problematic() { try { throw int(42); -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' } catch (int e) { } throw int(42); - // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception' + // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception' try { throw 12; -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' } catch (...) { throw; // Ok, even if the type is not known, conforming code can never rethrow a non-std::exception object. } try { throw non_derived_exception(); -// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 9:1: note: type defined here +// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' +// CHECK-NOTES: 9:1: note: type defined here } catch (non_derived_exception ) { } throw non_derived_exception(); - // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' - // CHECK-MESSAGES: 9:1: note: type defined here + // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' + // CHECK-NOTES: 9:1: note: type defined here // FIXME: More complicated kinds of inheritance should be checked later, but there is // currently no way use ASTMatchers for this kind of task. @@ -100,15 +100,15 @@ // Templated function that throws exception based on template type template void ThrowException() { throw T(); } -// CHECK-MESSAGES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 120:1: note: type defined here -// CHECK-MESSAGES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 120:1: note: type defined here -// CHECK-MESSAGES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 123:1: note: type defined here -// CHECK-MESSAGES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception' -// CHECK-MESSAGES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' -// CHECK-MESSAGES: 9:1: note: type defined here +// CHECK-NOTES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' +// CHECK-NOTES: 120:1: note: type defined here +// CHECK-NOTES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' +// CHECK-NOTES: 120:1: note: type defined here +// CHECK-NOTES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception' +// CHECK-NOTES: 123:1: note: type defined here +// CHECK-NOTES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception' +// CHECK-NOTES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' +// CHECK-NOTES: 9:1: note: type defined here #define THROW_EXCEPTION(CLASS) ThrowException() #define THROW_BAD_EXCEPTION throw int(42); #define THROW_GOOD_EXCEPTION throw std::exception(); @@ -134,25 +134,28 @@ THROW_EXCEPTION(deep_hierarchy);// Ok THROW_BAD_EXCEPTION; - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception' - // CHECK-MESSAGES: [[@LINE-25]]:35: note: expanded from macro 'THROW_BAD_EXCEPTION' + // CHECK-NOTES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. In https://reviews.llvm.org/D36892#1187959, @JonasToth wrote: > @lebedev.ri and @alexfh i would change the tests in > https://reviews.llvm.org/D48714 to use CHECK-NOTES. Is it ok, to commit this > one? > > For testing purposes, you could change a single line of > `hicpp-exception-baseclass.cpp` to use the CHECK-NOTES. I do the rest :) SGTM Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
JonasToth added a comment. @lebedev.ri and @alexfh i would change the tests in https://reviews.llvm.org/D48714 to use CHECK-NOTES. Is it ok, to commit this one? For testing purposes, you could change a single line of `hicpp-exception-baseclass.cpp` to use the CHECK-NOTES. I do the rest :) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. As per the previous comment: I have no concerns as long as the documentation is updated and at least one existing test is changed to use this feature (see the list in the previous comment). Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri updated this revision to Diff 154490. lebedev.ri added a comment. Rebased, just to control bitrot, no changes. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 Files: test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -78,6 +78,7 @@ file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else '' check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix + check_notes_prefix = 'CHECK-NOTES' + file_check_suffix # Tests should not rely on STL being available, and instead provide mock # implementations of relevant APIs. @@ -91,9 +92,10 @@ has_check_fixes = check_fixes_prefix in input_text has_check_messages = check_messages_prefix in input_text + has_check_notes = check_notes_prefix in input_text if not has_check_fixes and not has_check_messages: -sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) ) +sys.exit('None of %s, %s or %s found in the input' % (check_fixes_prefix, check_messages_prefix, check_notes_prefix) ) # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -156,5 +158,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=' + check_notes_prefix, + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -78,6 +78,7 @@ file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else '' check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix + check_notes_prefix = 'CHECK-NOTES' + file_check_suffix # Tests should not rely on STL being available, and instead provide mock # implementations of relevant APIs. @@ -91,9 +92,10 @@ has_check_fixes = check_fixes_prefix in input_text has_check_messages = check_messages_prefix in input_text + has_check_notes = check_notes_prefix in input_text if not has_check_fixes and not has_check_messages: -sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) ) +sys.exit('None of %s, %s or %s found in the input' % (check_fixes_prefix, check_messages_prefix, check_notes_prefix) ) # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -156,5 +158,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=' + check_notes_prefix, + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
alexfh added a comment. It looks like some existing tests could benefit from this: $ grep -R -l 'note: ' test/clang-tidy/ test/clang-tidy/bugprone-forward-declaration-namespace.cpp test/clang-tidy/llvm-twine-local.cpp test/clang-tidy/overlapping.cpp test/clang-tidy/google-readability-nested-namespace-comments.cpp test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp test/clang-tidy/cert-static-object-exception.cpp test/clang-tidy/fix.cpp test/clang-tidy/google-readability-namespace-comments.cpp test/clang-tidy/cppcoreguidelines-avoid-goto.cpp test/clang-tidy/performance-move-constructor-init.cpp test/clang-tidy/fuchsia-default-arguments.cpp test/clang-tidy/readability-misleading-indentation.cpp test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp test/clang-tidy/fix-errors.cpp test/clang-tidy/bugprone-use-after-move.cpp test/clang-tidy/cppcoreguidelines-owning-memory-containers.cpp test/clang-tidy/bugprone-argument-comment.cpp test/clang-tidy/cppcoreguidelines-owning-memory.cpp test/clang-tidy/readability-function-size.cpp test/clang-tidy/hicpp-exception-baseclass.cpp test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp test/clang-tidy/macros.cpp test/clang-tidy/readability-container-size-empty.cpp test/clang-tidy/Inputs/overlapping/o.h test/clang-tidy/bugprone-forwarding-reference-overload.cpp If you're interested in changing some of these tests to use CHECK-NOTES, there's no need to wait for a resolution on https://reviews.llvm.org/D36836 (which, unfortunately, may take really long). However, please update the relevant section of docs/clang-tidy/index.rst. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
aaron.ballman added a comment. In https://reviews.llvm.org/D36892#953953, @lebedev.ri wrote: > In https://reviews.llvm.org/D36892#953891, @aaron.ballman wrote: > > > I think you're set to commit this > > > Should i commit it though? > Until licensing concerns with https://reviews.llvm.org/D36836 are finally > magically resolved and it is committed, there won't be any users, and since > there is no tests for this, that would be a dead code with all the > consequences. Hmm, I thought we had other tests that could make use of this functionality? However, I might be misremembering. Hold off on committing until there's test coverage, but it'd be good to look at existing tests to see if any of them can be modified. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri added a comment. In https://reviews.llvm.org/D36892#953891, @aaron.ballman wrote: > I think you're set to commit this Should i commit it though? Until licensing concerns with https://reviews.llvm.org/D36836 are finally magically resolved and it is committed, there won't be any users, and since there is no tests for this, that would be a dead code with all the consequences. > - if @alexfh has concerns, they can be addressed post-commit. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
aaron.ballman added a comment. I think you're set to commit this -- if @alexfh has concerns, they can be addressed post-commit. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri updated this revision to Diff 126681. lebedev.ri changed the repository for this revision from rL LLVM to rCTE Clang Tools Extra. lebedev.ri added a comment. Rebased. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 Files: test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -80,9 +80,11 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('CHECK-FIXES, CHECK-MESSAGES, or CHECK-NOTES not found in the ' + 'input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -143,5 +145,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -80,9 +80,11 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('CHECK-FIXES, CHECK-MESSAGES, or CHECK-NOTES not found in the ' + 'input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -143,5 +145,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri added a comment. @alexfh any thoughts on this one? Repository: rL LLVM https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. I am okay with this direction but would still like @alexfh to accept before you commit. Repository: rL LLVM https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri updated this revision to Diff 119758. lebedev.ri added a comment. Rebased. Repository: rL LLVM https://reviews.llvm.org/D36892 Files: test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -80,9 +80,11 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('CHECK-FIXES, CHECK-MESSAGES, or CHECK-NOTES not found in the ' + 'input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -143,5 +145,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -80,9 +80,11 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('CHECK-FIXES, CHECK-MESSAGES, or CHECK-NOTES not found in the ' + 'input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -143,5 +145,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri updated this revision to Diff 113254. lebedev.ri marked an inline comment as done. lebedev.ri added a comment. Reword the 'no magic found' error message. Repository: rL LLVM https://reviews.llvm.org/D36892 Files: test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -73,21 +73,23 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('CHECK-FIXES, CHECK-MESSAGES, or CHECK-NOTES not found in the ' + 'input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while # avoiding empty lines which could potentially trigger formatting-related # checks. cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text) write_file(temp_file_name, cleaned_test) original_file_name = temp_file_name + ".orig" write_file(original_file_name, cleaned_test) args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \ clang_tidy_extra_args print('Running ' + repr(args) + '...') @@ -136,5 +138,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -73,21 +73,23 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('CHECK-FIXES, CHECK-MESSAGES, or CHECK-NOTES not found in the ' + 'input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while # avoiding empty lines which could potentially trigger formatting-related # checks. cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text) write_file(temp_file_name, cleaned_test) original_file_name = temp_file_name + ".orig" write_file(original_file_name, cleaned_test) args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \ clang_tidy_extra_args print('Running ' + repr(args) + '...') @@ -136,5 +138,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
aaron.ballman added a comment. > I do agree that it makes sense to keep it as low as possible, but also i see > a clear logic between all thee current checks: Thank you for the explanation. I think that makes sense to me, but I'd like to hear from @alexfh before accepting. Comment at: test/clang-tidy/check_clang_tidy.py:79-80 except subprocess.CalledProcessError as e: print('clang-tidy failed:\n' + e.output.decode()) raise print(' clang-tidy output ---\n' + I think the text should be rephrased to "CHECK-FIXES, CHECK-MESSAGES, or CHECK-NOTES not found in the input" Repository: rL LLVM https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
JonasToth added a comment. alright. i thought it would do something different, but the enforcement to handle all notes is a good thing. forget what i wrote :) Repository: rL LLVM https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri added a comment. In https://reviews.llvm.org/D36892#856501, @JonasToth wrote: > Note can be handled right now as well. Yes. Adding this new prefix is about adding `-implicit-check-not=notes`. I.e. if you use `CHECK-MESSAGES`, then it will only enforce you to have check-lines for all the `error: ` and `warning: ` the check outputs. It does *not* enforce that all the `note: ` are to be handled. `CHECK-NOTES` however would enforce that. > E.g. > > // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an > owner > > would the patch handle the codelocation correctly? I'm not sure what is the question to be honest. This does not change anything about codelocation handling Repository: rL LLVM https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri added a comment. In https://reviews.llvm.org/D36892#856469, @aaron.ballman wrote: > Instead of CHECK-NOTES, do we want to extend CHECK-MESSAGES to handle `note` > in addition to `warning` and `error`? If i change `CHECK-MESSAGES` to also require all the notes to be checked, a *lot* of tests fail: Testing Time: 4.04s Failing Tests (165): Clang Tools :: clang-tidy/android-cloexec-accept.cpp Clang Tools :: clang-tidy/android-cloexec-accept4.cpp Clang Tools :: clang-tidy/android-cloexec-creat.cpp Clang Tools :: clang-tidy/android-cloexec-dup.cpp Clang Tools :: clang-tidy/android-cloexec-epoll-create.cpp Clang Tools :: clang-tidy/android-cloexec-epoll-create1.cpp Clang Tools :: clang-tidy/android-cloexec-fopen.cpp Clang Tools :: clang-tidy/android-cloexec-inotify-init.cpp Clang Tools :: clang-tidy/android-cloexec-inotify-init1.cpp Clang Tools :: clang-tidy/android-cloexec-memfd-create.cpp Clang Tools :: clang-tidy/android-cloexec-open.cpp Clang Tools :: clang-tidy/android-cloexec-socket.cpp Clang Tools :: clang-tidy/boost-use-to-string.cpp Clang Tools :: clang-tidy/bugprone-integer-division.cpp Clang Tools :: clang-tidy/bugprone-suspicious-memset-usage.cpp Clang Tools :: clang-tidy/bugprone-undefined-memory-manipulation.cpp Clang Tools :: clang-tidy/cert-dcl21-cpp.cpp Clang Tools :: clang-tidy/cert-oop11-cpp.cpp Clang Tools :: clang-tidy/clean-up-code.cpp Clang Tools :: clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp Clang Tools :: clang-tidy/cppcoreguidelines-pro-type-cstyle-cast.cpp Clang Tools :: clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp Clang Tools :: clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp Clang Tools :: clang-tidy/cppcoreguidelines-pro-type-member-init.cpp Clang Tools :: clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp Clang Tools :: clang-tidy/cppcoreguidelines-pro-type-vararg.cpp Clang Tools :: clang-tidy/deduplication.cpp Clang Tools :: clang-tidy/google-build-explicit-make-pair.cpp Clang Tools :: clang-tidy/google-explicit-constructor.cpp Clang Tools :: clang-tidy/google-readability-casting.c Clang Tools :: clang-tidy/google-readability-casting.cpp Clang Tools :: clang-tidy/google-readability-namespace-comments.cpp Clang Tools :: clang-tidy/google-readability-todo.cpp Clang Tools :: clang-tidy/llvm-include-order.cpp Clang Tools :: clang-tidy/llvm-twine-local.cpp Clang Tools :: clang-tidy/misc-argument-comment-gmock.cpp Clang Tools :: clang-tidy/misc-argument-comment-strict.cpp Clang Tools :: clang-tidy/misc-argument-comment.cpp Clang Tools :: clang-tidy/misc-assert-side-effect.cpp Clang Tools :: clang-tidy/misc-bool-pointer-implicit-conversion.cpp Clang Tools :: clang-tidy/misc-definitions-in-headers.hpp Clang Tools :: clang-tidy/misc-forwarding-reference-overload.cpp Clang Tools :: clang-tidy/misc-inaccurate-erase.cpp Clang Tools :: clang-tidy/misc-inefficient-algorithm.cpp Clang Tools :: clang-tidy/misc-lambda-function-name.cpp Clang Tools :: clang-tidy/misc-macro-parentheses.cpp Clang Tools :: clang-tidy/misc-macro-repeated-side-effects.c Clang Tools :: clang-tidy/misc-misplaced-const.c Clang Tools :: clang-tidy/misc-misplaced-const.cpp Clang Tools :: clang-tidy/misc-move-const-arg.cpp Clang Tools :: clang-tidy/misc-move-constructor-init.cpp Clang Tools :: clang-tidy/misc-move-forwarding-reference.cpp Clang Tools :: clang-tidy/misc-multiple-statement-macro.cpp Clang Tools :: clang-tidy/misc-static-assert.c Clang Tools :: clang-tidy/misc-static-assert.cpp Clang Tools :: clang-tidy/misc-string-compare.cpp Clang Tools :: clang-tidy/misc-string-constructor.cpp Clang Tools :: clang-tidy/misc-string-integer-assignment.cpp Clang Tools :: clang-tidy/misc-suspicious-semicolon.cpp Clang Tools :: clang-tidy/misc-suspicious-string-compare.c Clang Tools :: clang-tidy/misc-suspicious-string-compare.cpp Clang Tools :: clang-tidy/misc-swapped-arguments.cpp Clang Tools :: clang-tidy/misc-uniqueptr-reset-release.cpp Clang Tools :: clang-tidy/misc-unused-alias-decls.cpp Clang Tools :: clang-tidy/misc-unused-parameters.c Clang Tools :: clang-tidy/misc-unused-parameters.cpp Clang Tools :: clang-tidy/misc-unused-raii.cpp Clang Tools :: clang-tidy/misc-unused-using-decls.cpp Clang Tools :: clang-tidy/misc-virtual-near-miss.cpp Clang Tools :: clang-tidy/modernize-avoid-bind.cpp Clang Tools :: clang-tidy/modernize-deprecated-headers-cxx03.cpp Clang Tools :: clang-tidy/modernize-deprecated-headers-cxx11.cpp Clang Tools ::
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
JonasToth added a comment. Note can be handled right now as well. E.g. // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner would the patch handle the codelocation correctly? Repository: rL LLVM https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
aaron.ballman added a comment. Instead of CHECK-NOTES, do we want to extend CHECK-MESSAGES to handle `note` in addition to `warning` and `error`? I'd prefer to keep the number of "magic" names as low as possible so I have to remember less stuff when writing or reviewing tests. Repository: rL LLVM https://reviews.llvm.org/D36892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri updated this revision to Diff 113226. lebedev.ri added a comment. Rebased. Repository: rL LLVM https://reviews.llvm.org/D36892 Files: test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -73,21 +73,23 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES ' + 'nor CHECK-NOTES found in the input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while # avoiding empty lines which could potentially trigger formatting-related # checks. cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text) write_file(temp_file_name, cleaned_test) original_file_name = temp_file_name + ".orig" write_file(original_file_name, cleaned_test) args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \ clang_tidy_extra_args print('Running ' + repr(args) + '...') @@ -136,5 +138,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -73,21 +73,23 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES ' + 'nor CHECK-NOTES found in the input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while # avoiding empty lines which could potentially trigger formatting-related # checks. cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text) write_file(temp_file_name, cleaned_test) original_file_name = temp_file_name + ".orig" write_file(original_file_name, cleaned_test) args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \ clang_tidy_extra_args print('Running ' + repr(args) + '...') @@ -136,5 +138,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri created this revision. lebedev.ri added a project: clang-tools-extra. Herald added subscribers: xazax.hun, JDevlieghere. Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES` `CHECK-MESSAGES` checks that there are no test output lines with `warning:|error:`, which are not explicitly handled in lit tests. However there does not seem to be a nice way to enforce for all the `note:` to be checked. This was useful for me when developing https://reviews.llvm.org/D36836. Repository: rL LLVM https://reviews.llvm.org/D36892 Files: test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -73,9 +73,11 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES ' + 'nor CHECK-NOTES found in the input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -136,5 +138,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -73,9 +73,11 @@ has_check_fixes = input_text.find('CHECK-FIXES') >= 0 has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_notes = input_text.find('CHECK-NOTES') >= 0 - if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') + if not has_check_fixes and not has_check_messages and not has_check_notes: +sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES ' + 'nor CHECK-NOTES found in the input') # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -136,5 +138,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=CHECK-NOTES', + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits