summaryrefslogtreecommitdiffstats
path: root/clang/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [analyzer] Fix nullptr access when processing instantiated function in ↵Shuai Wang2018-09-191-0/+30
| | | | | | ExprMutationAnalyzer. llvm-svn: 342562
* [NFC] Fix uncompilable test cases of ExprMutationAnalyzer.Shuai Wang2018-09-191-311/+265
| | | | | | And ensure future test cases doesn't have compile errors. llvm-svn: 342525
* [Index] Add an option to collect macros from preprocesor.Eric Liu2018-09-183-0/+144
| | | | | | | | | | | | | | Summary: Also added unit tests for the index library; lit+c-index-test is painful... Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D52098 llvm-svn: 342451
* [analyzer] Treat std::{move,forward} as casts in ExprMutationAnalyzer.Shuai Wang2018-09-171-23/+115
| | | | | | | | | | | | | | | Summary: This is a follow up of D52008 and should make the analyzer being able to handle perfect forwardings in real world cases where forwardings are done through multiple layers of function calls with `std::forward`. Fixes PR38891. Reviewers: lebedev.ri, JonasToth, george.karpenkov Subscribers: xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D52120 llvm-svn: 342409
* [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, ↵Shuai Wang2018-09-173-2/+16
| | | | | | | | | | | | CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52157 llvm-svn: 342407
* [ASTImporter] Fix import of VarDecl initGabor Marton2018-09-171-2/+145
| | | | | | | | | | | | | | | | | | Summary: The init expression of a VarDecl is overwritten in the "To" context if we import a VarDecl without an init expression (and with a definition). Please refer to the added tests, especially InitAndDefinitionAreInDifferentTUs. This patch fixes the malfunction by importing the whole Decl chain similarly as we did that in case of FunctionDecls. We handle the init expression similarly to a definition, alas only one init expression will be in the merged ast. Reviewers: a_sidorin, xazax.hun, r.stahl, a.sidorin Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D51597 llvm-svn: 342384
* [clang-Format] Fix indentation of member call after blockIlya Biryukov2018-09-171-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: before patch: > echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google ``` test() { ([]() -> { int b = 32; return 3; }) .as(); }); ``` after patch: > echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google ``` test() { ([]() -> { int b = 32; return 3; }).as(); }); ``` Patch by Anders Karlsson (ank)! Reviewers: klimek Reviewed By: klimek Subscribers: danilaml, acoomans, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45719 llvm-svn: 342363
* [analyzer] Handle forwarding reference better in ExprMutationAnalyzer.Shuai Wang2018-09-141-0/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We used to treat an `Expr` mutated whenever it's passed as non-const reference argument to a function. This results in false positives in cases like this: ``` int x; std::vector<int> v; v.emplace_back(x); // `x` is passed as non-const reference to `emplace_back` ``` In theory the false positives can be suppressed with `v.emplace_back(std::as_const(x))` but that's considered overly verbose, inconsistent with existing code and spammy as diags. This diff handles such cases by following into the function definition and see whether the argument is mutated inside. Reviewers: lebedev.ri, JonasToth, george.karpenkov Subscribers: xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D52008 llvm-svn: 342271
* [VFS] vfs::directory_iterator yields path and file type instead of full StatusSam McCall2018-09-141-27/+29
| | | | | | | | | | | | | | | | | | | | | | | Summary: Most callers I can find are using only `getName()`. Type is used by the recursive iterator. Now we don't have to call stat() on every listed file (on most platforms). Exceptions are e.g. Solaris where readdir() doesn't include type information. On those platforms we'll still stat() - see D51918. The result is significantly faster (stat() can be slow). My motivation: this may allow us to improve clang IO on large TUs with long include search paths. Caching readdir() results may allow us to skip many stat() and open() operations on nonexistent files. Reviewers: bkramer Subscribers: fedor.sergeev, cfe-commits Differential Revision: https://reviews.llvm.org/D51921 llvm-svn: 342232
* [Sema] Remove location from implicit capture init exprVedant Kumar2018-09-131-5/+5
| | | | | | | | | | | | | | | | | | A lambda's closure is initialized when the lambda is declared. For implicit captures, the initialization code emitted from EmitLambdaExpr references source locations *within the lambda body* in the function containing the lambda. This results in a poor debugging experience: we step to the line containing the lambda, then into lambda, out again, over and over, until every capture's field is initialized. To improve stepping behavior, assign the starting location of the lambda to expressions which initialize an implicit capture within it. rdar://39807527 Differential Revision: https://reviews.llvm.org/D50927 llvm-svn: 342194
* [clang-format] Wrapped block after case label should not be merged into one lineOwen Pan2018-09-131-0/+26
| | | | | | | | PR38854 Differential Revision: http://reviews.llvm.org/D51719 llvm-svn: 342116
* [analyzer] Add ExprMutationAnalyzerShuai Wang2018-09-112-0/+944
| | | | | | | | | | | | | | | | | | Summary: This is 1/2 of moving ExprMutationAnalyzer from clangtidy to clang/Analysis. This diff along simply copies the ExprMutationAnalyzer over with trivial modifications (e.g. include path, namespace) 2/2 will migrate existing usage of ExprMutationAnalyzer and remove the original copy inside clangtidy. Reviewers: george.karpenkov Subscribers: mgorny, xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, cfe-commits, JonasToth Differential Revision: https://reviews.llvm.org/D51948 llvm-svn: 341994
* [ASTMatchers] add three matchers for dependent expressionsJonas Toth2018-09-111-0/+42
| | | | | | | | | | | | | | | | | | | Summary: The new matchers can be used to check if an expression is type-, value- or instantiation-dependent in a templated context. These matchers are used in a clang-tidy check and generally useful as the problem of unresolved templates occurs more often in clang-tidy and they provide an easy way to check for this issue. Reviewers: aaron.ballman, alexfh, klimek Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51880 llvm-svn: 341958
* [Tooling] Improve handling of CL-style optionsHamza Sood2018-09-091-3/+30
| | | | | | | | | | | | | | | | | | This patch fixes the handling of clang-cl options in InterpolatingCompilationDatabase. They were previously ignored completely, which led to a lot of bugs: Additional options were being added with the wrong syntax. E.g. a file was specified as C++ by adding -x c++, which causes an error in CL mode. The args were parsed and then rendered, which means that the aliasing information was lost. E.g. /W4 was rendered to -Wall, which in CL mode means -Weverything. CL options were ignored when checking things like -std=, so a lot of logic was being bypassed. Differential Revision: https://reviews.llvm.org/D51321 llvm-svn: 341760
* clang-format: Fix formatting C++ namespaces with preceding 'inline' or ↵Sam McCall2018-09-051-0/+75
| | | | | | | | | | | | | | | | | | | | | | 'export' specifier This fixes formatting namespaces with preceding 'inline' and 'export' (Modules TS) specifiers. This change fixes namespaces not being identified as such with preceding 'inline' or 'export' specifiers. Motivation: I was experimenting with the Modules TS (-fmodules-ts) and found it would be useful if clang-format would correctly format 'export namespace'. While making the changes, I noticed that similar issues still exist with 'inline namespace', and addressed them as well. Patch by Marco Elver! Reviewers: klimek, djasper, owenpan, sammccall Reviewed By: owenpan, sammccall Subscribers: owenpan, cfe-commits Differential Revision: https://reviews.llvm.org/D51036 llvm-svn: 341450
* Adding HardLink Support to VirtualFileSystem.Ilya Biryukov2018-09-041-0/+114
| | | | | | | | | | | | | | | | | | | | | | | Summary: Added support of creating a hardlink from one file to another file. After a hardlink is added between two files, both file will have the same: 1. UniqueID (inode) 2. Size 3. Buffer This will bring replay of compilation closer to the actual compilation. There are instances where clang checks for the UniqueID of the file/header to be loaded which leads to a different behavior during replay as all files have different UniqueIDs. Patch by Utkarsh Saxena! Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51359 llvm-svn: 341366
* Add header guards to some headers that are missing themArgyrios Kyrtzidis2018-09-031-0/+5
| | | | llvm-svn: 341324
* [ASTImporter] Merge ExprBitsGabor Marton2018-09-031-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Some `Expr` classes set up default values for the `ExprBits` of `Stmt`. These default values are then overwritten by the parser sometimes. One example is `InitListExpr` which sets the value kind to be an rvalue in the ctor. However, this bit may change after the `InitListExpr` is created. There may be other expressions similar to `InitListExpr` in this sense, thus the safest solution is to copy the expression bits. The lack of copying `ExprBits` causes an assertion in the analyzer engine in a specific case: Since the value kind is not imported, the analyzer engine believes that the given InitListExpr is an rvalue, thus it creates a nonloc::CompoundVal instead of creating memory region (as in case of an lvalue reference). Reviewers: a_sidorin, r.stahl, xazax.hun, a.sidorin Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D51533 llvm-svn: 341316
* Fix Bug 38713: clang-format mishandles a short block after "default:" in a ↵Jonas Toth2018-09-021-0/+18
| | | | | | | | | | | | | | | | | | | switch statement Summary: See https://bugs.llvm.org/show_bug.cgi?id=38713 Patch by Owen Pan! Reviewers: djasper, klimek, sammccall Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51294 llvm-svn: 341284
* Allow binding to NamedValue resulting from let expressionStephen Kelly2018-08-301-0/+38
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51259 llvm-svn: 341142
* Add dump() method for SourceRangeStephen Kelly2018-08-301-0/+48
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50662 llvm-svn: 341140
* Parse compile commands lazily in InterpolatingCompilationDatabaseIlya Biryukov2018-08-281-3/+6
| | | | | | | | | | | | | | | | | Summary: This greatly reduces the time to read 'compile_commands.json'. For Chromium on my machine it's now 0.7 seconds vs 30 seconds before the change. Reviewers: sammccall, jfb Reviewed By: sammccall Subscribers: mgrang, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D51314 llvm-svn: 340838
* [clang-format] fix PR38557 - comments between "default" and ':' causes the ↵Jonas Toth2018-08-241-0/+16
| | | | | | | | | | | | | | | | | | | case label to be treated as an identifier Summary: The Bug was reported and fixed by Owen Pan. See the original bug report here: https://bugs.llvm.org/show_bug.cgi?id=38557 Patch by Owen Pan! Reviewers: krasimir, djasper, klimek Reviewed By: klimek Subscribers: JonasToth, cfe-commits Differential Revision: https://reviews.llvm.org/D50697 llvm-svn: 340624
* [clang-format] fix PR38525 - Extraneous continuation indent spaces with ↵Jonas Toth2018-08-241-0/+12
| | | | | | | | | | | | | | | | | | BreakBeforeBinaryOperators set to All Summary: See bug report https://bugs.llvm.org/show_bug.cgi?id=38525 for more details. Reviewers: djasper, klimek, krasimir, sammccall Reviewed By: sammccall Subscribers: hiraditya, JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D50699 llvm-svn: 340623
* [Tooling] Add a isSingleProcess() helper to ToolExecutorIlya Biryukov2018-08-241-0/+2
| | | | | | | | | | | | | | | | Summary: Used in clangd's symbol builder to optimize for the common shared-memory executor case. Reviewers: ioeric Reviewed By: ioeric Subscribers: kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51164 llvm-svn: 340599
* [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, ↵Shuai Wang2018-08-231-0/+20
| | | | | | | | | | | | CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50617 llvm-svn: 340547
* Fix import of class templates partial specializationGabor Marton2018-08-221-2/+259
| | | | | | | | | | | | | | | | | | | Summary: Currently there are several issues with the import of class template specializations. (1) Different TUs may have class template specializations with the same template arguments, but with different set of instantiated MethodDecls and FieldDecls. In this patch we provide a fix to merge these methods and fields. (2) Currently, we search the partial template specializations in the set of simple specializations and we add partial specializations as simple specializations. This is bad, this patch fixes it. Reviewers: a_sidorin, xazax.hun, r.stahl Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50451 llvm-svn: 340402
* [ASTImporter] Adding some friend function related unittests.Balazs Keri2018-08-211-0/+205
| | | | | | | | | | | | Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D49798 llvm-svn: 340277
* clang-format: Change Google style wrt. the formatting of empty messages.Daniel Jasper2018-08-151-8/+4
| | | | | | | | | | | Before: message Empty { } After: message Empty {} llvm-svn: 339803
* Fix ASTMatchersTraversalTest testcase compile on older compilersDavid Green2018-08-151-3/+3
| | | | | | | | 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: 339759
* Remove obsolete commentStephen Kelly2018-08-141-1/+0
| | | | | | | This related to the code as first checked in in r266292 ([ASTImporter] Implement some expression-related AST node import., 2016-04-14). llvm-svn: 339731
* Fix Stmt::ignoreImplicitStephen Kelly2018-08-141-0/+39
| | | | | | | | | | | | | | | | Summary: A CXXBindTemporaryExpr can appear inside an ImplicitCastExpr, and was not ignored previously. Fixes the case reported in PR37327. Reviewers: rsmith, dblaikie, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50666 llvm-svn: 339730
* [clang-format] Fix comment, NFCKrasimir Georgiev2018-08-131-1/+1
| | | | llvm-svn: 339573
* [ASTImporter] Improved import of friend templates.Balazs Keri2018-08-131-0/+87
| | | | | | | | | | | | | | | | | | | Summary: When importing a friend class template declaration, this declaration should not be merged with any other existing declaration for the same type. Otherwise the getFriendDecl of the FriendDecl can point to an other already referenced declaration, this case causes problems. Additionally the previous decl of class templates is set at import. Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50516 llvm-svn: 339560
* [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExprShuai Wang2018-08-121-0/+19
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50605 llvm-svn: 339530
* [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExprShuai Wang2018-08-122-6/+14
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50606 llvm-svn: 339522
* Port getLocStart -> getBeginLocStephen Kelly2018-08-098-9/+9
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Fix structural inequivalency of forward EnumDeclGabor Marton2018-08-091-0/+54
| | | | | | | | | | | | | | Summary: Currently we consider one forward declared RecordDecl and another with a definition equal. We have to do the same in case of enums. Reviewers: a_sidorin, r.stahl, xazax.hun Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50444 llvm-svn: 339336
* Add support for importing imaginary literalsGabor Marton2018-08-091-0/+8
| | | | | | | | | | Reviewers: a_sidorin, r.stahl, xazax.hun Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50428 llvm-svn: 339334
* [VFS] Remove superfluous semicolon from unittest.Craig Topper2018-08-081-1/+1
| | | | llvm-svn: 339296
* [AST] Check described template at structural equivalence check.Balazs Keri2018-08-081-5/+28
| | | | | | | | | | | | | | | | | | | | Summary: When checking a class or function the described class or function template is checked too. Split StructuralEquivalenceContext::Finish into multiple functions. Improved test with symmetric check, added new tests. Reviewers: martong, a.sidorin, a_sidorin, bruno Reviewed By: martong, a.sidorin Subscribers: rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D49223 llvm-svn: 339256
* [ASTImporter] Load external Decls when getting field index.Balazs Keri2018-08-081-0/+34
| | | | | | | | | | | | | | | | | Summary: At equality check of fields without name the index of fields is compared. At determining the index of a field all fields of the parent context should be loaded from external source to find the field at all. Reviewers: a.sidorin, a_sidorin, r.stahl Reviewed By: a.sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D49796 llvm-svn: 339226
* [VFS] Emit an error when entry at root level uses a relative path.Volodymyr Sapsai2018-08-071-0/+32
| | | | | | | | | | | | | | | | | | | | | Entries with only a filename prevent us from building a file system tree and cause the assertion > Assertion failed: (NewParentE && "Parent entry must exist"), function uniqueOverlayTree, file clang/lib/Basic/VirtualFileSystem.cpp, line 1303. Entries with a relative path are simply not discoverable during header search. rdar://problem/28990865 Reviewers: bruno, benlangmuir Reviewed By: bruno Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D49518 llvm-svn: 339164
* [clang-format] comment reflow: add last line's penalty when ending brokenKrasimir Georgiev2018-08-071-0/+20
| | | | | | | | | | | | | | | | | | Summary: This fixes a bug in clang-format where the last line's penalty is not taken into account when its ending is broken. Usually the last line's penalty is handled by addNextStateToQueue, but in cases where the trailing `*/` is put on a newline, the contents of the last line have to be considered for penalizing. Reviewers: mprobst Reviewed By: mprobst Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50378 llvm-svn: 339123
* [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the ↵Simon Marchi2018-08-062-11/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | requested name Summary: InMemoryFileSystem::status behaves differently than RealFileSystem::status. The Name contained in the Status returned by RealFileSystem::status will be the path as requested by the caller, whereas InMemoryFileSystem::status returns the normalized path. For example, when requested the status for "../src/first.h", RealFileSystem returns a Status with "../src/first.h" as the Name. InMemoryFileSystem returns "/absolute/path/to/src/first.h". The reason for this change is that I want to make a unit test in the clangd testsuite (where we use an InMemoryFileSystem) to reproduce a bug I get with the clangd program (where a RealFileSystem is used). This difference in behavior "hides" the bug in the unit test version. An indirect impact of this change is that a -Wnonportable-include-path warning is now emitted in test PCH/case-insensitive-include.c. This is because the real path of the included file (with the wrong case) was not available previously, whereas it is now. Reviewers: malaperle, ilya-biryukov, bkramer Reviewed By: ilya-biryukov Subscribers: eric_niebler, malaperle, omtcyfz, hokein, bkramer, ilya-biryukov, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D48903 llvm-svn: 339063
* Removed the OverflowConversionsToFract tests for now. Will add them backLeonard Chan2018-08-061-45/+0
| | | | | | in once I figure out why this doesn't work on windows. llvm-svn: 339038
* Fix for failing test from sanitizer-x86_64-linux-fast where there was aLeonard Chan2018-08-061-0/+7
| | | | | | left shift on a negative value. llvm-svn: 339037
* [Fixed Point Arithmetic] Fixed Point ConstantLeonard Chan2018-08-062-0/+685
| | | | | | | | | | This patch proposes an abstract type that represents fixed point numbers, similar to APInt or APSInt that was discussed in https://reviews.llvm.org/D48456#inline-425585. This type holds a value, scale, and saturation and is meant to perform intermediate calculations on constant fixed point values. Currently this class is used as a way for handling the conversions between fixed point numbers with different sizes and radixes. For example, if I'm casting from a signed _Accum to a saturated unsigned short _Accum, I will need to check the value of the signed _Accum to see if it fits into the short _Accum which involves getting and comparing against the max/min values of the short _Accum. The FixedPointNumber class currently handles the radix shifting and extension when converting to a signed _Accum. Differential Revision: https://reviews.llvm.org/D48661 llvm-svn: 339028
* [Fixed Point Arithmetic] Fix for FixedPointValueToStringLeonard Chan2018-08-062-0/+108
| | | | | | | | | | | | - Print negative numbers correctly - Handle APInts of different sizes - Add formal unit tests for FixedPointValueToString - Add tests for checking correct printing when padding is set - Restrict to printing in radix 10 since that's all we need for now Differential Revision: https://reviews.llvm.org/D49945 llvm-svn: 339026
* [ASTmporter] SourceRange-free function parameter checking for declarationsGabor Marton2018-08-061-6/+35
| | | | | | | | | | | | | | | | Summary: The previous code which avoided infinite recursion (because of reparsing declarations in function parameter lists) contained SourceRange dependent code which had some problems when parameter types were coming from macros. The new solution is not using macros and therefore much safer. A couple of importer problems are fixed in redis and tmux by this fix. Various unittests are included. Reviewers: a.sidorin, r.stahl, a_sidorin Reviewed By: a_sidorin Subscribers: cfe-commits, dkrupp, balazske, martong Differential Revision: https://reviews.llvm.org/D49792 Patch by Zoltan Gera! llvm-svn: 339018
OpenPOWER on IntegriCloud