summaryrefslogtreecommitdiffstats
path: root/clang/lib/CrossTU
Commit message (Collapse)AuthorAgeFilesLines
* [CrossTU] Fix problem with CrossTU AST load limit and progress messages.Balazs Keri2019-08-121-32/+26
| | | | | | | | | | | | | | | | | | | Summary: Number of loaded ASTs is to be incremented only if the AST was really loaded but not if it was returned from cache. At the same place the message about a loaded AST is displayed. Reviewers: martong, gamesh411 Reviewed By: martong Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66054 llvm-svn: 368545
* [CrossTU] Handle case when no USR could be generated during Decl search.Balazs Keri2019-08-061-9/+11
| | | | | | | | | | | | | | | | | | | 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
* [clang][NFC] Remove unused private variable 'CI' in CrossTranslationUnit.hRaphael Isemann2019-08-051-1/+1
| | | | | | | | | | | | | | It seems because of the recent refactorings this variable has become unused and now we get this warning in the build logs: In file included from llvm/clang/lib/CrossTU/CrossTranslationUnit.cpp:12: llvm/clang/include/clang/CrossTU/CrossTranslationUnit.h:200:21: warning: private field 'CI' is not used [-Wunused-private-field] CompilerInstance &CI; ^ I'll remove them for now to get the builds back to green. llvm-svn: 367840
* [CrossTU][NFCI] Refactor loadExternalAST functionEndre Fulop2019-08-051-52/+141
| | | | | | | | | | | | | | | | Summary: Refactor loadExternalAST method of CrossTranslationUnitContext in order to reduce maintenance burden and so that features are easier to add in the future. Reviewers: martong Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64753 llvm-svn: 367829
* [CrossTU] Add a function to retrieve original source location.Balazs Keri2019-07-241-8/+38
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: A new function will be added to get the original SourceLocation for a SourceLocation that was imported as result of getCrossTUDefinition. The returned SourceLocation is in the context of the (original) SourceManager for the original source file. Additionally the ASTUnit object for that source file is returned. This is needed to get a SourceManager to operate on with the returned source location. The new function works if multiple different source files are loaded with the same CrossTU context. Reviewers: martong, shafik Reviewed By: martong Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65064 llvm-svn: 366884
* Revert r366449: [CrossTU] Add a function to retrieve original source location.Ilya Biryukov2019-07-181-39/+11
| | | | | | | | Reason: the commit breaks layering by adding a dependency on ASTUnit (which is inside clangFrontend) from the ASTImporter (which is inside clangAST). llvm-svn: 366453
* [CrossTU] Add a function to retrieve original source location.Balazs Keri2019-07-181-11/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: A new function will be added to get the original SourceLocation for a SourceLocation that was imported as result of getCrossTUDefinition. The returned SourceLocation is in the context of the (original) SourceManager for the original source file. Additionally the ASTUnit object for that source file is returned. This is needed to get a SourceManager to operate on with the returned source location. The new function works if multiple different source files are loaded with the same CrossTU context. This patch can be treated as part of a bigger change that is needed to improve macro expansion handliong at plist generation. Reviewers: martong, shafik, a_sidorin, xazax.hun Reviewed By: martong Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64554 llvm-svn: 366449
* [analyzer] Add analyzer option to limit the number of imported TUsEndre Fulop2019-07-081-3/+16
| | | | | | | | | | | | Summary: During CTU analysis of complex projects, the loaded AST-contents of imported TUs can grow bigger than available system memory. This option introduces a threshold on the number of TUs to be imported for a single TU in order to prevent such cases. Differential Revision: https://reviews.llvm.org/D59798 llvm-svn: 365314
* [ASTImporter] Mark erroneous nodes in shared stGabor Marton2019-07-011-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Now we store the errors for the Decls in the "to" context too. For that, however, we have to put these errors in a shared state (among all the ASTImporter objects which handle the same "to" context but different "from" contexts). After a series of imports from different "from" TUs we have a "to" context which may have erroneous nodes in it. (Remember, the AST is immutable so there is no way to delete a node once we had created it and we realized the error later.) All these erroneous nodes are marked in ASTImporterSharedState::ImportErrors. Clients of the ASTImporter may use this as an input. E.g. the static analyzer engine may not try to analyze a function if that is marked as erroneous (it can be queried via ASTImporterSharedState::getImportDeclErrorIfAny()). Reviewers: a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62376 llvm-svn: 364785
* [CTU] Add missing statisticsGabor Marton2019-06-281-2/+6
| | | | | | | | | | | | Reviewers: xazax.hun Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63878 llvm-svn: 364630
* [ASTImporter] Use llvm::Expected and Error in the importer APIGabor Marton2019-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: This is the final phase of the refactoring towards using llvm::Expected and llvm::Error in the ASTImporter API. This involves the following: - remove old Import functions which returned with a pointer, - use the Import_New functions (which return with Err or Expected) everywhere and handle their return value - rename Import_New functions to Import This affects both Clang and LLDB. Reviewers: shafik, teemperor, aprantl, a_sidorin, balazske, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits, lldb-commits Tags: #clang, #lldb Differential Revision: https://reviews.llvm.org/D61438 llvm-svn: 360760
* [analyzer][CrossTU] Extend CTU to VarDecls with initializerRafael Stahl2019-04-231-41/+92
| | | | | | | | | | | | | | | | | | | | | | Summary: The existing CTU mechanism imports `FunctionDecl`s where the definition is available in another TU. This patch extends that to VarDecls, to bind more constants. - Add VarDecl importing functionality to CrossTranslationUnitContext - Import Decls while traversing them in AnalysisConsumer - Add VarDecls to CTU external mappings generator - Name changes from "external function map" to "external definition map" Reviewers: NoQ, dcoughlin, xazax.hun, george.karpenkov, martong Reviewed By: xazax.hun Subscribers: Charusso, baloghadamsoftware, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, george.karpenkov, mgorny, whisperity, szepet, rnkovacs, a.sidorin, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D46421 llvm-svn: 358968
* Changed every use of ASTImporter::Import to Import_NewBalazs Keri2019-04-081-5/+20
| | | | | | | | | | | | | | Reviewers: a.sidorin, shafik, martong, a_sidorin Reviewed By: a_sidorin Subscribers: rnkovacs, dkrupp, martong, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D55049 llvm-svn: 357913
* [CTU] Do not allow different CPP dialects in CTUGabor Marton2019-02-281-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If CPP dialects are different then return with error. Consider this STL code: template<typename _Alloc> struct __alloc_traits #if __cplusplus >= 201103L : std::allocator_traits<_Alloc> #endif { // ... }; This class template would create ODR errors during merging the two units, since in one translation unit the class template has a base class, however in the other unit it has none. Reviewers: xazax.hun, a_sidorin, r.stahl Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57906 llvm-svn: 355096
* 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. llvm-svn: 351636
* [analyzer][CrossTU][NFC] Generalize to external definitions instead of ↵Rafael Stahl2019-01-101-7/+7
| | | | | | | | | | | | | | | | external functions Summary: This is just changing naming and documentation to be general about external definitions that can be imported for cross translation unit analysis. There is at least a plan to add VarDecls: D46421 Reviewers: NoQ, xazax.hun, martong, a.sidorin, george.karpenkov, serge-sans-paille Reviewed By: xazax.hun, martong Subscribers: mgorny, whisperity, baloghadamsoftware, szepet, rnkovacs, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D56441 llvm-svn: 350852
* [CTU] Make loadExternalAST return with non nullptr on successGabor Marton2019-01-071-3/+3
| | | | | | | | | | | | | | | Summary: In loadExternalAST we return with either an error or with a valid ASTUnit pointer which should not be a nullptr. This prevents in the call site any superfluous check for being a nullptr. Reviewers: xazax.hun, a_sidorin, Szelethus, balazske Subscribers: rnkovacs, dkrupp, gamesh411, cfe-commits Differential Revision: https://reviews.llvm.org/D55280 llvm-svn: 350521
* [ASTImporter] Add importer specific lookupGabor Marton2018-12-171-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: There are certain cases when normal C/C++ lookup (localUncachedLookup) does not find AST nodes. E.g.: Example 1: template <class T> struct X { friend void foo(); // this is never found in the DC of the TU. }; Example 2: // The fwd decl to Foo is not found in the lookupPtr of the DC of the // translation unit decl. struct A { struct Foo *p; }; In these cases we create a new node instead of returning with the old one. To fix it we create a new lookup table which holds every node and we are not interested in any C++ specific visibility considerations. Simply, we must know if there is an existing Decl in a given DC. Reviewers: a_sidorin, a.sidorin Subscribers: mgorny, rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53708 llvm-svn: 349351
* Fix up diagnostics.Richard Trieu2018-12-141-3/+2
| | | | | | | | | | | Move some diagnostics around between Diagnostic*Kinds.td files. Diagnostics used in multiple places were moved to DiagnosticCommonKinds.td. Diagnostics listed in the wrong place (ie, Sema diagnostics listed in DiagnosticsParseKinds.td) were moved to the correct places. One diagnostic split into two so that the diagnostic string is in the .td file instead of in code. Cleaned up the diagnostic includes after all the changes. llvm-svn: 349125
* [CTU] Add triple/lang mismatch handlingGabor Marton2018-12-071-0/+65
| | | | | | | | | | | | | | | | | | Summary: We introduce a strict policy for C++ CTU. It can work across TUs only if the C++ dialects are the same. We neither allow C vs C++ CTU. We do this because the same constructs might be represented with different properties in the corresponding AST nodes or even the nodes might be completely different (a struct will be RecordDecl in C, but it will be a CXXRectordDecl in C++, thus it may cause certain assertions during cast operations). Reviewers: xazax.hun, a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Differential Revision: https://reviews.llvm.org/D55134 llvm-svn: 348610
* [CTU] Add more lit tests and better error handlingGabor Marton2018-12-071-1/+3
| | | | | | | | | | | | | | | Summary: Adding some more CTU list tests. E.g. to check if a construct is unsupported. We also slightly modify the handling of the return value of the `Import` function from ASTImporter. Reviewers: xazax.hun, balazske, a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Differential Revision: https://reviews.llvm.org/D55131 llvm-svn: 348605
* [CTU] Add DisplayCTUProgress analyzer switchGabor Marton2018-12-071-3/+9
| | | | | | | | | | | | | | | | Summary: With a new switch we may be able to print to stderr if a new TU is being loaded during CTU. This is very important for higher level scripts (like CodeChecker) to be able to parse this output so they can create e.g. a zip file in case of a Clang crash which contains all the related TU files. Reviewers: xazax.hun, Szelethus, a_sidorin, george.karpenkov Subscribers: whisperity, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, Differential Revision: https://reviews.llvm.org/D55135 llvm-svn: 348594
* [CTU] Add asserts to protect invariantsGabor Marton2018-12-071-0/+3
| | | | | | | | | | Reviewers: xazax.hun, a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Differential Revision: https://reviews.llvm.org/D55132 llvm-svn: 348586
* [CTU] Add statisticsGabor Marton2018-12-071-1/+15
| | | | | | | | | | Reviewers: xazax.hun, a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Differential Revision: https://reviews.llvm.org/D55133 llvm-svn: 348584
* [CrossTU] Fix handling of Cross Translation Unit directory pathGabor Horvath2017-10-271-4/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D38842 llvm-svn: 316764
* Fix implicit-fallthrough warning by adding missing breakSimon Pilgrim2017-09-241-0/+1
| | | | llvm-svn: 314079
* Fix unused variable warning in non-debug builds.Richard Trieu2017-09-221-1/+1
| | | | llvm-svn: 314035
* Add Cross Translation Unit support libraryGabor Horvath2017-09-222-0/+284
This patch introduces a class that can help to build tools that require cross translation unit facilities. This class allows function definitions to be loaded from external AST files based on an index. In order to use this functionality an index is required. The index format is a flat text file but it might be replaced with a different solution in the near future. USRs are used as names to look up the functions definitions. This class also does caching to avoid redundant loading of AST files. Right now only function defnitions can be loaded using this API because this is what the in progress cross translation unit feature of the Static Analyzer requires. In to future this might be extended to classes, types etc. Differential Revision: https://reviews.llvm.org/D34512 llvm-svn: 313975
OpenPOWER on IntegriCloud