This is an archive of the discontinued LLVM Phabricator instance.

readability-redundant-declarations: Fix crash
ClosedPublic

Authored by danielmarjamaki on Nov 21 2016, 5:27 AM.

Details

Summary

This patch fixes a crash reported by Miklos Vajna

The testcase output without the fix:

******************** TEST 'Clang Tools :: clang-tidy/readability-redundant-declaration.cpp' FAILED ********************
Script:
--
/usr/bin/python2.7 /home/danielm/llvm/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py /home/danielm/llvm/tools/clang/tools/extra/test/clang-tidy/readability-redundant-declaration.cpp readability-redundant-declaration /home/danielm/llvm/build/tools/clang/tools/extra/test/clang-tidy/Output/readability-redundant-declaration.cpp.tmp
--
Exit Code: 1

Command Output (stdout):
--
Running ['clang-tidy', '/home/danielm/llvm/build/tools/clang/tools/extra/test/clang-tidy/Output/readability-redundant-declaration.cpp.tmp.cpp', '-fix', '--checks=-*,readability-redundant-declaration', '--', '--std=c++11']...
clang-tidy failed:
clang-tidy: /home/danielm/llvm/tools/clang/tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:183: clang::DiagnosticBuilder clang::tidy::ClangTidyContext::diag(llvm::StringRef, clang::SourceLocation, llvm::StringRef, clang::DiagnosticIDs::Level): Assertion `Loc.isValid()' failed.


--
Command Output (stderr):
--
Traceback (most recent call last):
  File "/home/danielm/llvm/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py", line 135, in <module>
    main()
  File "/home/danielm/llvm/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py", line 91, in main
    subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['clang-tidy', '/home/danielm/llvm/build/tools/clang/tools/extra/test/clang-tidy/Output/readability-redundant-declaration.cpp.tmp.cpp', '-fix', '--checks=-*,readability-redundant-declaration', '--', '--std=c++11']' returned non-zero exit status -6

--

Diff Detail

Repository
rL LLVM

Event Timeline

danielmarjamaki retitled this revision from to readability-redundant-declarations: Fix crash.
danielmarjamaki updated this object.
danielmarjamaki added a reviewer: alexfh.
danielmarjamaki set the repository for this revision to rL LLVM.
danielmarjamaki updated this object.
danielmarjamaki added a subscriber: vmiklos.
hokein accepted this revision.Nov 21 2016, 6:32 AM
hokein added a reviewer: hokein.
hokein added a subscriber: hokein.

LGTM with a nit.

clang-tidy/readability/RedundantDeclarationCheck.cpp
33 ↗(On Diff #78706)

Maybe put this statement in front of if (Prev->getLocation() == D->getLocation())?

This revision is now accepted and ready to land.Nov 21 2016, 6:32 AM
This revision was automatically updated to reflect the committed changes.