aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/ExtractAPI
AgeCommit message (Collapse)AuthorFilesLines
2023-01-14[clang] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata2-15/+17
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-20[Support] Move TargetParsers to new componentArchibald Elliott1-0/+1
This is a fairly large changeset, but it can be broken into a few pieces: - `llvm/Support/*TargetParser*` are all moved from the LLVM Support component into a new LLVM Component called "TargetParser". This potentially enables using tablegen to maintain this information, as is shown in https://reviews.llvm.org/D137517. This cannot currently be done, as llvm-tblgen relies on LLVM's Support component. - This also moves two files from Support which use and depend on information in the TargetParser: - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting the current Host machine for info about it, primarily to support getting the host triple, but also for `-mcpu=native` support in e.g. Clang. This is fairly tightly intertwined with the information in `X86TargetParser.h`, so keeping them in the same component makes sense. - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains the target triple parser and representation. This is very intertwined with the Arm target parser, because the arm architecture version appears in canonical triples on arm platforms. - I moved the relevant unittests to their own directory. And so, we end up with a single component that has all the information about the following, which to me seems like a unified component: - Triples that LLVM Knows about - Architecture names and CPUs that LLVM knows about - CPU detection logic for LLVM Given this, I have also moved `RISCVISAInfo.h` into this component, as it seems to me to be part of that same set of functionality. If you get link errors in your components after this patch, you likely need to add TargetParser into LLVM_LINK_COMPONENTS in CMake. Differential Revision: https://reviews.llvm.org/D137838
2022-12-17llvm::Optional::value => operator*/operator->Fangrui Song1-2/+2
std::optional::value() has undesired exception checking semantics and is unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The call sites block std::optional migration. This makes `ninja clang` work in the absence of llvm::Optional::value.
2022-12-16[clang][ExtractAPI] Fix naming of typedef'd anonymous enumsDaniel Grumberg1-2/+8
Anonymous enums that are typedef'd should take on the name of the typedef. Differential Revision: https://reviews.llvm.org/D140010
2022-12-13[clang][ExtractAPI] Add support for single symbol SGF and libclang supportDaniel Grumberg8-660/+932
This is mainly adding an entry point to `SymbolGraphSerializer` at `serializeSingleSymbolSGF` and exposing the necessary data to make this possible. Additionaly there are some changes to how symbol kinds and path components are serialized to make the usage more ergonomic in `serializeSingleSymbolSGF`. On the libclang side this introduces APIs to: - create an APISet from a TU - dispose of an APISet - query an APISet for a single symbol SGF for a given USR. - generate a single symbol SGF for a given CXCursor, this only traverses the necessary AST nodes to construct the result as oppposed as going through the entire AST. Differential Revision: https://reviews.llvm.org/D139115
2022-12-09[ExtractAPI] Use std::optional in ExtractAPIConsumer.cpp (NFC)Kazu Hirata1-3/+4
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-09[clang] Use std::nullopt instead of None in comments (NFC)Kazu Hirata1-9/+9
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 Hirata2-9/+9
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-08Fix duplicate word typos; NFCRageking81-1/+1
This revision fixes typos where there are 2 consecutive words which are duplicated. There should be no code changes in this revision (only changes to comments and docs). Do let me know if there are any undesirable changes in this revision. Thanks.
2022-11-07Revert "Only add targetFallback if target is not in defined in current product"Daniel Grumberg2-37/+1
This was an accidental addition of a non-reviewed change. This reverts commit f63db9159bbbb0db98e13cb4440fdaa5c40e219b.
2022-11-07Only add targetFallback if target is not in defined in current productDaniel Grumberg2-1/+37
2022-11-07[clang][ExtractAPI] Add targetFallback to relationships in symbol graphDaniel Grumberg1-0/+1
Adds a 'targetFallback' field to relationships in symbol graph that contains the plain name of the relationship target. This is useful for clients when the relationship target symbol is not available. Differential Revision: https://reviews.llvm.org/D136455
2022-10-25[clang][ExtractAPI] Allow users to specify a list of symbols to ignoreDaniel Grumberg4-1/+75
Adds a `--extract-api-ignores=` command line option that allows users to provide a file containing a new line separated list of symbols to unconditionally ignore when extracting API information. Differential Revision: https://reviews.llvm.org/D136450
2022-10-13[clang][ExtractAPI] Ignore fully anonymous RecordDeclsDaniel Grumberg1-0/+3
ExtractAPI was emitting a separate symbol for anonymous record declaration that define the type of a member of another record declaration. Now ExtractAPI ignores these declarations and just records the existence of the actual member. Differential Revision: https://reviews.llvm.org/D135804
2022-10-05[clang][ExtractAPI] Don't print locations for anonymous tagsZixu Wang1-0/+5
ExtractAPI doesn't care about locations of anonymous TagDecls. Set the printing policy to exclude that from anonymous decl names. Differential Revision: https://reviews.llvm.org/D135295
2022-08-19[clang][ExtractAPI] Record availability information on all platformsDaniel Grumberg5-144/+176
Currently ExtractAPI only emits availability information for the current platform. This makes it easy for clients to get all availability information for a given symbol in one invocation as opposed to having to invoke clang once per-platform and then merge the symbol-graphs. Differential Revision: https://reviews.llvm.org/D130918
2022-08-08[clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song1-1/+1
With C++17 there is no Clang pedantic warning or MSVC C5051. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D131346
2022-08-07clang: fix typo availbilityAarush Bhat1-1/+1
- Fixes [[ https://github.com/llvm/llvm-project/issues/56787 | #56787 ]]. I am fixing the spelling of availability. I am unsure if this change will have any side effects. If someone can help on how to check if it has any side effects, I can test those out as well. Reviewed By: inclyc Differential Revision: https://reviews.llvm.org/D131277
2022-08-01Fixed a number of typosGabriel Ravier1-7/+7
I went over the output of the following mess of a command: (ulimit -m 2000000; ulimit -v 2000000; git ls-files -z | parallel --xargs -0 cat | aspell list --mode=none --ignore-case | grep -E '^[A-Za-z][a-z]*$' | sort | uniq -c | sort -n | grep -vE '.{25}' | aspell pipe -W3 | grep : | cut -d' ' -f2 | less) and proceeded to spend a few days looking at it to find probable typos and fixed a few hundred of them in all of the llvm project (note, the ones I found are not anywhere near all of them, but it seems like a good start). Differential Revision: https://reviews.llvm.org/D130827
2022-07-27[clang][ExtractAPI] Ensure that class properties have a kind of "Type Property"Daniel Grumberg1-3/+8
Generated symbol graphs should distinguish between type properties and instance properties. Differential Revision: https://reviews.llvm.org/D130581
2022-07-27[clang][ExtractAPI] Add a space between type and name in property ↵Daniel Grumberg1-0/+1
declaration fragments Differential Revision: https://reviews.llvm.org/D130583
2022-07-22[NFC] Start saving InstantiatedFromDecl in non-template functionsErich Keane1-0/+1
In cases where a non-template function is defined inside a function template, we don't have information about the original uninstantiated version. In the case of concepts instantiation, we will need the ability to get back to the original template. This patch splits a piece of the deferred concepts instantaition patch off to accomplish the storage of this, with minor runtime overhead, and zero additional storage.
2022-07-13[clang] Use value instead of getValue (NFC)Kazu Hirata1-2/+2
2022-07-01Revert "Re-apply "Deferred Concept Instantiation Implementation"""Erich Keane1-1/+0
This reverts commit befa8cf087dbb8159a4d9dc8fa4d6748d6d5049a. Apparently this breaks some libc++ builds with an apparent assertion, so I'm looking into that .
2022-07-01Re-apply "Deferred Concept Instantiation Implementation""Erich Keane1-0/+1
This reverts commit d4d47e574ecae562ab32f8ac7fa3f4d424bb6574. This fixes the lldb crash that was observed by ensuring that our friend-'template contains reference to' TreeTransform properly handles a TemplateDecl.
2022-06-30Revert "Deferred Concept Instantiation Implementation"Jonas Devlieghere1-1/+0
This reverts commit 2f207439521d62d9551b2884158368e8b34084e5 because it triggers an assertion when building an LLDB test program: Assertion failed: (InstantiatingSpecializations.empty() && "failed to clean up an InstantiatingTemplate?"), function ~Sema, file /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Sema/Sema.cpp, line 458. More details in https://reviews.llvm.org/D126907.
2022-06-30Deferred Concept Instantiation ImplementationErich Keane1-0/+1
This is a continuation of D119544. Based on @rsmith 's feed back showing me https://eel.is/c++draft/temp#friend-9, We should properly handle friend functions now. Differential Revision: https://reviews.llvm.org/D126907
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-18[clang] Use value_or instead of getValueOr (NFC)Kazu Hirata1-2/+2
2022-06-12[clang] Use any_of and none_of (NFC)Kazu Hirata1-5/+5
2022-05-25[clang][extract-api] Don't emit symbols prefixed with an underscoreDaniel Grumberg1-0/+5
These symbols are understood to not be used for client API consumption by convention so they should not appear in the generated symbol graph. Differential Revision: https://reviews.llvm.org/D125678
2022-05-09Revert ""Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation"""""Erich Keane1-1/+0
This reverts commit a425cac31e2e4cee8e14b7b9a99c8ba17c1ebb52. There is another libc++ test, that this time causes us to hit an assertion. Reverting, likely for a while this time.
2022-05-09"Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation""""Erich Keane1-0/+1
This includes a fix for the libc++ issue I ran across with friend declarations not properly being identified as overloads. This reverts commit 45c07db31cc76802a1a2e41bed1ce9c1b8198181.
2022-05-05[clang] Add static_cast to fix Bazel build.Adrian Kuegel1-1/+2
Differential Revision: https://reviews.llvm.org/D124995
2022-05-04Revert "Revert "[clang][extract-api] Use relative includes""Zixu Wang1-12/+178
Reapply the change after fixing sanitizer errors. The original problem was that `StringRef`s in `Matches` are pointing to temporary local `std::string`s created by `path::convert_to_slash` in the regex match call. This patch does the conversion up front in container `FilePath`. This reverts commit 2966f0fa505266735dbc8324b8821b7f0aa901ff. Differential Revision: https://reviews.llvm.org/D124964
2022-05-04Revert "[clang][extract-api] Use relative includes"Zixu Wang1-181/+12
This reverts commit 4c262fee08b5383c96857d77eefe80d61c41d2b0. Revert to fix Msan and Asan errors.
2022-05-04[clang][extract-api] Use relative includesZixu Wang1-12/+181
This patch transforms the given input headers to relative include names using header search entries and some heuritics. For example: `/Path/To/Header.h` will be included as `<Header.h>` with a search path of `-I /Path/To/`; and `/Path/To/Framework.framework/Headers/Header.h` will be included as `<Framework/Header.h>`, given a search path of `-F /Path/To`. Headermaps will also be queried in reverse to find a spelled name to include headers. Differential Revision: https://reviews.llvm.org/D123831
2022-05-02Revert "Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation"""Erich Keane1-1/+0
This reverts commit a97899108e495147985e5e9492e742d51d5cc97a. The patch caused some problems with the libc++ `__range_adaptor_closure` that I haven't been able to figure out the cause of, so I am reverting while I figure out whether this is a solvable problem/issue with the CFE, or libc++ depending on an older 'incorrect' behavior.
2022-05-02Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation""Erich Keane1-0/+1
This reverts commit 0c31da48389754822dc3eecc4723160c295b9ab2. I've solved the issue with the PointerUnion by making the `FunctionTemplateDecl` pointer be a NamedDecl, that could be a `FunctionDecl` or `FunctionTemplateDecl` depending. This is enforced with an assert.
2022-05-02Revert "Deferred Concept Instantiation Implementation"Erich Keane1-1/+0
This reverts commit 4b6c2cd647e9e5a147954886338f97ffb6a1bcfb. The patch caused numerous ARM 32 bit build failures, since we added a 5th item to the PointerUnion, and went over the 2-bits available in the 32 bit pointers.
2022-05-02Deferred Concept Instantiation ImplementationErich Keane1-0/+1
As reported here: https://github.com/llvm/llvm-project/issues/44178 Concepts are not supposed to be instantiated until they are checked, so this patch implements that and goes through significant amounts of work to make sure we properly re-instantiate the concepts correctly. Differential Revision: https://reviews.llvm.org/D119544
2022-04-28Frontend: Delete output streams before closing CompilerInstance outputsDuncan P. N. Exon Smith1-1/+1
Delete the output streams coming from CompilerInstance::createOutputFile() and friends once writes are finished. Concretely, replacing `OS->flush()` with `OS.reset()` in: - `ExtractAPIAction::EndSourceFileAction()` - `PrecompiledPreambleAction::setEmittedPreamblePCH()` - `cc1_main()'s support for `-ftime-trace` This fixes theoretical bugs related to proxy streams, which may have cleanups to run in their destructor. For example, a proxy that CompilerInstance sometimes uses is `buffer_ostream`, which wraps a `raw_ostream` lacking pwrite support and adds it. `flush()` does not promise that output is complete; `buffer_ostream` needs to wait until the destructor to forward anything so that it can service later calls to `pwrite()`. If the destructor isn't called then the proxied stream hasn't received any content. This also protects against some logic bugs, triggering a null dereference on a later attempt to write to the stream. No tests, since in practice these particular code paths never use use `buffer_ostream`; you need to be writing a binary file to a pipe (such as stdout) to hit it, but `-extract-api` writes a text file and the other two use computed filenames that will never (in practice) be a pipe. This is effectively NFC, for now. But I have some other patches in the works that add guard rails, crashing if the stream hasn't been destructed by the time the CompilerInstance is told to keep the output file, since in most cases this is a problem. Differential Revision: https://reviews.llvm.org/D124635
2022-04-12[clang][extract-api] Add support for true anonymous enumsDaniel Grumberg2-21/+24
Anonymous enums without a typedef should have a "(anonymous)" identifier. Differential Revision: https://reviews.llvm.org/D123533
2022-04-11[clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.Daniel Grumberg3-82/+93
- Split GlobalRecord into two distinct types to be able to introduce has_function_signature type trait. - Add has_function_signature type trait. - Serialize function signatures as part of serializeAPIRecord for records that are known to have a function signature. Differential Revision: https://reviews.llvm.org/D123304
2022-04-08[clang][extract-api] Emit "navigator" property of "name" in SymbolGraphDaniel Grumberg1-0/+7
Differential Revision: https://reviews.llvm.org/D123391
2022-04-07[clang][extract-api][NFC] Use dedicated API to check for macro equalityDaniel Grumberg1-8/+9
Differential Revision: https://reviews.llvm.org/D123295
2022-04-07[clang][ExtractAPI] Fix declaration fragments for ObjC methodsZixu Wang1-8/+9
Objective-C methods selector parts should be considered as identifiers. Depends on D123259 Differential Revision: https://reviews.llvm.org/D123261
2022-04-07[clang][extract-api] Process only APIs declared in inputsDaniel Grumberg1-7/+80
We should only process APIs declared in the command line inputs to avoid drowning the ExtractAPI output with symbols the user doesn't care about. This is achieved by keeping track of the provided input files and checking that the associated Decl or Macro is declared in one of those files. Differential Revision: https://reviews.llvm.org/D123148