summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[clang-tidy] Fix readability-redundant-string-init for c++17/c++2a"Mitchell Balan2019-11-194-23/+4
| | | | This reverts commit 06f3dabe4a2e85a32ade27c0769b6084c828a206.
* [clang-tidy] Added DefaultOperatorNewCheck.Balázs Kéri2019-11-199-5/+193
| | | | | | | | | | | | | | | | Summary: Added new checker 'cert-default-operator-new' that checks for CERT rule MEM57-CPP. Simple version. Reviewers: aaron.ballman, alexfh, JonasToth, lebedev.ri Reviewed By: aaron.ballman Subscribers: hiraditya, martong, mehdi_amini, mgorny, inglorion, xazax.hun, dkrupp, steven_wu, dexonsmith, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67545
* [clangd] Fix hover 'local scope' to include class template paramsSam McCall2019-11-192-11/+11
| | | | | | | | | | | | Summary: Fixes the last part of https://github.com/clangd/clangd/issues/76 Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70325
* [clangd] More sensible output for constructors/destructors in hover.Sam McCall2019-11-194-41/+68
| | | | | | | | | | | | | | Summary: Previously: both had type void() and return type void. Now: neither have a type. Constructors return T, destructors return void. Reviewers: hokein Subscribers: merge_guards_bot, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70317
* [clangd] Fix ps4 buildbot failure.Haojian Wu2019-11-191-2/+0
| | | | | dynamic_cast on ps4 buildbot seems relying on rtti flag which is off by default. Remove the dynamic_cast in the tests.
* Reland "[clangd] Implement rename by using SelectionTree and ↵Haojian Wu2019-11-192-48/+459
| | | | | | | | | findExplicitReferences." this reland the commit 4f80fc2491cc35730a9a84b86975278b7daa8522 which has been reverted at f805c60a093325c16ce4200d2615ef48555d9cb8. Fixed windows buildbot failure (by adding -fno-delayed-template-parsing flag).
* Revert "[clangd] Implement rename by using SelectionTree and ↵Wolfgang Pieb2019-11-182-462/+46
| | | | | | | | | findExplicitReferences." This reverts commit 4f80fc2491cc35730a9a84b86975278b7daa8522. Caused buildbot failure at http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/58251
* [clangd] Store xref for Macros in ParsedAST.Utkarsh Saxena2019-11-186-8/+146
| | | | | | | This patch adds the cross references for Macros in the MainFile. We add references for the main file to the ParsedAST. We query the references from it using the SymbolID. Xref outside main file will be added to the index in a separate patch.
* [clangd] Implement rename by using SelectionTree and findExplicitReferences.Haojian Wu2019-11-182-46/+462
| | | | | | | | | | | | | | | | | | | | | | | Summary: With the new implemenation, we will have better coverage of various AST nodes, and fix some known/potential bugs. Also added the existing clang-renamae tests. Known changed behavior: - "~Fo^o()" will not trigger the rename, will fix afterwards - references in macro bodies are not renamed now This fixes: - https://github.com/clangd/clangd/issues/167 - https://github.com/clangd/clangd/issues/169 - https://github.com/clangd/clangd/issues/171 Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69934
* [clangd] Fix some clang-tidy warnings on SourceCodeTests.cpp, NFC.Haojian Wu2019-11-181-9/+8
|
* [clangd] Fix diagnostic warnings in the RenameTests, NFC.Haojian Wu2019-11-181-2/+4
|
* [clangd] Expose the xref's incomplete flag to clangdServer API.Haojian Wu2019-11-186-29/+46
| | | | | | | | | | | | Summary: so that clangd C++ API users (via ClangdServer) can access it. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70380
* [AST] Attach comment in `/** doc */ typedef struct A {} B` to B as well as A.Sam McCall2019-11-181-0/+13
| | | | | | | | | | | | | | | | | | | | | | Summary: Semantically they're the same thing, and it's important when the underlying struct is anonymous. There doesn't seem to be a problem attaching the same comment to multiple things as it already happens with `/** doc */ int a, b;` This affects an Index test but the results look better (name present, USR points to the typedef). Fixes https://github.com/clangd/clangd/issues/189 Reviewers: kadircet, lh123 Subscribers: ilya-biryukov, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70203
* Revert "[NFC] Refactor representation of materialized temporaries"Nico Weber2019-11-175-5/+5
| | | | | | This reverts commit 08ea1ee2db5f9d6460fef1d79d0d1d1a5eb78982. It broke ./ClangdTests/FindExplicitReferencesTest.All on the bots, see comments on https://reviews.llvm.org/D69360
* [NFC] Refactor representation of materialized temporariesTyker2019-11-165-5/+5
| | | | | | | | | | | | | | | Summary: this patch refactor representation of materialized temporaries to prevent an issue raised by rsmith in https://reviews.llvm.org/D63640#inline-612718 Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: rnkovacs, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69360
* [clangd] Improve long and confusing preamble log message.Sam McCall2019-11-161-2/+3
|
* Remove +x permission on some filesSylvestre Ledru2019-11-162-0/+0
|
* Avoid including Builtins.h in Preprocessor.hReid Kleckner2019-11-153-0/+3
| | | | | | Builtins are rarely if ever accessed via the Preprocessor. They are typically found on the ASTContext, so there should be no performance penalty to using a pointer indirection to store the builtin context.
* [clang-tidy] Give readability-redundant-string-init a customizable list of ↵Mitchell Balan2019-11-155-13/+144
| | | | | | | | | | | | | | | | | | | string types to fix Summary: This patch adds a feature requested in https://reviews.llvm.org/D69238 to enable `readability-redundant-string-init` to take a list of strings to apply the fix to rather than hard-coding `basic_string`. It adds a `StringNames` option of semicolon-delimited names of string classes to which to apply this fix. Tests ensure this works with test class out::TestString as well as std::string and std::wstring as before. It should be applicable to llvm::StringRef, QString, etc. Note: This commit was previously reverted due to a failing unit test. That test has been fixed in this version. Reviewers: MyDeveloperDay, aaron.ballman, hokein, alexfh, JonasToth, gribozavr2 Patch by: poelmanc Subscribers: gribozavr2, xazax.hun, Eugene.Zelenko, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D69548
* [clang-tidy] Fix readability-redundant-string-init for c++17/c++2aMitchell Balan2019-11-154-4/+23
| | | | | | | | | | | | | | | | | | | Summary: `readability-redundant-string-init` was one of several clang-tidy checks documented as failing for C++17. (The failure mode in C++17 is that it changes `std::string Name = ""`; to `std::string Name = Name;`, which actually compiles but crashes at run-time.) Analyzing the AST with `clang -Xclang -ast-dump` showed that the outer `CXXConstructExprs` that previously held the correct SourceRange were being elided in C++17/2a, but the containing `VarDecl` expressions still had all the relevant information. So this patch changes the fix to get its source ranges from `VarDecl`. It adds one test `std::string g = "u", h = "", i = "uuu", j = "", k;` to confirm proper warnings and fixit replacements in a single `DeclStmt` where some strings require replacement and others don't. The readability-redundant-string-init.cpp and readability-redundant-string-init-msvc.cpp tests now pass for C++11/14/17/2a. Reviewers: gribozavr, etienneb, alexfh, hokein, aaron.ballman, gribozavr2 Patch by: poelmanc Subscribers: NoQ, MyDeveloperDay, Eugene.Zelenko, dylanmckay, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D69238
* Revert "[clang-tidy] Give readability-redundant-string-init a customizable ↵Mitchell Balan2019-11-155-144/+13
| | | | | | list of string types to fix" This reverts commit 96fbc32cb9ea23b1e7e3ff6906ec3ccda9500982.
* [clang-tidy] Give readability-redundant-string-init a customizable list of ↵Mitchell Balan2019-11-155-13/+144
| | | | | | | | | | | | | | | | | string types to fix Summary: This patch adds a feature requested in https://reviews.llvm.org/D69238 to enable `readability-redundant-string-init` to take a list of strings to apply the fix to rather than hard-coding `basic_string`. It adds a `StringNames` option of semicolon-delimited names of string classes to which to apply this fix. Tests ensure this works with test class out::TestString as well as std::string and std::wstring as before. It should be applicable to llvm::StringRef, QString, etc. Reviewers: MyDeveloperDay, aaron.ballman, hokein, alexfh, JonasToth, gribozavr2 Patch by: poelmanc Subscribers: gribozavr2, xazax.hun, Eugene.Zelenko, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D69548
* [clang-tidy] modernize-use-override new option AllowOverrideAndFinalMitchell Balan2019-11-153-17/+20
| | | | | | | | | | | | | | | | | | | Summary: In addition to adding `override` wherever possible, clang-tidy's `modernize-use-override` nicely removes `virtual` when `override` or `final` is specified, and further removes override when final is specified. While this is great default behavior, when code needs to be compiled with gcc at high warning levels that include `gcc -Wsuggest-override` or `gcc -Werror=suggest-override`, clang-tidy's removal of the redundant `override` keyword causes gcc to emit a warning or error. This discrepancy / conflict has been noted by others including a comment on Stack Overflow and by Mozilla's Firefox developers. This patch adds an AllowOverrideAndFinal option defaulting to 0 - thus preserving current behavior - that when enabled allows both `override` and `final` to co-exist, while still fixing all other issues. The patch includes a test file verifying all combinations of virtual/override/final, and mentions the new option in the release notes. Reviewers: alexfh, djasper, JonasToth Patch by: poelmanc Subscribers: JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70165
* [clang-tidy] modernize-use-using work with multi-argument templatesMitchell Balan2019-11-152-11/+95
| | | | | | | | | | | | | | | | | | | | | | | Summary: If clang-tidy's modernize-use-using feature finds any commas that are not within parentheses, it won't create a fix. That means it won't change lines like: typedef std::pair<int, int> Point; to using Point = std::pair<int, int>; or even: typedef std::map<std::string, Foo> MyMap; typedef std::vector<int,MyCustomAllocator<int>> MyVector; This patch allows the fix to apply to lines with commas if they are within parentheses or angle brackets that were not themselves within parentheses. Reviewers: alexfh, hokein, aaron.ballman Patch by: poelmanc Subscribers: jonathanmeier, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D67460
* [clangd] Don't repeat class template args when printing constructor definitionsSam McCall2019-11-152-1/+2
| | | | This fixes part of https://github.com/clangd/clangd/issues/76
* [clangd] Fix typo in symbol kind conversionSam McCall2019-11-153-8/+8
| | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70309
* [clangd] Don't consider class template params part of constructor name.Sam McCall2019-11-153-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This is shorter and usually the extra info is noise. There are cases where the params become type-parameter-0-0 that are hard to fix. This affects a few features: - 'name' field in structured hover API (not exposed yet) - 'name' field in locateSymbolAt (not exposed in LSP) - 'document/symbol' - the symbol is hierarchically nested in the class template, or written as foo<t>::foo when defined out-of-line. Added a test case for hover from https://github.com/clangd/clangd/issues/76. This patch fixes one field, but no fewer than four others are wrong! I'll fix them... Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70308
* [clangd] Fix SelectionTree behavior on constructor init-lists.Sam McCall2019-11-152-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | Summary: For the constructor Foo() : classmember(arg) {} The AST looks like: - CXXCtorInitializer classmember(arg) - CXXConstructExpr classmember(arg) - DeclRefExpr: arg We want the 'classmember' to be associated with the CXXCtorInitializer, not the CXXConstructExpr. (CXXConstructExpr is known to have bad ranges). So just early-claim it. Thanks @hokein for tracking down/reducing the bug. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits, hokein Tags: #clang Differential Revision: https://reviews.llvm.org/D70312
* [clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.Haojian Wu2019-11-155-7/+17
| | | | | | | | | | | | | | | | Summary: The helper is more correct to detect header file, this would fix our issues caused by false positive before. Reviewers: sammccall Reviewed By: sammccall Subscribers: merge_guards_bot, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70299
* [clangd] Add isHeaderFile helper.Haojian Wu2019-11-154-6/+44
| | | | | | | | | | | | | | | | | | | Summary: we have a few places using `ASTCtx.getLangOpts().IsHeaderFile` to determine a header file, but it relies on "-x c-header" compiler flag, if the compilation command doesn't have this flag, we will get a false positive. We are encountering this issue in bazel build system. To solve this problem, we infer the file from file name, actual changes will come in follow-ups. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70235
* [AST] Use written names instead of `type-param-0-0` in more cases when ↵Sam McCall2019-11-152-2/+12
| | | | | | | | | | | | | | | | | | | printing types and decls. Summary: This doesn't cover decls in diagnostics, which use NamedDecl::getNameForDiagnostic(). (That should also be fixed later I think). This covers some cases of https://github.com/clangd/clangd/issues/76 (hover, but not outline or sighelp) Reviewers: hokein Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70236
* [clang-include-fixer] Skip .rc files when finding symbolsReid Kleckner2019-11-141-0/+3
| | | | | | | | | | | | | | | | Summary: For some reason CMake includes entries for .rc files, but find-all-symbols handles them improperly. See PR43993 Reviewers: sammccall, bkramer Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70196
* [clangd] Ignore more implicit nodes in computing selection.Sam McCall2019-11-142-9/+39
| | | | | | | | | | | | | | | | | | | | | | Summary: The DeclRefExpr for the callee of overloaded `operator()` and `operator[]` are assigned the range of the paren/bracket lists in the AST. These are better thought of as implicit (at least `()` - `[] is murkier). But there's no bit on Expr for implicit, so just ignore them on our side. While here, deal with the case where an implicit stmt (e.g. implicit-this) is wrapped in an implicit cast. Previously we ignored the statement but not the cast, and so the cast ended up being selected. Fixes https://github.com/clangd/clangd/issues/195 Reviewers: kadircet, lh123 Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70194
* [clangd] Expose value of enumerators to Hover API. (not UI yet)Sam McCall2019-11-142-0/+17
| | | | | | | | | | | | Summary: This is part of https://github.com/clangd/clangd/issues/180. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70209
* [clangd] Simplify the code in Index::refsIlya Biryukov2019-11-143-26/+17
| | | | | | | | | | | | | | | | | Summary: While here, also fix potential UB in MergeIndex. Thanks Kadir for finding this! Reviewers: hokein Reviewed By: hokein Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70225
* [clangd] Add bool return type to Index::refs API.Haojian Wu2019-11-1312-25/+58
| | | | | | | | | | | | | | | | Summary: Similar to fuzzyFind, the bool indicates whether there are more xref results. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70139
* [clangd] Fix crash in DefineInline::prepare()Sam McCall2019-11-112-1/+4
|
* [libTooling] Further simplify `Stencil` type and introduce `MatchComputation`.Yitzhak Mandelbaum2019-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: This revision introduces a new interface `MatchComputation` which generalizes the `Stencil` interface and replaces the `std::function` interface of `MatchConsumer`. With this revision, `Stencil` (as an abstraction) becomes just one collection of implementations of `MatchComputation<std::string>`. Correspondingly, we remove the `Stencil` class entirely in favor of a simple type alias, deprecate `MatchConsumer` and change all functions that accepted `MatchConsumer<std::string>` to use `MatchComputation<std::string>` instead. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69802
* Fix filename typo in rG8d288a0668a5Simon Pilgrim2019-11-111-2/+2
|
* [clang-tidy] Add bugprone-bad-signal-to-kill-thread check and its alias ↵Abel Kocsis2019-11-1110-0/+191
| | | | cert-pos44-c
* Revert "[clang-tidy] Add bugprone-bad-signal-to-kill-thread checker and ↵Abel Kocsis2019-11-1110-191/+0
| | | | | | alias cert-pos44-c" This reverts commit 4edf0cb0e03e31d468979d0d7dec08bd9f4f8204.
* [clang-tidy] Add bugprone-bad-signal-to-kill-thread checker and alias ↵Abel Kocsis2019-11-1110-0/+191
| | | | cert-pos44-c
* [clangd] fixes semantic highlighting testHaojian Wu2019-11-111-21/+29
| | | | | | | | | | | | | | | | Summary: fixes https://github.com/clangd/clangd/issues/176 Patch by liu hui! Reviewers: ilya-biryukov, hokein, sammccall Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D70078
* [clangd] Use name of Macro to compute its SymbolID, NFC.Utkarsh Saxena2019-11-114-7/+8
| | | | | | | | | | | | | | | | | | | Summary: We use the name from the IdentifierInfo of the Macro to compute its SymbolID. It is better to just take the Name as a parameter to avoid storing the IdentifierInfo whenever we need the SymbolID for the Macro. Patch by UTKARSH SAXENA! Reviewers: hokein Reviewed By: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69937
* [clangd] Fix a regression of not showing documentation from forward ↵Haojian Wu2019-11-112-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | declarations. Summary: There is a regression from https://reviews.llvm.org/D68467. Unlike class forward declarations, function ducomentation is written in the declaration in headers, the function definition doesn't contain any documentation, cases like: ``` foo.h // this is foo. void foo(); foo.cc void foo() {} ``` we should still show documentation from the foo declaration. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69961
* [clangd] Fixes colon escaping on WindowsIlya Biryukov2019-11-113-22/+24
| | | | | | vscode always escapes the colon on the file uri, which causes the semantic highlighting fails on windows. fixes: https://github.com/clangd/clangd/issues/176
* [clangd] NFC, reuse the source manager variable in the RawStringLiteral ↵Alex Lorenz2019-11-081-2/+1
| | | | | | apply method Differential Revision: https://reviews.llvm.org/D69544
* Revert "Reapply "Fix crash on switch conditions of non-integer types in ↵Melanie Blower2019-11-082-3/+1
| | | | | | | templates"" This reverts commit 759948467ea3181615d44d80f74ffeb260180fd0. There were build bot failures in clang-tidy
* Reapply "Fix crash on switch conditions of non-integer types in templates"Melanie Blower2019-11-082-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch reapplies commit 76945821b9cad3. The first version broke buildbots due to clang-tidy test fails. The fails are because some errors in templates are now diagnosed earlier (does not wait till instantiation). I have modified the tests to add checks for these diagnostics/prevent these diagnostics. There are no additional code changes. Summary of code changes: Clang currently crashes for switch statements inside a template when the condition is a non-integer field member because contextual implicit conversion is skipped when parsing the condition. This conversion is however later checked in an assert when the case statement is handled. The conversion is skipped when parsing the condition because the field member is set as type-dependent based on its containing class. This patch sets the type dependency based on the field's type instead. This patch fixes Bug 40982. Reviewers: rnk, gribozavr2 Patch by: Elizabeth Andrews (eandrews) Differential revision: https://reviews.llvm.org/D69950
* [clangd] NFC, hide the internal-only utility function lex.Haojian Wu2019-11-071-3/+4
| | | | To avoid any potential ODR violations.
OpenPOWER on IntegriCloud