[llvm-bugs] [Bug 33734] New: TextDiagnostic.cpp buildFixItInsertionLine assertion check failure of HintByteOffset
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 10 12:18:33 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33734
Bug ID: 33734
Summary: TextDiagnostic.cpp buildFixItInsertionLine assertion
check failure of HintByteOffset
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: chh at google.com
CC: llvm-bugs at lists.llvm.org
Clang-tidy performance-unnecessary-value-param checks causes this assertion
failure in TextDiagnostic.cpp,
when a function's definition and declaration are at the same line of different
files,
and the declaration line is longer then the definition line.
If clang-tidy is built without assertion checks, it does not abort,
but the "displayed" suggested fix line is wrong.
The actual applied fix is correct.
The following test case is reduced from one Android source file.
Note that t.h declares f1 at line 5 and f2 at line 6.
t.cc defines f1 at line 3 and f2 at line 6.
Declaration lines of f1 and f2 in t.h are longer than
the header lines of f1 and f2 in t.cc.
$ cat t.h
struct ABC {
ABC(const ABC&);
int get(int) const;
};
int f1( int n, ABC v); // line 5
int f2( int n, ABC v); // line 6
$ cat t.cc
#include "t.h"
// line 2
int f1(int n, ABC v) {
return v.get(n);
}
int f2(int n, ABC v) {
return v.get(n);
}
============================================================
## Current output from clang-tidy release build, without
-DLLVM_ENABLE_ASSERTIONS
(clang-tidy did not abort, but suggested fix line for f2 is wrong)
clang_tidy -checks=*,-anal*,-cppcoreguide*,-llvm*,-hicpp* -header-filter=.*
/tmp/t.cc --
2 warnings generated.
/tmp/t.cc:3:19: warning: the parameter 'v' is copied for each invocation but
only used as a const reference; consider making it a const reference
[performance-unnecessary-value-param]
int f1(int n, ABC v) {
~~~ ^
/tmp/t.cc:6:19: warning: the parameter 'v' is copied for each invocation but
only used as a const reference; consider making it a const reference
[performance-unnecessary-value-param]
int f2(int n, ABC v) {
~~~ ^
const & const &
============================================================
## Current output from clang-tidy release build, with
-DLLVM_ENABLE_ASSERTIONS=On
(clang-tidy has assertion error)
.../llvm.307566/build/bin/clang-tidy
-checks=*,-anal*,-cppcoreguide*,-llvm*,-hicpp* -header-filter=.* /tmp/t.cc --
2 warnings generated.
/tmp/t.cc:3:19: warning: the parameter 'v' is copied for each invocation but
only used as a const reference; consider making it a const reference
[performance-unnecessary-value-param]
int f1(int n, ABC v) {
~~~ ^
/tmp/t.cc:6:19: warning: the parameter 'v' is copied for each invocation but
only used as a const reference; consider making it a const reference
[performance-unnecessary-value-param]
clang-tidy:
.../llvm.307566/llvm/tools/clang/lib/Frontend/TextDiagnostic.cpp:1083:
std::string buildFixItInsertionLine(unsigned int, const
{anonymous}::SourceColumnMap&, llvm::ArrayRef<clang::FixItHint>, const
clang::SourceManager&, const clang::DiagnosticOptions*): Assertion
`HintByteOffset < static_cast<unsigned>(map.bytes())+1' failed.
Aborted (core dumped)
============================================================
## Expected output:
.../llvm.FID/build/bin/clang-tidy
-checks=*,-anal*,-cppcoreguide*,-llvm*,-hicpp* -header-filter=.* /tmp/t.cc --
2 warnings generated.
/tmp/t.cc:3:19: warning: the parameter 'v' is copied for each invocation but
only used as a const reference; consider making it a const reference
[performance-unnecessary-value-param]
int f1(int n, ABC v) {
~~~ ^
const &
/tmp/t.cc:6:19: warning: the parameter 'v' is copied for each invocation but
only used as a const reference; consider making it a const reference
[performance-unnecessary-value-param]
int f2(int n, ABC v) {
~~~ ^
const &
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170710/7fbeeab9/attachment.html>
More information about the llvm-bugs
mailing list