summaryrefslogtreecommitdiff
path: root/tools/clang-import-test
Commit message (Collapse)AuthorAgeFilesLines
* ArrayRef'ized CompilerInvocation::CreateFromArgsDmitri Gribenko2019-08-271-3/+1
| | | | | | | | | | Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66797 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370122 91177308-0d34-0410-b5e6-96231b3b80d8
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-11/+11
| | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368942 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang] Adopt new FileManager error-returning APIsHarlan Haskins2019-08-011-2/+2
| | | | | | | | 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> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367616 91177308-0d34-0410-b5e6-96231b3b80d8
* cmake: Add CLANG_LINK_CLANG_DYLIB optionTom Stellard2019-07-031-1/+1
| | | | | | | | | | | | | | | | Summary: Setting CLANG_LINK_CLANG_DYLIB=ON causes clang tools to link against libclang_shared.so instead of the individual component libraries. Reviewers: mgorny, beanz, smeenai, phosek, sylvestre.ledru Subscribers: arphaman, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63503 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365092 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce the ability to dump the AST to JSON.Aaron Ballman2019-05-131-2/+3
| | | | | | This adds the -ast-dump=json cc1 flag (in addition to -ast-dump=default, which is the default if no dump format is specified), as well as some initial AST dumping functionality and tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360622 91177308-0d34-0410-b5e6-96231b3b80d8
* Make SourceManager::createFileID(UnownedTag, ...) take a const ↵Nico Weber2019-04-041-1/+2
| | | | | | | | | | | | | | | | | | | | | llvm::MemoryBuffer* Requires making the llvm::MemoryBuffer* stored by SourceManager const, which in turn requires making the accessors for that return const llvm::MemoryBuffer*s and updating all call sites. The original motivation for this was to use it and fix the TODO in CodeGenAction.cpp's ConvertBackendLocation() by using the UnownedTag version of createFileID, and since llvm::SourceMgr* hands out a const llvm::MemoryBuffer* this is required. I'm not sure if fixing the TODO this way actually works, but this seems like a good change on its own anyways. No intended behavior change. Differential Revision: https://reviews.llvm.org/D60247 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357724 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix file headers. NFCFangrui Song2019-03-011-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355176 91177308-0d34-0410-b5e6-96231b3b80d8
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* Add explicit dependency on clangSerialization for a bunch of components to ↵Fangrui Song2018-12-121-0/+1
| | | | | | | | | | | | | | | fix -DBUILD_SHARED_LIBS=on build This is a more thorough fix of rC348911. The story about -DBUILD_SHARED_LIBS=on build after rC348907 (Move PCHContainerOperations from Frontend to Serialization) is: 1. libclangSerialization.so defines PCHContainerReader dtor, ... 2. clangFrontend and clangTooling define classes inheriting from PCHContainerReader, thus their DSOs have undefined references on PCHContainerReader dtor 3. Components depending on either clangFrontend or clangTooling cannot be linked unless they have explicit dependency on clangSerialization due to the default linker option -z defs. The explicit dependency could be avoided if libclang{Frontend,Tooling}.so had these undefined references. This patch adds the explicit dependency on clangSerialization to make them build. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348915 91177308-0d34-0410-b5e6-96231b3b80d8
* NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington2018-10-301-2/+1
| | | | | | | | | | We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345637 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASTImporter] Add test for C++'s try/catch statements.Raphael Isemann2018-08-201-0/+2
| | | | | | | | | | | | | | Summary: Also enable exceptions in clang-import-test so that we can parse the test files. Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50978 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340220 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASTImporter] Add test for C++ casts and fix broken const_cast importing.Raphael Isemann2018-08-201-0/+2
| | | | | | | | | | | | | | | | Summary: The ASTImporter does currently not handle const_casts. This patch adds the missing const_cast importer code and the test case that discovered this. Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50932 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340182 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix case of LLVM library names.Nico Weber2018-04-231-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330604 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow the creation of human-friendly ASTDumper to arbitrary output streamAlexander Kornienko2018-04-061-1/+2
| | | | | | | | | | | | | | | | | | | | | Summary: `ASTPrinter` allows setting the ouput to any O-Stream, but that printer creates source-code-like syntax (and is also marked with a `FIXME`). The nice, colourful, mostly human-readable `ASTDumper` only works on the standard output, which is not feasible in case a user wants to see the AST of a file through a code navigation/comprehension tool. This small addition of an overload solves generating a nice colourful AST block for the users of a tool I'm working on, [[ http://github.com/Ericsson/CodeCompass | CodeCompass ]], as opposed to having to duplicate the behaviour of definitions that only exist in the anonymous namespace of implementation TUs related to this module. Reviewers: alexfh, klimek, rsmith Reviewed By: alexfh Subscribers: rnkovacs, dkrupp, gsd, xazax.hun, cfe-commits, #clang Tags: #clang Patch by Whisperity! Differential Revision: https://reviews.llvm.org/D45096 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329391 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-import-test: fix build with clang-3.8Pavel Labath2018-03-131-1/+1
| | | | | | | | clang-3.8 complains that constructor for '...' must explicitly initialize the const object. Newer clangs and gcc seem to be fine with this, but explicitly initializing the variable does not hurt. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327383 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang-import-test] Run clang-format, NFCVedant Kumar2018-02-071-8/+9
| | | | | | | I ran across clang-import-test while looking into testing for lldb. There shouldn't be any harm in running clang-format over it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324527 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typos of occurred and occurrenceMalcolm Parsons2018-01-241-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323316 91177308-0d34-0410-b5e6-96231b3b80d8
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319840 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for remembering origins to ExternalASTMergerSean Callanan2017-09-271-58/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ExternalASTMerger has hitherto relied on being able to look up any Decl through its named DeclContext chain. This works for many cases, but causes problems for function-local structs, which cannot be looked up in their containing FunctionDecl. An example case is void f() { { struct S { int a; }; } { struct S { bool b; }; } } It is not possible to lookup either of the two Ses individually (or even to provide enough information to disambiguate) after parsing is over; and there is typically no need to, since they are invisible to the outside world. However, ExternalASTMerger needs to be able to complete either S on demand. This led to an XFAIL on test/Import/local-struct, which this patch removes. The way the patch works is: It defines a new data structure, ExternalASTMerger::OriginMap, which clients are expected to maintain (default-constructing if the origin does not have an ExternalASTMerger servicing it) As DeclContexts are imported, if they cannot be looked up by name they are placed in the OriginMap. This allows ExternalASTMerger to complete them later if necessary. As DeclContexts are imported from an origin that already has its own OriginMap, the origins are forwarded – but only for those DeclContexts that are actually used. This keeps the amount of stored data minimal. The patch also applies several improvements from review: - Thoroughly documents the interface to ExternalASTMerger; - Adds optional logging to help track what's going on; and - Cleans up a bunch of braces and dangling elses. Differential Revision: https://reviews.llvm.org/D38208 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314336 91177308-0d34-0410-b5e6-96231b3b80d8
* This adds the argument --dump-ir to clang-import-test, which allows Sean Callanan2017-08-071-3/+11
| | | | | | | | | | | | | | | | | | | | | | viewing of the final IR. This is useful for confirming that structure layout was correct. I've added two tests: - A test that checks that structs in top-level code are completed correctly during struct layout (they are) - A test that checks that structs defined in function bodies are cpmpleted correctly during struct layout (currently they are not, so this is XFAIL). The second test fails because LookupSameContext() (ExternalASTMerger.cpp) can't find the struct. This is an issue I intend to resolve separately. Differential Revision: https://reviews.llvm.org/D36429 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310318 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bot by linking clang-import-test against libclangDriverSean Callanan2017-07-251-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309018 91177308-0d34-0410-b5e6-96231b3b80d8
* [ExternalASTMerger] Import Objective-C classesSean Callanan2017-07-251-12/+27
| | | | | | | | | | | | | | This patch adds functionality and a test for importing Objective-C classes and their methods. It also adds a flag to clang-import-test to set the language used for parsing. This takes the same argument format as the -x option to the driver. Differential Revision: https://reviews.llvm.org/D35274 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309014 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang-import-test] Committed missed update to clang-import-test.cppSean Callanan2017-07-111-16/+2
| | | | | | | | | | I didn't commit clang-import-test.cpp in r307600, but it had some changes that were part of https://reviews.llvm.org/D35220 Corrected that now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307602 91177308-0d34-0410-b5e6-96231b3b80d8
* Preserve CXX method overrides in ASTImporterLang Hames2017-06-201-9/+23
| | | | | | | | | | | | | | Summary: The ASTImporter should import CXX method overrides from the source context when it imports a method decl. Reviewers: spyffe, rsmith, doug.gregor Reviewed By: spyffe Differential Revision: https://reviews.llvm.org/D34371 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305850 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASTImporter] Improve handling of incomplete typesSean Callanan2017-05-131-2/+44
| | | | | | | | | | | | | | | | | | | | | | ASTImporter has some bugs when it's importing types that themselves come from an ExternalASTSource. This is exposed particularly in the behavior when comparing complete TagDecls with forward declarations. This patch does several things: - Adds a test case making sure that conflicting forward-declarations are resolved correctly; - Extends the clang-import-test harness to test two-level importing, so that we make sure we complete types when necessary; and - Fixes a few bugs I found this way. Failure to complete types was one; however, I also discovered that complete RecordDecls aren't properly added to the redecls chain for existing forward declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302975 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang-import-test] Lookup inside contextsSean Callanan2017-04-111-52/+12
| | | | | | | | | | | | | | | | | | | | clang-import-test has until now been only able to report top-level Decls. This is clearly insufficient; we should be able to look inside structs and namespaces also. This patch adds new test cases for a variety of lookups inside existing ASTContexts, and adds the functionality necessar to make most of these testcases work. (One testcase is known to fail because of ASTImporter limitations when importing templates; I'll look into that separately.) This patch also separates the core functionality out into ExternalASTMerger, an interface that allows clients like LLDB to make use of it. clang-import-test now only has the machinery necessary to set up the tests. Differential revision: https://reviews.llvm.org/D30435 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299976 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase ↵David Blaikie2017-01-061-1/+1
| | | | | | | | | | | | | | and CodeCompleteConsumer" Aleksey Shlypanikov pointed out my mistake in migrating an explicit unique_ptr to auto - I was expecting the function returned a unique_ptr, but instead it returned a raw pointer - introducing a leak. Thanks Aleksey! This reapplies r291184, reverted in r291249. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291270 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and ↵David Blaikie2017-01-061-1/+1
| | | | | | | | | | CodeCompleteConsumer" Caused a memory leak reported by asan. Reverting while I investigate. This reverts commit r291184. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291249 91177308-0d34-0410-b5e6-96231b3b80d8
* IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and ↵David Blaikie2017-01-051-1/+1
| | | | | | CodeCompleteConsumer git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291184 91177308-0d34-0410-b5e6-96231b3b80d8
* Testbed and skeleton of a new expression parserSean Callanan2016-12-222-0/+346
| | | | | | | | | | | | | | | | | | | | | Recommitted after formal approval. LLVM's JIT is now the foundation of dynamic-compilation features for many languages. Clang also has low-level support for dynamic compilation (ASTImporter and ExternalASTSource, notably). How the compiler is set up for dynamic parsing is generally left up to individual clients, for example LLDB's C/C++/Objective-C expression parser and the ROOT project. Although this arrangement offers external clients the flexibility to implement dynamic features as they see fit, the lack of an in-tree client means that subtle bugs can be introduced that cause regressions in the external clients but aren't caught by tests (or users) until much later. LLDB for example regularly encounters complicated ODR violation scenarios where it is not immediately clear who is at fault. Other external clients (notably, Cling) rely on similar functionality, and another goal is to break this functionality up into composable parts so that any client can be built easily on top of Clang without requiring extensive additional code. I propose that the parts required to build a simple expression parser be added to Clang. Initially, I aim to have the following features: A piece that looks up external declarations from a variety of sources (e.g., from previous dynamic compilations, from modules, or from DWARF) and uses clear conflict resolution rules to reconcile differences, with easily understood errors. This functionality will be supported by in-tree tests. A piece that works hand in hand with the LLVM JIT to resolve the locations of external declarations so that e.g. variables can be redeclared and (for high-performance applications like DTrace) external variables can be accessed directly from the registers where they reside. This commit adds a tester that parses a sequence of source files and then uses them as source data for an expression. External references are resolved using an ExternalASTSource that responds to name queries using an ASTImporter. This is the setup that LLDB uses, and the motivating reason for MinimalImport in ASTImporter. When complete, this tester will implement the first of the above goals. Differential Revision: https://reviews.llvm.org/D27180 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290367 91177308-0d34-0410-b5e6-96231b3b80d8
* Reverting r290004, r290006, r290010 pending review.Sean Callanan2016-12-192-346/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290130 91177308-0d34-0410-b5e6-96231b3b80d8
* Added clangLex to the dependencies for clang-import-test.Sean Callanan2016-12-161-0/+1
| | | | | | | This is part of the effort to get the i686-mingw32-RA-on-linux bot to like clang-import-test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290010 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed library dependencies on clang-import-test to clean up the bots.Sean Callanan2016-12-161-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290006 91177308-0d34-0410-b5e6-96231b3b80d8
* Testbed and skeleton of a new expression parserSean Callanan2016-12-162-0/+343
LLVM's JIT is now the foundation of dynamic-compilation features for many languages. Clang also has low-level support for dynamic compilation (ASTImporter and ExternalASTSource, notably). How the compiler is set up for dynamic parsing is generally left up to individual clients, for example LLDB's C/C++/Objective-C expression parser and the ROOT project. Although this arrangement offers external clients the flexibility to implement dynamic features as they see fit, the lack of an in-tree client means that subtle bugs can be introduced that cause regressions in the external clients but aren't caught by tests (or users) until much later. LLDB for example regularly encounters complicated ODR violation scenarios where it is not immediately clear who is at fault. Other external clients (notably, Cling) rely on similar functionality, and another goal is to break this functionality up into composable parts so that any client can be built easily on top of Clang without requiring extensive additional code. I propose that the parts required to build a simple expression parser be added to Clang. Initially, I aim to have the following features: - A piece that looks up external declarations from a variety of sources (e.g., from previous dynamic compilations, from modules, or from DWARF) and uses clear conflict resolution rules to reconcile differences, with easily understood errors. This functionality will be supported by in-tree tests. - A piece that works hand in hand with the LLVM JIT to resolve the locations of external declarations so that e.g. variables can be redeclared and (for high-performance applications like DTrace) external variables can be accessed directly from the registers where they reside. This commit adds a tester that parses a sequence of source files and then uses them as source data for an expression. External references are resolved using an ExternalASTSource that responds to name queries using an ASTImporter. This is the setup that LLDB uses, and the motivating reason for MinimalImport in ASTImporter. When complete, this tester will implement the first of the above goals. Differential Revision: https://reviews.llvm.org/D27180 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290004 91177308-0d34-0410-b5e6-96231b3b80d8