summaryrefslogtreecommitdiffstats
path: root/clang/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [LibTooling] Relax Transformer to allow rewriting macro expansionsYitzhak Mandelbaum2019-07-181-22/+102
| | | | | | | | | | | | | | | | | | | | Summary: Currently, Transformer rejects any changes to source locations inside macro expansions. This change relaxes that constraint to allow rewrites when the entirety of the expansion is replaced, since that can be mapped to replacing the entirety of the expansion range in the file source. This change makes Transformer consistent with the handling of edit ranges in `clang::edit::Commit` (which is used, for example, for applying `FixItHint`s from diagnostics). Reviewers: ilya-biryukov Subscribers: gribozavr, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64518 llvm-svn: 366473
* [LibTooling] Add function to translate and validate source range for editingYitzhak Mandelbaum2019-07-181-2/+108
| | | | | | | | | | | | | | | | | Summary: Adds the function `getRangeForEdit` to validate that a given source range is editable and, if needed, translate it into a range in the source file (for example, if it's sourced in macro expansions). Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64924 llvm-svn: 366469
* Revert r366449: [CrossTU] Add a function to retrieve original source location.Ilya Biryukov2019-07-181-33/+6
| | | | | | | | 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-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ASTImporter] Fix structural eq of lambdasGabor Marton2019-07-172-0/+68
| | | | | | | | | | | | | | | | | | Summary: The structural equivalence check reported false eq between lambda classes with different parameters in their call signature. The solution is to check the methods for equality too in case of lambda classes. Reviewers: a_sidorin, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64075 llvm-svn: 366332
* [ASTImporter] Fix LLDB lookup in transparent ctx and with ext srcGabor Marton2019-07-171-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: With LLDB we use localUncachedLookup(), however, that fails to find Decls when a transparent context is involved and the given DC has external lexical storage. The solution is to use noload_lookup, which works well with transparent contexts. But, we cannot use only the noload_lookup since the slow case of localUncachedLookup is still needed in some other cases. These other cases are handled in ASTImporterLookupTable, but we cannot use that with LLDB since that traverses through the AST which initiates the load of external decls again via DC::decls(). We must avoid loading external decls during the import becuase ExternalASTSource is implemented with ASTImporter, so external loads during import results in uncontrolled and faulty import. Reviewers: shafik, teemperor, jingham, clayborg, a_sidorin, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits, lldb-commits Tags: #clang, #lldb Differential Revision: https://reviews.llvm.org/D61333 llvm-svn: 366325
* [clang-format] Don't detect call to ObjC class method as C++11 attribute ↵Ben Hamilton2019-07-161-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | specifier Summary: Previously, clang-format detected something like the following as a C++11 attribute specifier. @[[NSArray class]] instead of an array with an Objective-C method call inside. In general, when the attribute specifier checking runs, if it sees 2 identifiers in a row, it decides that the square brackets represent an Objective-C method call. However, here, `class` is tokenized as a keyword instead of an identifier, so this check fails. To fix this, the attribute specifier first checks whether the first square bracket has an "@" before it. If it does, then that square bracket is not the start of a attribute specifier because it is an Objective-C array literal. (The assumption is that @[[.*]] is not valid C/C++.) Contributed by rkgibson2. Reviewers: benhamilton Reviewed By: benhamilton Subscribers: aaron.ballman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64632 llvm-svn: 366267
* [DirectoryWatcher][test] Relax test assumptionsJan Korous2019-07-151-44/+20
| | | | | | | | | Workaround for FSEvents sometimes sending notifications for events that happened before DirectoryWatcher was created. This caused tests to be flaky on green dragon. llvm-svn: 366138
* [DirectoryWatcher][NFC][test] Add typedef for enumJan Korous2019-07-151-22/+23
| | | | llvm-svn: 366137
* [ASTImporter] Using Lang_CXX14 in ASTImporterVisibilityTest.Balazs Keri2019-07-151-17/+23
| | | | | | | | | | | | | | | | | | | | Summary: These tests may work with C++14 language constructs in the future (variable templates and others). To avoid warnings about language version C++ version constants in the tests are updated. Reviewers: martong, a.sidorin Reviewed By: martong Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64477 llvm-svn: 366061
* [DirectoryWatcher][test][NFC] Add information to test failure reportsJan Korous2019-07-131-2/+25
| | | | llvm-svn: 365976
* Re-land [JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from ↵Sam McCall2019-07-121-0/+27
| | | | | | | | parsed commands. Use //net/dir like other test cases for windows compatibility llvm-svn: 365975
* [DirectoryWatcher][NFC] Silence warnings in release buildJan Korous2019-07-121-3/+10
| | | | llvm-svn: 365968
* Reland [clang] DirectoryWatcherJan Korous2019-07-123-0/+444
| | | | | | | | | | This reverts commit f561227d133224d2d6a5a016abe4be051fa75501. - DirectoryWatcher - Fix the build for platforms that don't have DW implementated. - Fix the threading dependencies (thanks to compnerd). llvm-svn: 365954
* Revert "Reland [clang] DirectoryWatcher"Jan Korous2019-07-123-444/+0
| | | | | | This reverts commit fdcb7f47e783933e0af8a5fae91132269a208268. llvm-svn: 365948
* Reland [clang] DirectoryWatcherJan Korous2019-07-123-0/+444
| | | | | | | | This reverts commit abce8c457dd3de6b156756e547cc0eefb7653c79. + Fix the build for platforms that don't have DW implementated. llvm-svn: 365947
* Revert "[JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from ↵Russell Gallop2019-07-121-24/+0
| | | | | | | | | | parsed commands." New test is failing on Windows bot This reverts commit 9c0391b36a76f8e3949588de3f44b7314c2318bf. llvm-svn: 365906
* [JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from parsed ↵Sam McCall2019-07-121-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commands. Summary: It's common to use compiler wrappers by setting CC="gomacc clang++". This results in both args appearing in compile_commands.json, and clang's driver can't handle this. This patch attempts to recognize this pattern (by looking for well-known wrappers) and dropping argv0 in this case. It conservatively ignores other cases for now: - wrappers with unknown names - wrappers that accept -flags - wrappers where the compiler to use is implied (usually cc or gcc) This is done at the JSONCompilationDatabase level rather than somewhere more fundamental, as (hopefully) this isn't a general conceptual problem, but a messy aspect of the nature of the ecosystem around compile_commands.json. i.e. compilation databases more tightly tied to the build system should not have this problem. Reviewers: phosek, klimek Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64297 llvm-svn: 365887
* [test] Delete trailing spaces from YAML testsFangrui Song2019-07-124-16/+16
| | | | llvm-svn: 365873
* [clang-scan-deps] Dependency directives source minimizer:Alex Lorenz2019-07-101-0/+37
| | | | | | | | | | | | single quotes are not digit separators after a valid character literal prefix The single quote character can act as a c++ digit separator. However, the minimizer shouldn't treat it as such when it's actually following a valid character literal prefix, like L, U, u, or u8. Differential Revision: https://reviews.llvm.org/D64525 llvm-svn: 365700
* Revert [clang] DirectoryWatcherReid Kleckner2019-07-093-440/+0
| | | | | | This reverts r365574 (git commit 31babea94a3ed38a140540f2252cf043dacec1f7) llvm-svn: 365581
* [clang] DirectoryWatcherJan Korous2019-07-093-0/+440
| | | | | | | | | | Asynchronously monitors specified directory for changes and passes notifications to provided callback. Dependency for index-while-building. Differential Revision: https://reviews.llvm.org/D58418 llvm-svn: 365574
* [Syntax] Move roles into a separate enumIlya Biryukov2019-07-091-4/+4
| | | | | | To align with reviewer's suggestions. llvm-svn: 365479
* Reland r365355: [Syntax] Introduce syntax treesIlya Biryukov2019-07-092-0/+161
| | | | | | With a fix to a PS4 buildbot crash. llvm-svn: 365466
* Revert rL365355 : [Syntax] Introduce syntax treesSimon Pilgrim2019-07-092-161/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: A tooling-focused alternative to the AST. This commit focuses on the memory-management strategy and the structure of the AST. More to follow later: - Operations to mutate the syntax trees and corresponding textual replacements. - Mapping between clang AST nodes and syntax tree nodes. - More node types corresponding to the language constructs. Reviewers: sammccall Reviewed By: sammccall Subscribers: llvm-commits, mgorny, cfe-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61637 ........ Fixes buildbots which were crashing on SyntaxTests.exe llvm-svn: 365465
* [ASTImporter] Added visibility context check for EnumDecl.Balazs Keri2019-07-091-0/+65
| | | | | | | | | | | | | | | | | | | Summary: ASTImporter makes now difference between enums with same name in different translation units if these are not visible outside. ("Scoped enums" are not handled yet.) Reviewers: martong, a.sidorin, shafik, a_sidorin Reviewed By: a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62484 llvm-svn: 365464
* [Syntax] Introduce syntax treesIlya Biryukov2019-07-082-0/+161
| | | | | | | | | | | | | | | | | | | | | | | | Summary: A tooling-focused alternative to the AST. This commit focuses on the memory-management strategy and the structure of the AST. More to follow later: - Operations to mutate the syntax trees and corresponding textual replacements. - Mapping between clang AST nodes and syntax tree nodes. - More node types corresponding to the language constructs. Reviewers: sammccall Reviewed By: sammccall Subscribers: llvm-commits, mgorny, cfe-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61637 llvm-svn: 365355
* [ASTImporter] Fix import of lambda in function paramGabor Marton2019-07-081-0/+39
| | | | | | | | | | | | | | | | | | | | | Summary: The current import implementation fails to import the definition of a lambda class if the lambda class is defined in a function param. E.g., the lambda class below will be imported without any methods: ``` template <typename F> void f(F L = [](){}) {} ``` Reviewers: a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64073 llvm-svn: 365315
* [analyzer] Add analyzer option to limit the number of imported TUsEndre Fulop2019-07-081-7/+21
| | | | | | | | | | | | 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
* [Rewrite] Try to fix buildbot link fail left by r365263Joel E. Denny2019-07-061-0/+1
| | | | | | http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10272 llvm-svn: 365264
* [Rewrite] Try to fix buildbot link fail caused by r365258Joel E. Denny2019-07-061-0/+1
| | | | | | http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10270 llvm-svn: 365263
* [Rewrite] Extend to further accept CharSourceRangeJoel E. Denny2019-07-062-0/+82
| | | | | | | | | | | | | Some Rewrite functions are already overloaded to accept CharSourceRange, and this extends others in the same manner. I'm calling these in code that's not ready to upstream, but I figure they might be useful to others in the meantime. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D61467 llvm-svn: 365258
* Removed the test case added in D63538 due to windows buildbot failuresKristof Umann2019-07-051-38/+0
| | | | llvm-svn: 365209
* [analyzer][IDF] Add a control dependency calculator + a new debug checkerKristof Umann2019-07-051-0/+91
| | | | | | | | | | | | | | | | | | | | | | | I intend to improve the analyzer's bug reports by tracking condition expressions. 01 bool b = messyComputation(); 02 int i = 0; 03 if (b) // control dependency of the bug site, let's explain why we assume val 04 // to be true 05 10 / i; // warn: division by zero I'll detail this heuristic in the followup patch, strictly related to this one however: * Create the new ControlDependencyCalculator class that uses llvm::IDFCalculator to (lazily) calculate control dependencies for Clang's CFG. * A new debug checker debug.DumpControlDependencies is added for lit tests * Add unittests Differential Revision: https://reviews.llvm.org/D62619 llvm-svn: 365197
* Fix a buildbot failure due to the AST's lifetime ending before the testKristof Umann2019-07-051-17/+3
| | | | llvm-svn: 365181
* [analyzer][Dominators][NFC] Add unit testsKristof Umann2019-07-054-51/+174
| | | | | | Differential Revision: https://reviews.llvm.org/D62611 llvm-svn: 365179
* [CFG] Add a new function to get the proper condition of a CFGBlockKristof Umann2019-07-051-0/+52
| | | | | | | | | | | | | getTerminatorCondition() returned a condition that may be outside of the block, while the new function returns the proper one: if (A && B && C) {} Return C instead of A && B && C. Differential Revision: https://reviews.llvm.org/D63538 llvm-svn: 365177
* cmake: Add CLANG_LINK_CLANG_DYLIB optionTom Stellard2019-07-0319-22/+33
| | | | | | | | | | | | | | | | 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 llvm-svn: 365092
* [Bitcode] Move Bitstream to a separate libraryFrancis Visoiu Mistrih2019-07-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/. This is needed to avoid a circular dependency when using the bitstream code for parsing optimization remarks. Since Bitcode uses Core for the IR part: libLLVMRemarks -> Bitcode -> Core and Core uses libLLVMRemarks to generate remarks (see IR/RemarkStreamer.cpp): Core -> libLLVMRemarks we need to separate the Bitstream and Bitcode part. For clang-doc, it seems that it doesn't need the whole bitcode layer, so I updated the CMake to only use the bitstream part. Differential Revision: https://reviews.llvm.org/D63899 llvm-svn: 365091
* [clang-tidy] Fix the YAML created for checks like modernize-pass-by-valueIvan Donchevskii2019-07-031-0/+24
| | | | | | | | | | | Currently this check generates the replacement with the newline in the end. The proper way to export it to YAML is to have two \n\n instead of one. Without this fix clients should reinterpret the replacement as "#include <utility> " instead of "#include <utility>\n" Differential Revision: https://reviews.llvm.org/D63482 llvm-svn: 365017
* [clang][HeaderSearch] Shorten paths for includes in mainfile's directoryKadir Cetinkaya2019-07-031-9/+31
| | | | | | | | | | | | | | | | | | Summary: Currently HeaderSearch only looks at SearchDir's passed into it, but in addition to those paths headers can be relative to including file's directory. This patch makes sure that is taken into account. Reviewers: gribozavr Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63295 llvm-svn: 365005
* clang-format: Add new style option AlignConsecutiveMacrosSam McCall2019-07-021-0/+98
| | | | | | | | | | | | | | | | | | | | | | This option behaves similarly to AlignConsecutiveDeclarations and AlignConsecutiveAssignments, aligning the assignment of C/C++ preprocessor macros on consecutive lines. I've worked in many projects (embedded, mostly) where header files full of large, well-aligned "#define" blocks are a common pattern. We normally avoid using clang-format on these files, since it ruins any existing alignment in said blocks. This style option will align "simple" PP macros (no parameters) and PP macros with parameter lists on consecutive lines. Related Bugzilla entry (thanks mcuddie): https://llvm.org/bugs/show_bug.cgi?id=20637 Patch by Nick Renieris (VelocityRa)! Differential Revision: https://reviews.llvm.org/D28462 llvm-svn: 364938
* [LibTooling] Extend `RewriteRule` with support for adding includes.Yitzhak Mandelbaum2019-07-021-0/+36
| | | | | | | | | | | | | | | | | | Summary: This revision allows users to specify the insertion of an included directive (at the top of the file being rewritten) as part of a rewrite rule. These directives are bundled with `RewriteRule` cases, so that different cases can potentially result in different include actions. Reviewers: ilya-biryukov, gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63892 llvm-svn: 364917
* [clang][ArgumentAdjusters] Do not add fsyntax-only if already existsKadir Cetinkaya2019-07-021-0/+27
| | | | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64063 llvm-svn: 364904
* [ASTImporter] Structural eq: handle DependentScopeDeclRefExprGabor Marton2019-07-021-0/+138
| | | | | | | | | | | | | | | | Summary: Structural equivalence did not handle dependent template args properly when the arg contained a DependentScopeDeclRefExpr. Reviewers: a_sidorin, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62329 llvm-svn: 364889
* [analyzer] NFC: CallDescription: Implement describing C library functions.Artem Dergachev2019-07-011-0/+12
| | | | | | | | | | | | | | | | | | | When matching C standard library functions in the checker, it's easy to forget that they are often implemented as macros that are expanded to builtins. Such builtins would have a different name, so matching the callee identifier would fail, or may sometimes have more arguments than expected, so matching the exact number of arguments would fail, but this is fine as long as we have all the arguments that we need in their respective places. This patch adds a set of flags to the CallDescription class so that to handle various special matching rules, and adds the first flag into this set, which enables a more fuzzy matching for functions that may be implemented as compiler builtins. Differential Revision: https://reviews.llvm.org/D62556 llvm-svn: 364867
* [analyzer] NFC: Add a convenient CallDescriptionMap class.Artem Dergachev2019-07-013-6/+165
| | | | | | | | | | | | | | It encapsulates the procedure of figuring out whether a call event corresponds to a function that's modeled by a checker. Checker developers no longer need to worry about performance of lookups into their own custom maps. Add unittests - which finally test CallDescription itself as well. Differential Revision: https://reviews.llvm.org/D62441 llvm-svn: 364866
* [ASTImporter] Mark erroneous nodes in shared stGabor Marton2019-07-013-38/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ASTImporter] Mark erroneous nodes in from ctxGabor Marton2019-07-011-14/+197
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: During import of a specific Decl D, it may happen that some AST nodes had already been created before we recognize an error. In this case we signal back the error to the caller, but the "to" context remains polluted with those nodes which had been created. Ideally, those nodes should not had been created, but that time we did not know about the error, the error happened later. Since the AST is immutable (most of the cases we can't remove existing nodes) we choose to mark these nodes as erroneous. Here are the steps of the algorithm: 1) We keep track of the nodes which we visit during the import of D: See ImportPathTy. 2) If a Decl is already imported and it is already on the import path (we have a cycle) then we copy/store the relevant part of the import path. We store these cycles for each Decl. 3) When we recognize an error during the import of D then we set up this error to all Decls in the stored cycles for D and we clear the stored cycles. Reviewers: a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62375 llvm-svn: 364771
* [ASTImporter] Propagate error from ImportDeclContextGabor Marton2019-07-011-0/+87
| | | | | | | | | | | | | | | | | | | | | | Summary: During analysis of one project we failed to import one CXXDestructorDecl. But since we did not propagate the error in importDeclContext we had a CXXRecordDecl without a destructor. Then the analyzer engine had a CallEvent where the nonexistent dtor was requested (crash). Solution is to propagate the errors we have during importing a DeclContext. Reviewers: a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63603 llvm-svn: 364752
OpenPOWER on IntegriCloud