aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/ASTMatchers/Dynamic/Parser.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-15[clang-query] Allow for trailing comma in matchers (#148018)Remy Farley1-0/+10
Allow AST matches in clang-query to have a trailing comma at the end of matcher arguments. Makes it nicer to work with queries that span multiple lines. So, for example, the following is possible: ```clang-query match namedDecl( isExpansionInMainFile(), anyOf( varDecl().bind("var"), functionDecl().bind("func"), # enumDecl().bind("enum"), ), ) ```
2025-06-04[ASTMatchers] Remove unused includes (NFC) (#142407)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2023-12-27[clang] Use StringRef::ltrim (NFC)Kazu Hirata1-4/+2
2023-12-13[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)Kazu Hirata1-3/+3
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-01-14[clang] Remove remaining uses of llvm::Optional (NFC)Kazu Hirata1-1/+0
This patch removes several "using" declarations and #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14[clang] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-9/+8
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14[clang] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-03[clang] Use std::nullopt instead of None (NFC)Kazu Hirata1-2/+2
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-21Return None instead of Optional<T>() (NFC)Kazu Hirata1-2/+2
This patch replaces: return Optional<T>(); with: return None; to make the migration from llvm::Optional to std::optional easier. Specifically, I can deprecate None (in my source tree, that is) to identify all the instances of None that should be replaced with std::nullopt. Note that "return None" far outnumbers "return Optional<T>();". There are more than 2000 instances of "return None" in our source tree. All of the instances in this patch come from functions that return Optional<T> except Archive::findSym and ASTNodeImporter::import, where we return Expected<Optional<T>>. Note that we can construct Expected<Optional<T>> from any parameter convertible to Optional<T>, which None certainly is. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Differential Revision: https://reviews.llvm.org/D138464
2022-06-25[clang] Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+2
This patch replaces Optional::hasValue with the implicit cast to bool in conditionals only.
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata1-2/+2
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+2
2022-06-20[clang] Don't use Optional::hasValue (NFC)Kazu Hirata1-1/+1
2022-06-18[clang] Use value_or instead of getValueOr (NFC)Kazu Hirata1-1/+1
2021-12-24Use Optional::getValueOr (NFC)Kazu Hirata1-1/+1
2021-02-07Add clang-query support for mapAnyOfStephen Kelly1-12/+213
Differential Revision: https://reviews.llvm.org/D94880
2021-02-07[ASTMatchers] Extract parsing of bind token from the bind idStephen Kelly1-14/+23
This will be extended to be able to parse "with" for mapAnyOf in addition to "bind".
2021-02-07[ASTMatchers] Change internal method APIStephen Kelly1-11/+13
This will make it possible to parse matchers built dynamically.
2019-12-29Fix formatting in previous commitsStephen Kelly1-1/+2
2019-12-29Fix use of named values surrounded by newlines in clang-queryStephen Kelly1-7/+8
2019-12-29Fix handling of newlines in clang-queryStephen Kelly1-3/+1
Replace assert with diagnostic for missing newline.
2019-12-27Allow newlines in AST Matchers in clang-query filesStephen Kelly1-21/+55
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 Stepanov1-55/+21
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 Kelly1-21/+55
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 Kelly1-55/+21
This reverts commit 6a3ecf4dc7ec299394e71b3124df2b3a34ed4ac3.
2019-12-26Allow newlines in AST Matchers in clang-query filesStephen Kelly1-21/+55
Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
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
2018-10-03Allow comments with '#' in dynamic AST MatchersStephen Kelly1-0/+4
Summary: This is necessary for clang-query to be able to handle comments. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52751 llvm-svn: 343665
2018-09-30Use the container form llvm::sort(C, ...)Fangrui Song1-5/+5
There are a few leftovers of rC343147 that are not (\w+)\.begin but in the form of ([-[:alnum:]>.]+)\.begin or spanning two lines. Change them to use the container form in this commit. The 12 occurrences have been inspected manually for safety. llvm-svn: 343425
2018-08-30Allow binding to NamedValue resulting from let expressionStephen Kelly1-2/+21
Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51259 llvm-svn: 341142
2018-08-30Extract parseBindID methodStephen Kelly1-31/+38
Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51258 llvm-svn: 341141
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-13/+13
This is similar to the LLVM change https://reviews.llvm.org/D46290. 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 for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-04-06Fix typos in clangAlexander Kornienko1-1/+1
Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
2018-03-27[clang] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang1-2/+2
r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. llvm-svn: 328636
2017-11-01[ASTMatchers] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko1-17/+26
warnings; other minor fixes (NFC). llvm-svn: 317137
2017-06-09[ASTMatchers] Fix use after free.Benjamin Kramer1-1/+2
Found by asan. llvm-svn: 305094
2017-06-08[ASTMatchers] Add support for floatLiteralsPeter Wu1-13/+37
Summary: Needed to support something like "floatLiteral(equals(1.0))". The parser for floating point numbers is kept simple, so instead of ".1" you have to use "0.1". Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33135 llvm-svn: 305021
2017-06-08[ASTMatchers] Add support for boolean literalsPeter Wu1-2/+10
Summary: Recognize boolean literals for future extensions ("equals(true)"). Note that a specific VariantValue constructor is added to resolve ambiguity (like "Value = 5") between unsigned and bool. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33093 llvm-svn: 305020
2016-07-18[NFC] Header cleanupMehdi Amini1-1/+0
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2015-10-20Roll-back r250822.Angel Garcia Gomez1-2/+2
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-2/+2
Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
2015-10-04SourceRanges are small and trivially copyable, don't them by reference.Craig Topper1-1/+1
llvm-svn: 249259
2015-07-06Replace some const std::string & with llvm::StringRef or std::stringYaron Keren1-1/+1
and std::move to avoid implicit std::string construction. Patch by Eugene Kosov. llvm-svn: 241433
2015-07-03Revert r241330. It compiled with Visual C++ 2013 and gcc 4.9.1 (mingw) but ↵Yaron Keren1-1/+1
now fails the bots. llvm-svn: 241335
2015-07-03Replace some const std::string & with llvm::StringRef or std::stringYaron Keren1-1/+1
and std::move to avoid implicit std::string construction. Patch by Eugene Kosov. llvm-svn: 241330
2015-07-03Revert r241319, investigating.Yaron Keren1-1/+1
llvm-svn: 241321
2015-07-03Replace some const std::string & with llvm::StringRef or std::stringYaron Keren1-1/+1
and std::move to avoid implicit std::string construction. Part 1/2. Patch by Eugene Kosov. llvm-svn: 241319
2014-08-12Support named values in the autocomplete feature.Samuel Benzaquen1-34/+71
Summary: This includes: - Passing a Sema to completeExpression to allow for named values in the expression. - Passing a map of names to values to the parser. - Update the Sema interface to include completion for matchers. - Change the parser to use the Sema for completion, instead of going directly to Registry. Reviewers: pcc Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D3509 llvm-svn: 215472
2014-05-17[C++11] Use 'nullptr'. ASTMatchers edition.Craig Topper1-4/+4
llvm-svn: 209070