llvm-project/clang/unittests
Martin Probst b2780cd744 clang-format: [JS] handle "off" in imports
Previously, the JavaScript import sorter would ignore `// clang-format
off` and `on` comments. This change fixes that. It tracks whether
formatting is enabled for a stretch of imports, and then only sorts and
merges the imports where formatting is enabled, in individual chunks.

This means that there's no meaningful total order when module references are mixed
with blocks that have formatting disabled. The alternative approach
would have been to sort all imports that have formatting enabled in one
group. However that raises the question where to insert the
formatting-off block, which can also impact symbol visibility (in
particular for exports). In practice, sorting in chunks probably isn't a
big problem.

This change also simplifies the general algorithm: instead of tracking
indices separately and sorting them, it just sorts the vector of module
references. And instead of attempting to do fine grained tracking of
whether the code changed order, it just prints out the module references
text, and compares that to the previous text. Given that source files
typically have dozens, but not even hundreds of imports, the performance
impact seems negligible.

Differential Revision: https://reviews.llvm.org/D101515
2021-04-30 14:18:52 +02:00
..
AST [clang/Basic] Make TargetInfo.h not use DataLayout again 2021-04-27 22:26:10 -04:00
ASTMatchers [ASTMatchers] Add `cxxBaseSpecifier` matcher (non-top-level) 2021-04-09 00:05:36 +01:00
Analysis [analyzer] Introduce MacroExpansionContext to libAnalysis 2021-02-22 11:11:57 +01:00
Basic [clang][cli] Generate and round-trip language options 2021-02-09 10:18:55 +01:00
CodeGen Reland "Move the test compiler setup in a common place. NFCI" 2020-11-16 13:22:10 +00:00
CrossTU [analyzer][CTU] API for CTU macro expansions 2021-02-22 11:12:22 +01:00
DirectoryWatcher [DirectoryWatcher] Increase timeout to make test less flaky 2021-03-05 17:49:14 -08:00
Driver [Driver] Stop searching other prefixes once a GCC installation is found in one prefix 2021-03-19 20:35:59 -07:00
Format clang-format: [JS] handle "off" in imports 2021-04-30 14:18:52 +02:00
Frontend [clang] Implement CompilerInvocation copy assignment 2021-04-19 11:12:22 +02:00
Index [index] Improve macro indexing support 2021-04-06 09:12:14 -07:00
Introspection [AST] Fix DeclarationNameInfo introspection 2021-04-26 18:49:13 +01:00
Lex [clang] Make sure argument expansion locations are correct in presence of predefined buffer 2020-04-22 21:01:52 +02:00
Rename [clang-rename] Handle designated initializers. 2021-04-12 13:15:14 -07:00
Rewrite [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug 2019-08-15 21:17:48 +00:00
Sema [clang][CodeComplete] Fix crash on ParenListExprs 2021-02-08 13:16:49 +01:00
Serialization Revert "[modules] Do not cache invalid state for modules that we attempted to load." 2020-03-10 10:59:26 -07:00
StaticAnalyzer [analyzer] Don't include private gtest headers 2021-03-22 13:31:38 +01:00
Tooling [libTooling] Add smart pointer support to the `access` Stencil 2021-04-14 10:45:59 -07:00
libclang [libclang] Add CXRewriter to libclang API 2020-09-04 14:17:03 -07:00
CMakeLists.txt [AST] Add generator for source location introspection 2021-03-15 10:52:44 +00:00