Commit Graph

8034 Commits

Author SHA1 Message Date
Balazs Benics 9da697e1bc Reland "[analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag"
It was previously reverted by 8406839d19.

---

This flag was introduced by
6818991d71
    commit 6818991d71
    Author: Ted Kremenek <kremenek@apple.com>
    Date:   Mon Dec 7 22:06:12 2009 +0000

  Add clang-cc option '-analyzer-opt-analyze-nested-blocks' to treat
  block literals as an entry point for analyzer checks.

The last reference was removed by this commit:
5c32dfc5fb

    commit 5c32dfc5fb
    Author: Anna Zaks <ganna@apple.com>
    Date:   Fri Dec 21 01:19:15 2012 +0000

  [analyzer] Add blocks and ObjC messages to the call graph.
  This paves the road for constructing a better function dependency graph.
  If we analyze a function before the functions it calls and inlines,
  there is more opportunity for optimization.
  Note, we add call edges to the called methods that correspond to
  function definitions (declarations with bodies).

Consequently, we should remove this dead flag.
However, this arises a couple of burning questions.
 - Should the `cc1` frontend still accept this flag - to keep
   tools/users passing this flag directly to `cc1` (which is unsupported,
   unadvertised) working.
 - If we should remain backward compatible, how long?
 - How can we get rid of deprecated and obsolete flags at some point?

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126067
2022-06-14 10:22:37 +02:00
Dmitri Gribenko 11f75e0a2d [clang-tidy][docs] Remove an unintentional paragraph break 2022-06-11 21:03:43 +02:00
Dmitri Gribenko 65299c9c65 [clang-tidy][docs] Use std::optional instead of absl::optional in examples
The standard type is vastly more popular than the Abseil polyfill, so it
makes more sense to use it in documentation, even though the checker
actually understands both (and that fact is documented already).
2022-06-11 21:03:43 +02:00
Nico Weber 8406839d19 Revert "[analyzer] Deprecate `-analyzer-store region` flag"
This reverts commit d50d9946d1.
Broke check-clang, see comments on https://reviews.llvm.org/D126067

Also revert dependent change "[analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag"
This reverts commit 07b4a6d046.

Also revert "[analyzer] Fix buildbots after introducing a new frontend warning"
This reverts commit 90374df15d.
(See https://reviews.llvm.org/rG90374df15ddc58d823ca42326a76f58e748f20eb)
2022-06-10 08:50:13 -04:00
Shivam Gupta 8311604669 [NFC] update clang-tools-extra README.txt 2022-06-10 16:59:57 +05:30
Balazs Benics 4c38953f32 [clang-tidy] Remove reference to CSA AnalysisStoreOpt field
D126215 removed the `AnalysisStoreOpt` field, so `clang-tidy` should not
refer to it.
http://45.33.8.238/linux/78232/step_4.txt

  ../../clang-tools-extra/clang-tidy/ClangTidy.cpp:444:22: error: no
member named 'AnalysisStoreOpt' in 'clang::AnalyzerOptions'
      AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
      ~~~~~~~~~~~~~~~~~^
  ../../clang-tools-extra/clang-tidy/ClangTidy.cpp:444:41: error: use of
undeclared identifier 'RegionStoreModel'
      AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;

This one liner patch should resolve the build failure.

Differential Revision: https://reviews.llvm.org/D126215
2022-06-10 13:21:28 +02:00
Balazs Benics 07b4a6d046 [analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag
This flag was introduced by
6818991d71
    commit 6818991d71
    Author: Ted Kremenek <kremenek@apple.com>
    Date:   Mon Dec 7 22:06:12 2009 +0000

  Add clang-cc option '-analyzer-opt-analyze-nested-blocks' to treat
  block literals as an entry point for analyzer checks.

The last reference was removed by this commit:
5c32dfc5fb

    commit 5c32dfc5fb
    Author: Anna Zaks <ganna@apple.com>
    Date:   Fri Dec 21 01:19:15 2012 +0000

  [analyzer] Add blocks and ObjC messages to the call graph.
  This paves the road for constructing a better function dependency graph.
  If we analyze a function before the functions it calls and inlines,
  there is more opportunity for optimization.
  Note, we add call edges to the called methods that correspond to
  function definitions (declarations with bodies).

Consequently, we should remove this dead flag.
However, this arises a couple of burning questions.
 - Should the `cc1` frontend still accept this flag - to keep
   tools/users passing this flag directly to `cc1` (which is unsupported,
   unadvertised) working.
 - If we should remain backward compatible, how long?
 - How can we get rid of deprecated and obsolete flags at some point?

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126067
2022-06-10 13:09:37 +02:00
Nathan James b831786292
[clang-tidy][NFC] Tweak identifier-naming options reading/writiing 2022-06-10 07:07:21 +01:00
Haojian Wu 70d35fe125 [pseudo] Fix the broken build of ClangPseudoBenchmark, after c70aeaa. 2022-06-09 23:03:54 +02:00
Haojian Wu c70aeaad2b [pseudo] Move grammar-related headers to a separate dir, NFC.
We did that for .cpp, but forgot the headers.

Differential Revision: https://reviews.llvm.org/D127388
2022-06-09 14:58:05 +02:00
Christian Kandeler bf830623b0 [pseudo] Fix unit test build
Analogous to 632545e8ce.

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D127397
2022-06-09 14:42:47 +02:00
Sam McCall 18f0b7092d [pseudo] Don't clang-format test inputs. NFC 2022-06-09 14:18:30 +02:00
Haojian Wu 9ce232fba9 [pseudo] Fix the missing-field-initializers warning from f1ac00c9b0, NFC 2022-06-09 14:10:36 +02:00
Paul Pluzhnikov afbe3aed49 [clangd] Minor refactor of CanonicalIncludes::addSystemHeadersMapping.
Before commit b3a991df3c SystemHeaderMap used to be a vector.

Commit b3a991df3c changed it into a map, but neglected to remove
duplicate keys (e.g. "bits/typesizes.h", "include/stdint.h", etc.).

To prevent confusion, remove all duplicates, build HeaderMapping
one pair at a time and assert() that no duplicates are found.

Change by Paul Pluzhnikov (ppluzhnikov)!

Reviewed By: ilya-biryukov

Differential Revision: https://reviews.llvm.org/D125742
2022-06-09 12:18:39 +02:00
Haojian Wu f1ac00c9b0 [pseudo] Add grammar annotations support.
Add annotation handling ([key=value]) in the BNF grammar parser, which
will be used in the conditional reduction, and error recovery.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D126536
2022-06-09 12:06:22 +02:00
Haojian Wu 74e4d5f256 [pseudo] Simplify the glrReduce implementation.
glrReduce maintains two priority queues (one for bases, and the other
for Sequence), these queues are in parallel with each other, corresponding to a
single family. They can be folded into one.

This patch removes the bases priority queue, which improves the glrParse by
10%.

ASTReader.cpp: 2.03M/s (before) vs 2.26M/s (after)

Differential Revision: https://reviews.llvm.org/D127283
2022-06-09 11:28:52 +02:00
Haojian Wu 7a05942dd0 [pseudo] Remove the explicit Accept actions.
As pointed out in the previous review section, having a dedicated accept
action doesn't seem to be necessary. This patch implements the the same behavior
without accept acction, which will save some code complexity.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D125677
2022-06-09 11:19:07 +02:00
Haojian Wu 075449da80 [pseudo] Fix a sign-compare warning in debug build, NFC. 2022-06-09 11:18:03 +02:00
Christian Kandeler d352017184 [include-cleaner] Fix build error in unit test
Reviewed By: nridge

Differential Revision: https://reviews.llvm.org/D127217
2022-06-09 03:38:13 -04:00
Sam McCall 94b2ca18c1 [pseudo] GC GSS nodes, reuse them with a freelist
Most GSS nodes have short effective lifetimes, keeping them around until the
end of the parse is wasteful. Mark and sweep them every 20 tokens.

When parsing clangd/AST.cpp, this reduces the GSS memory from 1MB to 20kB.
We pay ~5% performance for this according to the glrParse benchmark.
(Parsing more tokens between GCs doesn't seem to improve this further).

Compared to the refcounting approach in https://reviews.llvm.org/D126337, this
is simpler (at least the complexity is better isolated) and has >2x less
overhead. It doesn't provide death handlers (for error-handling) but we have
an alternative solution in mind.

Differential Revision: https://reviews.llvm.org/D126723
2022-06-08 23:39:59 +02:00
Sam McCall bbc58c5e9b [pseudo] Restore accidentally removed debug print 2022-06-08 23:39:34 +02:00
Sam McCall 93bcff8aa8 [pseudo] Invert rows/columns of LRTable storage for speedup. NFC
There are more states than symbols.
This means first partioning the action list by state leaves us with a smaller
range to binary search over. This improves find() a lot and glrParse() by 7%.
The tradeoff is storing more smaller ranges increases the size of the offsets
array, overall grammar memory is +1% (337->340KB).

Before:
glrParse    188795975 ns    188778003 ns           77 bytes_per_second=1.98068M/s
After:
glrParse    175936203 ns    175916873 ns           81 bytes_per_second=2.12548M/s

Differential Revision: https://reviews.llvm.org/D127006
2022-06-08 23:35:14 +02:00
Nathan Lanza dd2f290918 Add llvm's Support lib to the psuedoCXX library
This is failing to find `EnableABIBreakingCheck` at link time. Add
Support to provide it here.

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D127269
2022-06-08 17:12:02 -04:00
Andrew Browne c7689fd552 [Clang] Fix memory leak due to TemplateArgumentListInfo used in AST node.
It looks like the leak is rooted at the allocation here:
1a155ee7de/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (L3857)

The VarTemplateSpecializationDecl is allocated using placement new which uses the AST structure for ownership: 1a155ee7de/clang/lib/AST/DeclBase.cpp (L99)

The problem is the TemplateArgumentListInfo inside 1a155ee7de/clang/include/clang/AST/DeclTemplate.h (L2721)
This object contains a vector which does not use placement new: 1a155ee7de/clang/include/clang/AST/TemplateBase.h (L564)

Apparently ASTTemplateArgumentListInfo should be used instead 1a155ee7de/clang/include/clang/AST/TemplateBase.h (L575)

https://reviews.llvm.org/D125802#3551305

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D126944
2022-06-08 09:58:25 -07:00
Martin Boehme f4baf63155 [clang-tidy] Fix syntax error in release notes.
Introduced by
1b664460fa

Sorry for the breakage.
2022-06-07 13:04:56 +02:00
Martin Boehme 1b664460fa [clang-tidy] `bugprone-use-after-move`: Don't warn on self-moves.
Reviewed By: sammccall, njames93

Differential Revision: https://reviews.llvm.org/D126853
2022-06-07 12:53:03 +02:00
Haojian Wu 28eeea1e27 [pseudo]Pull out the operator< test, NFC
Fix the review comment in https://reviews.llvm.org/D125479.
2022-06-07 11:00:08 +02:00
Haojian Wu cf88150c48 [pseudo] Fix the incorrect parameters-and-qualifiers rule.
The parenthese body should be parameter-declaration-clause, rather
than parameter-declaration-list.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D125479
2022-06-07 10:47:07 +02:00
Haojian Wu ecd7ff53b5 [pseudo] Fix the type-parameter rule.
The IDENTIFIER should be optional.

Differential Revision: https://reviews.llvm.org/D126998
2022-06-07 10:36:45 +02:00
Haojian Wu 90dab0473e [pseudo] Handle the language predefined identifier __func__
The clang lexer lexes it as a dedicated token kind (rather than
identifier), we extend the grammar to handle it.

Differential Revision: https://reviews.llvm.org/D126996
2022-06-07 10:34:37 +02:00
Haojian Wu 58b33bc8c4 [pseudo] Fix noptr-abstract-declarator rule.
The const-expression in the [] can be empty.

Differential Revision: https://reviews.llvm.org/D126992
2022-06-07 10:22:23 +02:00
Haojian Wu 0a6a17a4f9 [pseudo] Fix the member-specification grammar rule.
The grammar rule is not right, doesn't match the standard one.

Differential Revision: https://reviews.llvm.org/D126991
2022-06-07 10:18:18 +02:00
Qingyuan Zheng c119a17e7f [AST] Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl
Fixes https://github.com/clangd/clangd/issues/1132
where clangd's semantic highlighting is missing for symbols of a template
specialization definition. It turns out the visitor didn't traverse the
base classes of Class/Var##TemplateSpecializationDecl, i.e.
CXXRecordDecl/VarDecl. This patch adds them back as what is done in
DEF_TRAVERSE_TMPL_PART_SPEC_DECL.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D126757
2022-06-06 02:35:34 -04:00
Fangrui Song d86a206f06 Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options 2022-06-05 00:31:44 -07:00
Fangrui Song 47ec8b5574 [pseudo] Fix leaks after D126731
Array Operator new Cookies help lsan find allocations, while std::array
can't.
2022-06-03 18:43:16 -07:00
Sam McCall 830d158d2b [pseudo] Add CLANG_PSEUDO_GEN cmake cache variable to avoid nested CMake invocation
Similar to LLVM_TABLEGEN, CLANG_TABLEGEN variables

Differential Revision: https://reviews.llvm.org/D126717
2022-06-03 20:48:55 +02:00
Sam McCall a43fef05d4 [pseudo] rename pseudo-gen -> clang-pseudo-gen. NFC
This name is not namespaced. Requested in D126717

Differential Revision: https://reviews.llvm.org/D126725
2022-06-03 20:45:48 +02:00
Sam McCall dc63ad8878 [pseudo] Eliminate dependencies from clang-pseudo-gen. NFC
ClangBasic dependency eliminated by replacing our usage of
tok::getPunctuatorSpelling etc with direct use of the *.def file.

Implicit dependencies on clang-tablegen-targets removed as we manage to avoid
any transitive tablegen deps.

After these changes, `ninja clean; ninja pseudo-gen` runs 169 actions only
(basically Support and Demangle).

Differential Revision: https://reviews.llvm.org/D126731
2022-06-03 20:42:38 +02:00
Nico Weber 371e6f8b7f Revert "[clang-tidy] Confusable identifiers detection"
This reverts commit b94db7ed7e.
See comments on https://reviews.llvm.org/D112916:
- breaks `check-clangd`, and makes clang-tidy crash on simple inputs
- likely does the wrong thing in cross builds

Also revert follow-up "[gn build] (manually) port b94db7ed7e (Confusables.inc)"
This reverts commit 180bae08a0.
2022-06-03 09:30:01 -04:00
Nico Weber 88052fd241 check_clang_tidy.py: Update run line to python3
`python` no longer exists on several systems, and the script
runs under python3 when run as part of lit.
2022-06-03 09:28:09 -04:00
Nico Weber 180bae08a0 [gn build] (manually) port b94db7ed7e (Confusables.inc) 2022-06-03 07:49:28 -04:00
CHIANG, YU-HSUN (Tommy Chiang, oToToT) 8df2b1a866 [pp-trace] Print HashLoc in InclusionDirective callback
The HashLoc in InclusionDirective callback is an unused parameter.
Since pp-trace is also used as a test of Clang’s PPCallbacks interface,
add it to the output of pp-trace could avoid some unintended change on
it.

This shuold resolves PR52673

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D125373
2022-06-03 19:29:59 +08:00
serge-sans-paille b94db7ed7e [clang-tidy] Confusable identifiers detection
Detect identifiers that are confusable according to Unicode definition

        http://www.unicode.org/reports/tr39/#Confusable_Detection

and have conflicting scopes.

Differential Revision: https://reviews.llvm.org/D112916
2022-06-03 12:18:36 +02:00
Martin Boehme b50542f21e [clang-tidy] Add missing close quote in release notes.
Sorry for the breakage.
2022-06-03 10:33:57 +02:00
Martin Boehme 8b90b25390 [clang-tidy] `bugprone-use-after-move`: Fix handling of moves in lambda captures
Previously, we were treating a move in the lambda capture as if it happened
within the body of the lambda, not within the function that defines the lambda.

This fixes the same bug as https://reviews.llvm.org/D119165 (which it appears
may have been abandoned by the author?) but does so more simply.

Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D126780
2022-06-03 09:34:09 +02:00
Nicolas van Kempen 987f9cb6b9 [clang-tidy] Add proper emplace checks to modernize-use-emplace
modernize-use-emplace only recommends going from a push_back to an
emplace_back, but does not provide a recommendation when emplace_back is
improperly used. This adds the functionality of warning the user when
an unecessary temporary is created while calling emplace_back or other "emplacy"
functions from the STL containers.

Reviewed By: kuhar, ivanmurashko

Differential Revision: https://reviews.llvm.org/D101471
2022-06-03 00:14:57 +01:00
Mikael Holmen 35f0890c4e [clang-tidy] Remove extra ";" in ModernizeModuleTest.cpp
Without this fix we get

../../clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:270:2: error: extra ';' outside of a function is incompatible with C++98 [-Werror,-Wc++98-compat-extra-semi]
};
 ^
1 error generated.

when compiling with -Werror.
2022-06-02 12:50:00 +02:00
Richard b418ef5cb9 [clang-tidy] Reject invalid enum initializers in C files
C requires that enum values fit into an int.  Scan the macro tokens
present in an initializing expression and reject macros that contain
tokens that have suffixes making them larger than int.

C forbids the comma operator in enum initializing expressions, so
optionally reject comma operator.

Differential Revision: https://reviews.llvm.org/D125622

Fixes #55467
2022-06-01 22:25:39 -06:00
Adrian Prantl d951ca5439 Revert "[Driver] Enable to use C++20 standalne by -fcxx-modules"
This reverts commit a544710cd4.

See discussion in D120540.

This breaks C++ Clang modules on Darwin and also more than a dozen
tests in the LLDB testsuite.  I think we need to be more careful to
separate out the enabling of Clang C++ modules and C++20
modules. Either by having -fmodules-ts control the HaveModules flag,
or by adding a way to explicitly turn them off.
2022-06-01 12:11:57 -07:00
Haojian Wu 94552f0216 [pseudo] Build inc files when cxx.bnf changes.
Add the cxx.bnf file as a dependency of custom gen commands, so that the
inc files can be rebuilt when cxx.bnf changes.
2022-06-01 13:48:09 +02:00