summaryrefslogtreecommitdiffstats
path: root/clang/tools
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-scan-deps] add skip excluded conditional preprocessor block ↵Alex Lorenz2019-09-111-1/+10
| | | | | | | | | | | | | | | preprocessing optimization This commit adds an optimization to clang-scan-deps and clang's preprocessor that skips excluded preprocessor blocks by bumping the lexer pointer, and not lexing the tokens until reaching appropriate #else/#endif directive. The skip positions and lexer offsets are computed when the file is minimized, directly from the minimized tokens. On an 18-core iMacPro with macOS Catalina Beta I got 10-15% speed-up from this optimization when running clang-scan-deps on the compilation database for a recent LLVM and Clang (3511 files). Differential Revision: https://reviews.llvm.org/D67127 llvm-svn: 371656
* [Clang][Bundler] Replace std::vector by SmallVector [NFC]Sergey Dmitriev2019-09-111-6/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D67413 llvm-svn: 371637
* [Clang][Bundler] Fix for a potential memory leak [NFC]Sergey Dmitriev2019-09-111-16/+7
| | | | | | | | Bundler leaks memory if it is called with -type=o but given input isn't an object file (though it has to have a known binary type like IR, archive, etc...). Memory leak is happening when binary object returned by the createBinary(...) call cannot be casted to an ObjectFile type. In this case returned BinaryOrErr object releases ownership of the binary, but no one is taking it (see line 626). Differential Revision: https://reviews.llvm.org/D67416 llvm-svn: 371633
* libclang depends on ClangDriverOptions since r352803Nico Weber2019-09-061-1/+4
| | | | | | | | | | | | | | | | | | | | | Without this, the build would sometimes fail with In file included from clang/tools/libclang/CIndexer.cpp:17: In file included from clang/include/clang/Driver/Driver.h:15: clang/include/clang/Driver/Options.h:44:10: fatal error: 'clang/Driver/Options.inc' file not found #include "clang/Driver/Options.inc" ^~~~~~~~~~~~~~~~~ if Options.inc wasn't generated before libclang was built by coincidence. (In the GN build, this works because lib/Driver there declares the dep on tablegen as a public_dep since the generated file is part of Driver's public interface, and then things work out automatically without every client of Driver having to be careful.) llvm-svn: 371205
* [clang][Index] Replace CodegenNameGenerator with ASTNameGeneratorJan Korous2019-09-052-11/+11
| | | | | | | | Follow-up to: 3ff8c3b73f6, d5d15b4c1fd Should be NFC since the original patch just moved the code. llvm-svn: 371117
* [libclang] Refactored SharedParsedRegionsStorageDmitri Gribenko2019-09-051-24/+23
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Removed the `PPRegionSetTy` typedef because it is only used 3 times, and obscures code more than it helps. Renamed SharedParsedRegionsStorage to ThreadSafeParsedRegions, because that better reflects the reason for this type to exist. Replaced the `copyTo()` method that had an out parameter with a getter. Renamed the `merge()` method to `addParsedRegions()`. Renamed `ParsedSrcLocationsTracker::ParsedRegions` to `ParsedRegionsSnapshot`, which better reflects its role. Subscribers: arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67077 llvm-svn: 371041
* [analyzer] scan-build: handle --sysroot=/path in addition to --sysroot /path.Artem Dergachev2019-09-051-5/+8
| | | | | | | | | | | Current code assumes flags in CompilerLinkerOptionMap don't use =, which isn't always true. Patch by Chris Laplante! Differential Revision: https://reviews.llvm.org/D66569 llvm-svn: 371002
* [Driver] Use shared singleton instance of DriverOptTableIlya Biryukov2019-09-043-26/+28
| | | | | | | | | | | | | | | | | | | | | Summary: This significantly reduces the time required to run clangd tests, by ~10%. Should also have an effect on other tests that run command-line parsing multiple times inside a single invocation. Reviewers: gribozavr, sammccall Reviewed By: sammccall Subscribers: kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67163 llvm-svn: 370908
* [clang-scan-deps] NFC, refactor the DependencyScanningWorker to use a consumerAlex Lorenz2019-08-301-1/+57
| | | | | | | | | | | to report the dependencies to the client This will allow the scanner to report modular dependencies to the consumer. This will also allow the scanner to accept regular cc1 clang invocations, e.g. in an implementation of a libclang C API for clang-scan-deps, that I will add follow-up patches for in the future. llvm-svn: 370425
* [clang-scan-deps] reuse the file manager across invocations ofAlex Lorenz2019-08-291-1/+6
| | | | | | | | | | | | | | | | the dependency scanner on a single worker thread This behavior can be controlled using the new `-reuse-filemanager` clang-scan-deps option. By default the file manager is reused. The added test/ClangScanDeps/symlink.cpp is able to pass with the reused filemanager after the related FileEntryRef changes landed earlier. The test test/ClangScanDeps/subframework_header_dir_symlink.m still fails when the file manager is reused (I run the FileCheck with not to make it PASS). I will address this in a follow-up patch that improves the DirectoryEntry name modelling in the FileManager. llvm-svn: 370420
* Changed FrontendActionFactory::create to return a std::unique_ptrDmitri Gribenko2019-08-291-1/+3
| | | | | | | | | | Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66947 llvm-svn: 370379
* [Index] Added a ShouldSkipFunctionBody callback to libIndex, and refactored ↵Dmitri Gribenko2019-08-291-37/+35
| | | | | | | | | | | | clients to use it instead of inventing their own solution Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66879 llvm-svn: 370338
* [Index] Stopped wrapping FrontendActions in libIndex and its usersDmitri Gribenko2019-08-292-13/+15
| | | | | | | | | Exposed a new function, createIndexingASTConsumer, that creates an ASTConsumer. ASTConsumers compose well. Removed wrapping functionality from createIndexingAction. llvm-svn: 370337
* [Clang][Bundler] Do not require host triple for extracting device bundlesSergey Dmitriev2019-08-281-3/+6
| | | | | | | | Bundler currently requires host triple to be provided no matter if you are performing bundling or unbundling, but for unbundling operation such requirement is too restrictive. You may for example want to examine device part of the object for a particular offload target, but you have to extract host part as well even though you do not need it. Host triple isn't really needed for unbundling, so this patch removes that requirement. Differential Revision: https://reviews.llvm.org/D66601 llvm-svn: 370143
* [preprocessor] Add an opportunity to retain excluded conditional blocksEvgeny Mankov2019-08-272-1/+33
| | | | | | | | | | | | | | It is handy for clang tooling, for instance, in source to source transformation. Reviewers: vpykhtin (Valery Pykhtin), erichkeane (Erich Keane) Subscribers: rsmith (Richard Smith), akyrtzi (Argyrios Kyrtzidis) Tags: #clang Differential Revision: https://reviews.llvm.org/D66597 llvm-svn: 370123
* ArrayRef'ized CompilerInvocation::CreateFromArgsDmitri Gribenko2019-08-273-8/+5
| | | | | | | | | | Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66797 llvm-svn: 370122
* [Clang][Bundler] Fix for a hang when unbundling fat binarySergey Dmitriev2019-08-271-4/+5
| | | | | | | | clang-offload-bundler tool may hang under certain conditions when it extracts a subset of all available device bundles from the fat binary that is handled by the BinaryFileHandler. This patch fixes this problem. Differential Revision: https://reviews.llvm.org/D66598 llvm-svn: 370115
* [Clang][Bundler] Use llvm-objcopy for creating fat object filesSergey Dmitriev2019-08-262-119/+25
| | | | | | | | clang-offload-bundler currently uses partial linking for creating fat object files, but such technique cannot be used on Windows due to the absence of partial linking support in the linker. This patch changes implementation to use llvm-objcopy for merging device and host objects instead of doing partial linking. This is one step forward towards enabling OpenMP offload on Windows. Differential Revision: https://reviews.llvm.org/D66485 llvm-svn: 369955
* Improve behavior in the case of stack exhaustion.Richard Smith2019-08-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Clang performs various recursive operations (such as template instantiation), and may use non-trivial amounts of stack space in each recursive step (for instance, due to recursive AST walks). While we try to keep the stack space used by such steps to a minimum and we have explicit limits on the number of such steps we perform, it's impractical to guarantee that we won't blow out the stack on deeply recursive template instantiations on complex ASTs, even with only a moderately high instantiation depth limit. The user experience in these cases is generally terrible: we crash with no hint of what went wrong. Under this patch, we attempt to do better: * Detect when the stack is nearly exhausted, and produce a warning with a nice template instantiation backtrace, telling the user that we might run slowly or crash. * For cases where we're forced to trigger recursive template instantiation in arbitrarily-deeply-nested contexts, check whether we're nearly out of stack space and allocate a new stack (by spawning a new thread) after producing the warning. Reviewers: rnk, aaron.ballman Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66361 llvm-svn: 369940
* [libclang][index][NFCi] Refactor machinery for skipping function bodiesJan Korous2019-08-261-41/+65
| | | | | | | | | | | Refactor machinery for skipping inline function bodies that have already been parsed in other frontend actions. Preparations for moving this code to libIndex. Differential Revision: https://reviews.llvm.org/D66694 llvm-svn: 369931
* [analyzer] Analysis: Fix checker silencingCsaba Dabis2019-08-241-5/+8
| | | | llvm-svn: 369845
* [libclang][NFC] Remove debug commentJan Korous2019-08-221-3/+1
| | | | llvm-svn: 369714
* [analyzer] Analysis: Silence checkersCsaba Dabis2019-08-161-3/+15
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch introduces a new `analyzer-config` configuration: `-analyzer-config silence-checkers` which could be used to silence the given checkers. It accepts a semicolon separated list, packed into quotation marks, e.g: `-analyzer-config silence-checkers="core.DivideZero;core.NullDereference"` It could be used to "disable" core checkers, so they model the analysis as before, just if some of them are too noisy it prevents to emit reports. This patch also adds support for that new option to the scan-build. Passing the option `-disable-checker core.DivideZero` to the scan-build will be transferred to `-analyzer-config silence-checkers=core.DivideZero`. Reviewed By: NoQ, Szelethus Differential Revision: https://reviews.llvm.org/D66042 llvm-svn: 369078
* [Driver][Bundler] Improve bundling of object files.Alexey Bataev2019-08-151-26/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, object files were bundled using partial linking. It resulted in the following structure of the bundled objects: ``` <host_code> clang-offload-bundle __CLANG_OFFLOAD_BUNDLE__<target> <target_code> ``` But when we tried to unbundle object files, it worked correctly only for the target objects. The host object remains bundled. It produced a lot of junk sections in the host object files and in some cases may caused incorrect linking. Patch improves bundling of the object files. After this patch the bundled object looks like this: ``` <host_code> clang-offload-bundle __CLANG_OFFLOAD_BUNDLE__<target> <target_code> __CLANG_OFFLOAD_BUNDLE__<host> <host_code> ``` With this structure we are able to unbundle the host object files too so that after unbundling they are the same as were before. The host section is bundled twice. The bundled section is used to unbundle the original host section. Reviewers: yaxunl, tra, jlebar, hfinkel, jdoerfert Subscribers: caomhin, kkwli0, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65819 llvm-svn: 369019
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-1416-43/+43
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
* [clang] - An update after LLVM change.George Rimar2019-08-141-1/+4
| | | | | | SectionRef::getName() was changed to return Expected<> (D66089) llvm-svn: 368825
* Removed dead code from clang/tools/libclang/CXIndexDataConsumer.{cpp,h}Dmitri Gribenko2019-08-142-51/+0
| | | | | | | | | | | | Reviewers: jkorous Subscribers: dexonsmith, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66156 llvm-svn: 368805
* clang-scan-deps: do not spawn threads when LLVM_ENABLE_THREADS is disabledAlex Lorenz2019-08-131-19/+28
| | | | llvm-svn: 368640
* Add SVE opaque built-in typesRichard Sandiford2019-08-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the SVE built-in types defined by the Procedure Call Standard for the Arm Architecture: https://developer.arm.com/docs/100986/0000 It handles the types in all relevant places that deal with built-in types. At the moment, some of these places bail out with an error, including: (1) trying to generate LLVM IR for the types (2) trying to generate debug info for the types (3) trying to mangle the types using the Microsoft C++ ABI (4) trying to @encode the types in Objective C (1) and (2) are fixed by follow-on patches but (unlike this patch) they deal mostly with target-specific LLVM details, so seemed like a logically separate change. There is currently no spec for (3) and (4), so reporting an error seems like the correct behaviour for now. The intention is that the types will become sizeless types: http://lists.llvm.org/pipermail/cfe-dev/2019-June/062523.html The main purpose of the sizeless type extension is to diagnose impossible or dangerous uses of the types, such as any that would require sizeof to have a meaningful defined value. Until then, the patch sets the alignments of the types to the values specified in the link above. It also sets the sizes of the types to zero, which is chosen to be consistently wrong and shouldn't affect correctly-written code (i.e. code that would compile even with the sizeless type extension). The patch adds the common subset of functionality needed to test the sizeless type extension on the one hand and to provide SVE intrinsic functions on the other. After this patch, the two pieces of work are essentially independent. The patch is based on one by Graham Hunter: https://reviews.llvm.org/D59245 Differential Revision: https://reviews.llvm.org/D62960 llvm-svn: 368413
* [analyzer] Fix scan-build's plist output in plist-html mode.Artem Dergachev2019-08-081-1/+1
| | | | | | | r366941 accidentally made it delete all plist files as soon as they're produced. llvm-svn: 368338
* [clang] Add no-warn support for WaBrian Cain2019-08-081-0/+5
| | | | llvm-svn: 368328
* [llvm-mc] Add reportWarning() to MCContextBrian Cain2019-08-081-2/+2
| | | | | | | Adding reportWarning() to MCContext, so that it can be used from the Hexagon assembler backend. llvm-svn: 368327
* [diagtool] Use `operator<<(Colors)` to print out colored output.Rui Ueyama2019-08-081-36/+13
| | | | | | | | | | r368131 introduced this new API to print out messages in colors. If the colored output is disabled, `operator<<(Colors)` becomes nop. No functionality change intended. Differential Revision: https://reviews.llvm.org/D65854 llvm-svn: 368259
* Remove LLVM mutexes from clang in favor of std::mutexBenjamin Kramer2019-08-072-4/+3
| | | | | | | None of those need to be recursive mutexes. No functionality change intended. llvm-svn: 368173
* Replace non-recursive sys::Mutex users with std::mutexBenjamin Kramer2019-08-071-5/+3
| | | | | | | Also remove a use of sys::MutexImpl, that's just evil. No functionality change intended. llvm-svn: 368157
* Replace llvm::MutexGuard/UniqueLock with their standard equivalentsBenjamin Kramer2019-08-072-4/+4
| | | | | | | All supported platforms have <mutex> now, so we don't need our own copies any longer. No functionality change intended. llvm-svn: 368149
* Re-submit r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama2019-08-071-1/+2
| | | | | | | | | operator<< The original patch broke buildbots, perhaps because it changed the default setting whether colors are enabled or not. llvm-svn: 368131
* [clang-scan-deps] Implementation of dependency scanner over minimized sourcesAlex Lorenz2019-08-061-3/+21
| | | | | | | | | | | | | | | | | | | This commit implements the fast dependency scanning mode in clang-scan-deps: the preprocessing is done on files that are minimized using the dependency directives source minimizer. A shared file system cache is used to ensure that the file system requests and source minimization is performed only once. The cache assumes that the underlying filesystem won't change during the course of the scan (or if it will, it will not affect the output), and it can't be evicted. This means that the service and workers can be used for a single run of a dependency scanner, and can't be reused across multiple, incremental runs. This is something that we'll most likely support in the future though. Note that the driver still utilizes the underlying real filesystem. This commit is also still missing the fast skipped PP block skipping optimization that I mentioned at EuroLLVM talk. Additionally, the file manager is still not reused by the threads as well. Differential Revision: https://reviews.llvm.org/D63907 llvm-svn: 368086
* [CrossTU] Handle case when no USR could be generated during Decl search.Balazs Keri2019-08-061-2/+7
| | | | | | | | | | | | | | | | | | | Summary: When searching for a declaration to be loaded the "lookup name" for every other Decl is computed. If the USR can not be determined here should be not an assert, instead skip this Decl. Reviewers: martong Reviewed By: martong Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65445 llvm-svn: 368020
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-054-8/+8
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* Revert r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama2019-08-021-14/+34
| | | | | | | | operator<< This reverts commit r367649 in an attempt to unbreak Windows bots. llvm-svn: 367658
* Improve raw_ostream so that you can "write" colors using operator<<Rui Ueyama2019-08-021-34/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. raw_ostream supports ANSI colors so that you can write messages to the termina with colors. Previously, in order to change and reset color, you had to call `changeColor` and `resetColor` functions, respectively. So, if you print out "error: " in red, for example, you had to do something like this: OS.changeColor(raw_ostream::RED); OS << "error: "; OS.resetColor(); With this patch, you can write the same code as follows: OS << raw_ostream::RED << "error: " << raw_ostream::RESET; 2. Add a boolean flag to raw_ostream so that you can disable colored output. If you disable colors, changeColor, operator<<(Color), resetColor and other color-related functions have no effect. Most LLVM tools automatically prints out messages using colors, and you can disable it by passing a flag such as `--disable-colors`. This new flag makes it easy to write code that works that way. Differential Revision: https://reviews.llvm.org/D65564 llvm-svn: 367649
* [clang] Adopt new FileManager error-returning APIsHarlan Haskins2019-08-017-14/+20
| | | | | | | Update the callers of FileManager::getFile and FileManager::getDirectory to handle the new llvm::ErrorOr-returning methods. Signed-off-by: Harlan Haskins <harlan@apple.com> llvm-svn: 367616
* Fix exporting SARIF files from scan-build on Windows.Aaron Ballman2019-07-241-2/+2
| | | | | | | | In Perl, -z is defined as checking if a "file has zero size" and makes no mention what it does when given a directory. It looks like the behavior differs across platforms, which is why on Windows the SARIF file was always being deleted. Patch by Joe Ranieri. llvm-svn: 366941
* [Support] Fix `-ftime-trace-granularity` optionAnton Afanasyev2019-07-241-3/+4
| | | | | | | | | | | | | | | | Summary: Move `-ftime-trace-granularity` option to frontend options. Without patch this option is showed up in the help for any tool that links libSupport. Reviewers: sammccall Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D65202 llvm-svn: 366911
* Improve clang-format-diff help outputNico Weber2019-07-231-8/+4
| | | | | | | | | The description in clang-format-diff.py is more useful than the one in `clang-format-diff -h`, so use the same description in both places. Differential Revision: https://reviews.llvm.org/D64998 llvm-svn: 366828
* [clang-scan-view] Force utf-8 when handling report (python2 only)Serge Guelton2019-07-161-2/+2
| | | | | | | | Original patch by random human <random.bored.human@gmail.com> Differential Revision: https://reviews.llvm.org/D64129 llvm-svn: 366194
* [clang-fuzzer] Remove 'setUseOrcMCJITReplacement(false)' call.Lang Hames2019-07-151-1/+0
| | | | | | | | The default value for this option (UseMCJITReplacement) is already false, and OrcMCJITReplacement is going to have deprecation warnings attached in LLVM 9.0. Removing this call removes a spurious warning. llvm-svn: 366141
* Revert [clang-shlib] Fix clang-shlib for PRIVATE dependenciesShoaib Meenai2019-07-121-29/+2
| | | | | | | | This reverts r365825 (git commit 3173c60f96c3ccfc17d403a192ae58e720153c23) This is breaking BUILD_SHARED_LIBS=ON builds. Reverting while I rethink it. llvm-svn: 365922
* cmake: Fix install of libclang-cpp.so when LLVM_INSTALL_TOOLCHAIN_ONLY=ONTom Stellard2019-07-121-0/+5
| | | | | | | | | | | | | | | | | | | | | Summary: If CLANG_LINK_CLANG_DYLIB is also enabled, then this library needs to be installed. Fixes PR42575. Reviewers: beanz, smeenai Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64582 Conflicts: clang/tools/clang-shlib/CMakeLists.txt llvm-svn: 365905
OpenPOWER on IntegriCloud