aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-query
AgeCommit message (Collapse)AuthorFilesLines
2021-04-28[clang-query] Add check to prevent setting srcloc when no introspection is ↵Nathan James2-11/+17
available. Checks if introspection support is available set output kind parser. If it isn't present the auto complete will not suggest `srcloc` and an error query will be reported if a user tries to access it. Reviewed By: steveire Differential Revision: https://reviews.llvm.org/D101365
2021-04-25Add srcloc output to clang-queryStephen Kelly5-5/+106
Differential Revision: https://reviews.llvm.org/D93325
2021-03-03[clang-query] Fix help text after D91918Nathan James1-2/+0
After rG5e1801813d93210acae84ff3c68a01512c2df9bc The help command still lists IgnoreImplicitCastsAndParentheses as a valid option. Reviewed By: aaron.ballman, rsmith Differential Revision: https://reviews.llvm.org/D97806
2021-03-02[cte][NFC] Remove all references to stdlib stream headers.Nathan James1-8/+7
Inclusion of iostream is frobidden and using other stream classes from standard library is discouraged as per https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D97771
2021-01-25Add a --use-color option to clang-query to allow forcing the behaviorTom Ritter2-2/+22
D62056 makes the output color if clang auto-detects a tty, but if it does not, there is no way to force it to use colors anyway. This patch adjusts the command-lines given to ClangTool which will force color on or off if --use-color is specified.
2020-12-11Remove references to the ast_type_traits namespaceAlexander Kornienko4-12/+8
Follow up to cd62511496938e33c061c90796dd23a5288ff843 / https://reviews.llvm.org/D74499 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D92994
2020-11-23Remove the IgnoreImplicitCastsAndParentheses traversal kindStephen Kelly1-2/+0
Differential Revision: https://reviews.llvm.org/D91918
2020-08-28[clang-query][NFC] Silence a few lint warningsNathan James1-10/+12
2020-07-03Revert AST Matchers default to AsIs modeStephen Kelly2-4/+4
Reviewers: aaron.ballman, klimek Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83076
2020-07-03[clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumperBruno Ricci1-2/+1
In general there is no way to get to the ASTContext from most AST nodes (Decls are one of the exception). This will be a problem when implementing the rest of APValue::dump since we need the ASTContext to dump some kinds of APValues. The ASTContext* in ASTDumper and TextNodeDumper is not always non-null. This is because we still want to be able to use the various dump() functions in a debugger. No functional changes intended. Reverted in fcf4d5e4499a391dff42ea1a096f146db44147b6 since a few dump() functions in lldb where missed.
2020-07-02Revert "[clang][NFC] Store a pointer to the ASTContext in ASTDumper and ↵Bruno Ricci1-1/+2
TextNodeDumper" This reverts commit aa7fd905e4e1bc510448431da9310e8cf5197523. I missed some dump() functions.
2020-07-02[clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumperBruno Ricci1-2/+1
In general there is no way to get to the ASTContext from most AST nodes (Decls are one of the exception). This will be a problem when implementing the rest of APValue::dump since we need the ASTContext to dump some kinds of APValues. The ASTContext* in ASTDumper and TextNodeDumper is not always non-null. This is because we still want to be able to use the various dump() functions in a debugger. No functional changes intended.
2020-06-23[openmp] Add missing dependencies for OMP.h.inc after d90443bValentin Clement1-0/+3
2020-06-17[clang-tools-extra] Prevent linking to duplicate .a libs and dylibMichał Górny1-1/+3
Fix various tool libraries not to link to clang's .a libraries and dylib simultaneously. This may cause breakage, in particular through duplicate command-line option declarations. Differential Revision: https://reviews.llvm.org/D81967
2020-05-31clang-tidy and clang-query wont crash with invalid command line optionsNathan James1-3/+11
Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=46141 | clang-tidy crashed for unknown command line argument. ]] Reviewed By: aaron.ballman, thakis Differential Revision: https://reviews.llvm.org/D80879
2020-05-31Revert "clang-tidy and clang-query wont crash with invalid command line options"Nathan James1-11/+3
This reverts commit f23ddbe3c3ae5f40b99ba272afc3d16b800ba8b9.
2020-05-31clang-tidy and clang-query wont crash with invalid command line optionsNathan James1-3/+11
Summary: Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=46141 | clang-tidy crashed for unknown command line argument. ]] Reviewers: aaron.ballman, alexfh Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80879
2020-05-23Add a way to set traversal mode in clang-queryStephen Kelly5-2/+47
Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73037
2020-04-07[OpenMP] "UnFix" layering problem with FrontendOpenMPJohannes Doerfert1-0/+1
This reverts commit 97aa593a8387586095b7eac12974ba2fdd08f4c3 as it causes problems (PR45453) https://reviews.llvm.org/D77574#1966321. This additionally adds an explicit reference to FrontendOpenMP to clang-tidy where ASTMatchers is used. This is hopefully just a temporary solution. The dependence on `FrontendOpenMP` from `ASTMatchers` should be handled by CMake implicitly, not us explicitly. Reviewed By: aheejin Differential Revision: https://reviews.llvm.org/D77666
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-1/+2
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-12-29Fix newline handling in clang-query parserStephen Kelly1-1/+1
Don't prematurely remove characters from the end of the string
2019-12-27Allow newlines in AST Matchers in clang-query filesStephen Kelly4-19/+68
Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
2019-12-26Revert "Allow newlines in AST Matchers in clang-query files" + 1Evgenii Stepanov4-68/+19
Revert "Fix -Wunused-lambda-capture warnings." This reverts commit 2369560f4a7720b19edfbf9de14ef061307ff773. This reverts commit 522ee29a4fb3814db604b585c8637247477ec057. clang/lib/ASTMatchers/Dynamic/Parser.cpp:610:13: warning: implicit conversion turns string literal into bool: 'const char [35]' to 'bool' [-Wstring-conversion] assert(!"Newline should never be found here");
2019-12-26Fix -Wunused-lambda-capture warnings.Eric Christopher1-1/+1
2019-12-26Allow newlines in AST Matchers in clang-query filesStephen Kelly4-19/+68
Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
2019-12-26Revert "Allow newlines in AST Matchers in clang-query files"Stephen Kelly4-68/+19
This reverts commit 6a3ecf4dc7ec299394e71b3124df2b3a34ed4ac3.
2019-12-26Allow newlines in AST Matchers in clang-query filesStephen Kelly4-19/+68
Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
2019-12-06Use ASTDumper to dump the AST from clang-queryStephen Kelly1-1/+6
Summary: This way, the output is not limited by the various API differences between the dump() member functions. For example, all dumps are now in color, while that used to be the case only for Decls and Stmts, but not Types. Additionally, while DynTypedNode::dump (which was used up to now) was limited to dumping only Decls, Stmts and Types, this makes clang-query support everything ASTNodeTraverser supports. Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62056
2019-11-25Revert "Use InitLLVM to setup a pretty stack printer"Nico Weber1-2/+1
This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea. Breaks at least these tests on Windows: Clang :: Driver/clang-offload-bundler.c Clang :: Driver/clang-offload-wrapper.c
2019-11-26Use InitLLVM to setup a pretty stack printerRui Ueyama1-1/+2
InitLLVM does not only save a few lines from main() but also makes the commands do the right thing for multibyte character pathnames on Windows (i.e. canonicalize argv's to UTF-8) because of the code we have in this file: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32 For many LLVM commands, we already have calls of InitLLVM, but there are still remainings. Differential Revision: https://reviews.llvm.org/D70702
2019-10-04[clang-tools-extra] [cmake] Link against libclang-cpp whenever possibleMichal Gorny1-2/+5
Use clang_target_link_libraries() in order to support linking against libclang-cpp instead of static libraries. Differential Revision: https://reviews.llvm.org/D68448 llvm-svn: 373786
2019-10-04[clang-tools-extra] [cmake] Use add_clang_tool() to install toolsMichal Gorny1-3/+1
Replace add_clang_executable() calls with add_clang_tool() that takes care of creating correct, distribution-friendly install target. While at it, remove redundant install calls. This change also causes clang-move and pp-trace to be installed. Differential Revision: https://reviews.llvm.org/D68423 llvm-svn: 373694
2019-08-22Remove \brief commands from doxygen comments.Dmitri Gribenko1-1/+1
Summary: We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done [This is analogous to LLVM r331272 and CFE r331834] Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66578 llvm-svn: 369643
2019-03-20gn build: Add build files for some clang-tools-extraNico Weber1-1/+3
Adds clang-change-namespace, clang-move, clang-query, clang-reorder-fields. Differential Revision: https://reviews.llvm.org/D59554 llvm-svn: 356567
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth6-24/+18
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2019-01-10Remove unnecessary include.Richard Trieu1-1/+0
QuerySession.h does not need anything from Query.h, so it does not need to include it. llvm-svn: 350797
2019-01-08[Query] NFC: Port QueryParser to StringRefStephen Kelly2-29/+19
Summary: There is no reason for it to not be a StringRef. Making it one simplifies existing code, and makes follow-up features easier. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56415 llvm-svn: 350660
2018-12-12Add explicit dependency on clangSerialization after rC348911Fangrui Song2-0/+2
llvm-svn: 348916
2018-12-05[clang-query] Continue if compilation command not found for some filesGeorge Karpenkov1-2/+13
When searching for a code pattern in an entire project with a compilation database it's tempting to run ``` clang-query **.cpp ``` And yet, that often breaks because some files are just not in the compilation database: tests, sample code, etc.. clang-query should not stop when encountering such cases. Differential Revision: https://reviews.llvm.org/D51183 llvm-svn: 348328
2018-10-29[clang-query] Add non-exclusive output APIStephen Kelly4-7/+69
Summary: Add granular options for AST dumping, text printing and diagnostics. This makes it possible to * Have both diag and dump active at once * Extend the output with other queryable content in the future. Reviewers: aaron.ballman, pcc, ioeric, ilya-biryukov, klimek, sammccall Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52857 llvm-svn: 345522
2018-10-24[clang-query] Refactor Output settings to booleansStephen Kelly4-11/+39
Summary: This will make it possible to add non-exclusive mode output. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53501 llvm-svn: 345194
2018-10-24[clang-query] Add 'detailed-ast' output as an alias for 'dump'Stephen Kelly3-6/+10
Summary: Future development can then dump other content than AST. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53500 llvm-svn: 345193
2018-10-24[clang-query] Re-word command helpStephen Kelly1-5/+11
Summary: This will make it possible to easily * Add new commands which accept <feature> parameters * Extend the list of features Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53498 llvm-svn: 345192
2018-10-20[clang-query] Add option to print matcher expressionStephen Kelly4-11/+34
Summary: This is useful if using clang-query -f with a file containing multiple matchers. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52859 llvm-svn: 344840
2018-10-03[clang-query] Add comment token handlingStephen Kelly1-0/+8
Summary: It is possible to pass a file of commands to clang-query using the command line option -f or --preload. Make it possible to write comments in such files. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D52752 llvm-svn: 343666
2018-10-03[clang-query] Add single-letter 'q' alias for 'quit'Stephen Kelly2-1/+2
Reviewers: aaron.ballman, pcc Reviewed By: aaron.ballman Subscribers: Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D52746 llvm-svn: 343664
2018-10-01[clang-query] Add missing 'l' command handlingStephen Kelly1-0/+1
The `let` command was added in commit 045c15ba (Add new 'let' command to bind arbitrary values into constants., 2014-04-23). The `let` command and the non-existant `l` command were documented in commit 233092a0 (Add 'let' to the help message., 2015-02-27). Implement the `l` command now for completeness. llvm-svn: 343533
2018-10-01[clang-query] Sort command optionsStephen Kelly1-2/+2
llvm-svn: 343532
2018-08-30Add preload option to clang-queryStephen Kelly1-0/+15
Summary: This allows loading a file with pre-defined let commands for example. Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51261 llvm-svn: 341145
2018-08-30Extract runCommandsInFile methodStephen Kelly1-12/+19
Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51260 llvm-svn: 341144