llvm-project/clang/lib/Format
Kevin Cadieux a9bef0707d [clang-format] Fix incorrect isspace input (NFC)
This change fixes a clang-format unit test failure introduced by [D124748](https://reviews.llvm.org/D124748). The `countLeadingWhitespace` function was calling `isspace` with values that could fall outside the valid input range. The valid input range for `isspace` is unsigned 0-255. Values outside this range produce undefined behavior, which on Windows manifests as an assertion being raised in the debug runtime libraries. `countLeadingWhitespace` was calling `isspace` with a signed char that could produce a negative value if the underlying byte's value was 128 or above, which can happen for non-ASCII encodings. The fix is to use `StringRef`'s `bytes_begin` and `bytes_end` iterators to read the values as unsigned chars instead.

This bug can be reproduced by building the `check-clang-unit` target with a DEBUG configuration under Windows. This change is already covered by existing unit tests.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D128786
2022-06-29 10:20:46 -07:00
..
AffectedRangeManager.cpp [clang-format][NFC] Insert/remove braces in clang/lib/Format/ 2022-05-24 19:06:04 -07:00
AffectedRangeManager.h
BreakableToken.cpp [clang-format][NFC] Format lib/Format and unittests/Format in clang 2022-06-09 02:25:06 -07:00
BreakableToken.h [clang-format] Add option to control the spaces in a line comment 2021-02-01 22:48:50 +01:00
CMakeLists.txt [clang-format] Style to separate definition blocks 2022-01-03 15:47:39 -05:00
ContinuationIndenter.cpp [clang-format][NFC] Insert/remove braces in clang/lib/Format/ 2022-05-24 19:06:04 -07:00
ContinuationIndenter.h [Format] Remove unused LineContainsContinuedForLoopSection. NFC 2022-02-22 09:59:02 +01:00
DefinitionBlockSeparator.cpp [clang-format][NFC] Insert/remove braces in clang/lib/Format/ 2022-05-24 19:06:04 -07:00
DefinitionBlockSeparator.h [clang-format] Fix SeparateDefinitionBlocks issues 2022-01-24 14:23:20 +00:00
Encoding.h
Format.cpp [clang-format] Parse Verilog if statements 2022-06-26 01:52:15 +00:00
FormatInternal.h Move clang/Tooling/Core/Lookup.h to clang/Tooling/Refactoring/Lookup.h 2020-10-20 10:13:28 +01:00
FormatToken.cpp [clang-format][NFC] Insert/remove braces in clang/lib/Format/ 2022-05-24 19:06:04 -07:00
FormatToken.h [clang-format] Handle Verilog preprocessor directives 2022-06-26 02:02:29 +00:00
FormatTokenLexer.cpp [clang-format] Fix incorrect isspace input (NFC) 2022-06-29 10:20:46 -07:00
FormatTokenLexer.h [clang-format] Handle Verilog preprocessor directives 2022-06-26 02:02:29 +00:00
MacroExpander.cpp [clang-format] Elide unnecessary braces. NFC. 2022-02-02 14:36:01 +01:00
Macros.h [llvm][clang][NFC] updates inline licence info 2021-08-11 02:48:53 +00:00
NamespaceEndCommentsFixer.cpp [clang-format] Fix namespace format when the name is followed by a macro 2022-03-10 15:00:32 -08:00
NamespaceEndCommentsFixer.h
QualifierAlignmentFixer.cpp [clang-format] Fix QualifierAlignment with global namespace qualified types. 2022-05-26 15:02:33 +02:00
QualifierAlignmentFixer.h [clang-format] Fix a crash (assertion) in qualifier alignment when matching template closer is null 2022-01-06 19:40:39 +00:00
SortJavaScriptImports.cpp [clang-format][NFC] Insert/remove braces in clang/lib/Format/ 2022-05-24 19:06:04 -07:00
SortJavaScriptImports.h
TokenAnalyzer.cpp [clang-format] Reserve vectors when the number of items is known beforehand. NFC. 2022-02-03 10:38:23 +01:00
TokenAnalyzer.h Make clang-format fuzz through Lexing with asserts enabled. 2021-11-19 14:44:06 +01:00
TokenAnnotator.cpp [clang-format] Fix misplacement of `*` in declaration of pointer to struct 2022-06-29 15:21:02 +08:00
TokenAnnotator.h [clang-format][NFC] Make all TokenAnnotator member functions const 2022-05-06 14:46:32 -07:00
UnwrappedLineFormatter.cpp [clang-format] Quit analyzing solution space for large state count 2022-06-26 13:15:07 -07:00
UnwrappedLineFormatter.h [clang-format] Fix the issue that empty lines being removed at the beginning of namespace 2021-06-27 15:59:21 +01:00
UnwrappedLineParser.cpp [clang-format] Handle Verilog preprocessor directives 2022-06-26 02:02:29 +00:00
UnwrappedLineParser.h [clang-format] Remove braces of else blocks that embody an if block 2022-06-08 16:05:20 -07:00
UsingDeclarationsSorter.cpp [clang-format] Use ranged for loops. NFC. 2022-02-01 14:10:48 +01:00
UsingDeclarationsSorter.h
WhitespaceManager.cpp [clang-format][NFC] Format lib/Format and unittests/Format in clang 2022-06-09 02:25:06 -07:00
WhitespaceManager.h [clang-format] Minimize the damage caused by AlignArrayOfStructures when working on non square arrays 2022-03-12 17:22:31 +00:00