summaryrefslogtreecommitdiffstats
path: root/clang/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [CodeComplete] Propagate preferred types through parser in more casesIlya Biryukov2019-01-311-0/+99
| | | | | | | | | | | | | | Preferred types are used by code completion for ranking. This commit considerably increases the number of points in code where those types are propagated. In order to avoid complicating signatures of Parser's methods, a preferred type is kept as a member variable in the parser and updated during parsing. Differential revision: https://reviews.llvm.org/D56723 llvm-svn: 352788
* Accomodate gcc 7.3.0's -Wdangling-elseNico Weber2019-01-311-1/+2
| | | | llvm-svn: 352761
* [clang-format] Fix line parsing for noexcept lambdasBen Hamilton2019-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: > $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" |clang-format ``` int c = [b]() mutable noexcept { return [&b] { return b++; }(); } (); ``` with patch: > $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" |bin/clang-format ``` int c = [b]() mutable noexcept { return [&b] { return b++; }(); }(); ``` Contributed by hultman. Reviewers: benhamilton, jolesiak, klimek, Wizard Reviewed By: benhamilton Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56909 llvm-svn: 352622
* [Tooling] Handle #pragma once header guard in include insertion.Eric Liu2019-01-291-3/+11
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D57223 llvm-svn: 352503
* [ASTImporter] Fix handling of overriden methods during ASTImportShafik Yaghmour2019-01-281-0/+185
| | | | | | | | | Summary: When importing classes we may add a CXXMethodDecl more than once to a CXXRecordDecl when handling overrides. This patch will fix the cases we currently know about and handle the case where we are only dealing with declarations. Differential Revision: https://reviews.llvm.org/D56936 llvm-svn: 352436
* [AST] Add structural eq tests for template argsGabor Marton2019-01-281-0/+19
| | | | | | | | | | | | | | Summary: New tests added to verify equivalency of templates when their parameters are different. Reviewers: a_sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Differential Revision: https://reviews.llvm.org/D57235 llvm-svn: 352345
* [clang-format] square parens with one token are not Objective-C message sendsAlex Lorenz2019-01-241-0/+14
| | | | | | | | | | | | | | The commit r322690 introduced support for ObjC detection in header files. Unfortunately some C headers that use designated initializers are now incorrectly detected as Objective-C. This commit fixes it by ensuring that `[ token ]` is not annotated as an Objective-C message send. rdar://45504376 Differential Revision: https://reviews.llvm.org/D56226 llvm-svn: 352125
* [FileManager] Revert r347205 to avoid PCH file-descriptor leak.Sam McCall2019-01-241-27/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: r347205 fixed a bug in FileManager: first calling getFile(shouldOpen=false) and then getFile(shouldOpen=true) results in the file not being open. Unfortunately, some code was (inadvertently?) relying on this bug: when building with a PCH, the file entries are obtained first by passing shouldOpen=false, and then later shouldOpen=true, without any intention of reading them. After r347205, they do get unneccesarily opened. Aside from extra operations, this means they need to be closed. Normally files are closed when their contents are read. As these files are never read, they stay open until clang exits. On platforms with a low open-files limit (e.g. Mac), this can lead to spurious file-not-found errors when building large projects with PCH enabled, e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=924225 Fixing the callsites to pass shouldOpen=false when the file won't be read is not quite trivial (that info isn't available at the direct callsite), and passing shouldOpen=false is a performance regression (it results in open+fstat pairs being replaced by stat+open). So an ideal fix is going to be a little risky and we need some fix soon (especially for the llvm 8 branch). The problem addressed by r347205 is rare and has only been observed in clangd. It was present in llvm-7, so we can live with it for now. Reviewers: bkramer, thakis Subscribers: ilya-biryukov, ioeric, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D57165 llvm-svn: 352079
* Fix failing buildbotsGabor Marton2019-01-241-2/+2
| | | | | | | | | Fix remaining unittest errors caused by __attribute__((no_caller_saved_registers)) Related commit which caused the buildbots to fail: rL352050 llvm-svn: 352060
* Fix failing buildbotsGabor Marton2019-01-241-1/+4
| | | | | | | Related commit which caused the buildbots to fail: rL352050 llvm-svn: 352055
* [ASTImporter] Fix inequality of functions with different attributesGabor Marton2019-01-241-0/+25
| | | | | | | | | | | | | | | | Summary: FunctionType::ExtInfo holds such properties of a function which are needed mostly for code gen. We should not compare these bits when checking for structural equivalency. Checking ExtInfo caused false ODR errors during CTU analysis (of tmux). Reviewers: a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53699 llvm-svn: 352050
* [clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchersJonas Toth2019-01-211-0/+19
| | | | | | | | | | | | | | | | | Summary: This patch adds two unit-tests that are the result of reducing a crashing TU when running ExprMutAnalyzer over it. They are added only to ensure the regression that has been fixed with https://reviews.llvm.org/D56444 don't creep back. Reviewers: aaron.ballman, sammccall, rsmith, george.karpenkov Reviewed By: sammccall Subscribers: baloghadamsoftware, a.sidorin, Szelethus, donat.nagy, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D56917 llvm-svn: 351743
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-19129-516/+387
| | | | | | | | | | | | | | | | | 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] Unbreak building of SymbolReaperTest true BUILD_SHARED_LIBS=TrueAlex Bradbury2019-01-181-0/+3
| | | | | | | Extra dependencies need to be listed for StaticAnalysisTests in order for linking to succeed when BUILD_SHARED_LIBS=True. llvm-svn: 351540
* [tooling] Add a new argument adjuster for deleting plugin related command ↵Kadir Cetinkaya2019-01-181-0/+31
| | | | | | | | | | | | | | | | line args Summary: Currently both clangd and clang-tidy makes use of this mechanism so putting it into tooling so that all tools can make use of it. Reviewers: ilya-biryukov, sammccall Subscribers: ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D56856 llvm-svn: 351531
* [analyzer] A speculative fix for buildbot failures in the new SymbolReaperTest.Artem Dergachev2019-01-181-2/+1
| | | | | | I expect an xvalue to be easier to convert. llvm-svn: 351505
* [analyzer] Make sure base-region and its sub-regions are either all alive or ↵Artem Dergachev2019-01-182-0/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | all dead. SymbolReaper now realizes that our liveness analysis isn't sharp enough to discriminate between liveness of, say, variables and their fields. Surprisingly, this didn't quite work before: having a variable live only through Environment (eg., calling a C++ method on a local variable as the last action ever performed on that variable) would not keep the region value symbol of a field of that variable alive. It would have been broken in the opposite direction as well, but both Environment and RegionStore use the scanReachableSymbols mechanism for finding live symbols regions within their values, and due to that they accidentally end up marking the whole chain of super-regions as live when at least one sub-region is known to be live. It is now a direct responsibility of SymbolReaper to maintain this invariant, and a unit test was added in order to make sure it stays that way. Differential Revision: https://reviews.llvm.org/D56632 rdar://problem/46914108 llvm-svn: 351499
* Fix -Wsign-compare in new testsReid Kleckner2019-01-171-7/+7
| | | | llvm-svn: 351478
* Revert r351209 (which was a revert of r350891) with a fix.Aaron Ballman2019-01-171-2/+55
| | | | | | The test case had a parse error that was causing the condition string to be misreported. We now have better fallback code for error cases. llvm-svn: 351470
* Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a ↵Sam McCall2019-01-161-34/+18
| | | | | | | | | file without compilation database. This reverts commit r351282, and re-lands r351222 and r351229 with the use-after-free fixed. llvm-svn: 351316
* Revert "[Tooling] Make clang-tool find libc++ dir on mac when running on a ↵Vlad Tsyrklevich2019-01-161-18/+34
| | | | | | | | | file without compilation database." This reverts commits r351222 and r351229, they were causing ASan/MSan failures on the sanitizer bots. llvm-svn: 351282
* [Tooling] Fix broken compliation databse tests.Haojian Wu2019-01-151-34/+18
| | | | | | I forgot to update the unittest in r351222. llvm-svn: 351229
* Revert "Correct the source range returned from preprocessor callbacks."Benjamin Kramer2019-01-151-50/+8
| | | | | | | This reverts commit r350891. Also add a test case that would return an empty string with r350891. llvm-svn: 351209
* [AST] Fix double-traversal of code in top-level lambdas in RAV(implicit = yes).Sam McCall2019-01-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Prior to r351069, lambda classes were traversed or not depending on the {Function, Class, Namespace, TU} DeclContext containing them. If it was a function (common case) they were not traversed. If it was a namespace or TU (top-level lambda) they were traversed as part of that DeclContext traversal. r351069 "fixed" RAV to traverse these as part of the LambdaExpr, which is the right place. But top-level lambdas are now traversed twice. We fix that as blocks and block captures were apparently fixed in the past. Maybe it would be nicer to avoid adding the lambda classes to the DeclContext in the first place, but I can't work out the implications of that. Reviewers: bkramer, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56665 llvm-svn: 351075
* [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.Sam McCall2019-01-142-14/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes ASTContext's parent map for nodes in such classes (e.g. operator()). https://bugs.llvm.org/show_bug.cgi?id=39949 This also changes the observed shape of the AST for implicit RAVs. - this includes AST MatchFinder: cxxRecordDecl() now matches lambda classes, functionDecl() matches the call operator, and the parent chain is body -> call operator -> lambda class -> lambdaexpr rather than body -> lambdaexpr. - this appears not to matter for the ASTImporterLookupTable builder - this doesn't matter for the other RAVs in-tree. In order to do this, we remove the TraverseLambdaBody hook. The problem is it's hard/weird to ensure this hook is called when traversing via the implicit class. There were just two users of this hook in-tree, who use it to skip bodies. I replaced these with explicitly traversing the captures only. Another approach would be recording the bodies when the lambda is visited, and then recognizing them later. I'd be open to suggestion on how to preserve this hook, instead. Reviewers: aaron.ballman, JonasToth Subscribers: cfe-commits, rsmith, jdennett Differential Revision: https://reviews.llvm.org/D56444 llvm-svn: 351047
* Silence -Wsign-compare in unittestsBjorn Pettersson2019-01-111-7/+7
| | | | llvm-svn: 350933
* Correct the source range returned from preprocessor callbacks.Aaron Ballman2019-01-101-1/+118
| | | | | | This adjusts the source range passed in to the preprocessor callbacks to only include the condition range itself, rather than all of the conditionally skipped tokens. llvm-svn: 350891
* [libclang] Recommit r336590 with a fix for the memory leak in the testAlex Lorenz2019-01-081-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | The original commit had a memory leak in the test has a leak as it doesn't dispose of the evaluated cursor result. This also contains the follow-up NFC refactoring commit r336591. rdar://45893054 Original commit message: [libclang] evalute compound statement cursors before trying to evaluate the cursor like a declaration This change fixes a bug in libclang in which it tries to evaluate a statement cursor as a declaration cursor, because that statement still has a pointer to the declaration parent. rdar://38888477 Differential Revision: https://reviews.llvm.org/D49051 llvm-svn: 350666
* Fix use-after-free bug in Tooling.Alexander Kornienko2019-01-081-1/+4
| | | | | | | | | | | | | | | | | | | Summary: `buildASTFromCodeWithArgs()` was creating a memory buffer referencing a stack-allocated string. This diff changes the implementation to copy the code string into the memory buffer so that said buffer owns the memory. Patch by Yitzhak Mandelbaum. Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits, EricWF Differential Revision: https://reviews.llvm.org/D55765 llvm-svn: 350638
* [analyzer] Pass the correct loc Expr from VisitIncDecOp to evalStoreRafael Stahl2019-01-071-16/+39
| | | | | | | | | | | | | | Summary: The LocationE parameter of evalStore is documented as "The location expression that is stored to". When storing from an increment / decrement operator this was not satisfied. In user code this causes an inconsistency between the SVal and Stmt parameters of checkLocation. Reviewers: NoQ, dcoughlin, george.karpenkov Reviewed By: NoQ Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D55701 llvm-svn: 350528
* [clang] Add AST matcher for initializer list membersHyrum Wright2019-01-071-0/+12
| | | | | | | | | | | | | Summary: Much like hasArg for various call expressions, this allows LibTooling users to match against a member of an initializer list. This is currently being used as part of the abseil-duration-scale clang-tidy check. Differential Revision: https://reviews.llvm.org/D56090 llvm-svn: 350523
* clang-format: [JS] support goog.requireType.Martin Probst2019-01-071-0/+2
| | | | | | | | | | | | | | Summary: It's a new primitive for importing symbols, and should be treated like the (previously handled) `goog.require` and `goog.forwardDeclare`. Reviewers: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56385 llvm-svn: 350516
* [Distro] Support detecting GentooMichal Gorny2018-12-231-0/+36
| | | | | | | | | | | Add support for distinguishing plain Gentoo distribution, and a unit test for it. This is going to be used to introduce distro-specific customizations in the driver code; most notably, it is going to be used to disable -faddrsig. Differential Revision: https://reviews.llvm.org/D56024 llvm-svn: 350027
* Remove stat cache chaining as it's no longer needed after PTH support has beenAlex Lorenz2018-12-211-19/+10
| | | | | | | | | | | | | removed Stat cache chaining was implemented for a StatListener in the PTH writer so that it could write out the stat information to PTH. r348266 removed support for PTH, and it doesn't seem like there are other uses of stat cache chaining. We can remove the chaining support. Differential Revision: https://reviews.llvm.org/D55455 llvm-svn: 349942
* Fix build failures from r349812 due to a missing argument.Aaron Ballman2018-12-201-1/+2
| | | | llvm-svn: 349815
* [unittests] Remove superfluous semicolon, fixing warnings with GCC. NFC.Martin Storsjo2018-12-181-1/+1
| | | | llvm-svn: 349453
* [CodeComplete] Fix test failure on different host and target configsIlya Biryukov2018-12-171-6/+21
| | | | | | This should fix PR40033. llvm-svn: 349362
* Build ASTImporterTest.cpp with /bigobj on MSVC builds to keep ↵Simon Pilgrim2018-12-171-0/+4
| | | | | | llvm-clang-x86_64-expensive-checks-win buildbot happy llvm-svn: 349357
* [ASTImporter] Add importer specific lookupGabor Marton2018-12-171-28/+551
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ASTImporter] Fix redecl chain of classes and class templatesGabor Marton2018-12-172-88/+711
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The crux of the issue that is being fixed is that lookup could not find previous decls of a friend class. The solution involves making the friend declarations visible in their decl context (i.e. adding them to the lookup table). Also, we simplify `VisitRecordDecl` greatly. This fix involves two other repairs (without these the unittests fail): (1) We could not handle the addition of injected class types properly when a redecl chain was involved, now this is fixed. (2) DeclContext::removeDecl failed if the lookup table in Vector form did not contain the to be removed element. This caused troubles in ASTImporter::ImportDeclContext. This is also fixed. Reviewers: a_sidorin, balazske, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53655 llvm-svn: 349349
* [analyzer][NFC] Move CheckerRegistry from the Core directory to FrontendKristof Umann2018-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ClangCheckerRegistry is a very non-obvious, poorly documented, weird concept. It derives from CheckerRegistry, and is placed in lib/StaticAnalyzer/Frontend, whereas it's base is located in lib/StaticAnalyzer/Core. It was, from what I can imagine, used to circumvent the problem that the registry functions of the checkers are located in the clangStaticAnalyzerCheckers library, but that library depends on clangStaticAnalyzerCore. However, clangStaticAnalyzerFrontend depends on both of those libraries. One can make the observation however, that CheckerRegistry has no place in Core, it isn't used there at all! The only place where it is used is Frontend, which is where it ultimately belongs. This move implies that since include/clang/StaticAnalyzer/Checkers/ClangCheckers.h only contained a single function: class CheckerRegistry; void registerBuiltinCheckers(CheckerRegistry &registry); it had to re purposed, as CheckerRegistry is no longer available to clangStaticAnalyzerCheckers. It was renamed to BuiltinCheckerRegistration.h, which actually describes it a lot better -- it does not contain the registration functions for checkers, but only those generated by the tblgen files. Differential Revision: https://reviews.llvm.org/D54436 llvm-svn: 349275
* Attempt to fix code completion test to handle LLP64 platformsReid Kleckner2018-12-131-1/+3
| | | | llvm-svn: 349086
* [CodeComplete] Adhere to LLVM naming style in CodeCompletionTest. NFCIlya Biryukov2018-12-131-30/+31
| | | | | | | Also reuses the same var for multiple to reduce the chance of accidentally referecing the previous test. llvm-svn: 349063
* Fix CodeCompleteTest.cpp for older gcc plus ccache buildsDavid Green2018-12-131-45/+45
| | | | | | | | Some versions of gcc, especially when invoked through ccache (-E), can have trouble with raw string literals inside macros. This moves the string out of the macro. llvm-svn: 349059
* [CodeComplete] Fill preferred type on binary expressionsIlya Biryukov2018-12-131-30/+210
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55648 llvm-svn: 349053
* [clang] Add AST matcher for block expressions 🔍Stephane Moore2018-12-131-0/+4
| | | | | | | | | | | | | | | | | | Summary: This change adds a new AST matcher for block expressions. Test Notes: Ran the clang unit tests. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55546 llvm-svn: 349004
* [AST] Store "UsesADL" information in CallExpr.Eric Fiselier2018-12-121-0/+34
| | | | | | | | | | | | | | | | | | | | | Summary: Currently the Clang AST doesn't store information about how the callee of a CallExpr was found. Specifically if it was found using ADL. However, this information is invaluable to tooling. Consider a tool which renames usages of a function. If the originally CallExpr was formed using ADL, then the tooling may need to additionally qualify the replacement. Without information about how the callee was found, the tooling is left scratching it's head. Additionally, we want to be able to match ADL calls as quickly as possible, which means avoiding computing the answer on the fly. This patch changes `CallExpr` to store whether it's callee was found using ADL. It does not change the size of any AST nodes. Reviewers: fowles, rsmith, klimek, shafik Reviewed By: rsmith Subscribers: aaron.ballman, riccibruno, calabrese, titus, cfe-commits Differential Revision: https://reviews.llvm.org/D55534 llvm-svn: 348977
* Add explicit dependency on clangSerialization for a bunch of components to ↵Fangrui Song2018-12-1212-0/+12
| | | | | | | | | | | | | | | 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. llvm-svn: 348915
* [tests] Fix the FileManagerTest getVirtualFile test on WindowsStella Stamenova2018-12-071-8/+20
| | | | | | | | | | | | Summary: The test passes on Windows only when it is executed on the C: drive. If the build and tests run on a different drive, the test is currently failing. Reviewers: kadircet, asmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55451 llvm-svn: 348665
* [unittests] Add C++17 and C++2a support to the tooling testsHamza Sood2018-12-071-0/+4
| | | | llvm-svn: 348603
OpenPOWER on IntegriCloud