Issue 126334
Summary In UnsafeBufferUsage.cpp is getEndCharLoc(...) missing an assertion
Labels clang
Assignees
Reporter shafik
    Static analysis points out that on this line:

https://github.com/llvm/llvm-project/blob/12a154a94a9c2f6f0690adc7302da9c9e47ec806/clang/lib/Analysis/UnsafeBufferUsage.cpp#L2348

`Lexer::MeasureTokenLength` can return `0` and on the subsequent line `TkLen - 1` will end up as max unsigned which does not look like the code would deal with that gracefully.

This was brought in via https://github.com/llvm/llvm-project/commit/63413015099bc8aaa45cba7551e8fe432b2b795f

It looks like the assumption is that this will never return zero, if that is the case there should be an assertion, something like `assert(TkLen !=0);` to document this invariant.

 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to