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 --
Maybe put this statement in front of if (Prev->getLocation() == D->getLocation())?