summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "Add support for __builtin_os_log_format[_buffer_size]"Mehdi Amini2016-10-244-222/+2
| | | | | | This reverts commit r284990, two opencl test are broken llvm-svn: 285007
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-244-2/+222
| | | | | | | | | | | | | | These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 284990
* Remove move constructors that are identical to the generated default move ctor.Benjamin Kramer2016-10-211-1/+1
| | | | llvm-svn: 284856
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-201-2/+1
| | | | | | No functionality change intended. llvm-svn: 284730
* [analyzer] Remove superquadratic behaviour from DataflowWorklistAlexander Shaposhnikov2016-10-131-18/+9
| | | | | | | | | | | | | | | | | The class DataflowWorklist internally maintains a sorted list of pointers to CFGBlock and the method enqueuePredecessors has to call sortWorklist to maintain the invariant. The implementation based on vector + sort works well for small sizes but gets infeasible for relatively large sizes. In particular the issue takes place for some cryptographic libraries which use code generation. The diff replaces vector + sort with priority queue. For one of the implementations of AES this patch reduces the time for analysis from 204 seconds to 8 seconds. Test plan: make -j8 check-clang Differential revision: https://reviews.llvm.org/D25503 llvm-svn: 284166
* [Analysis] Use unique_ptr for CallGraph::FunctionMap.Justin Lebar2016-10-101-9/+7
| | | | | | | | | | Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25427 llvm-svn: 283775
* [Analysis] Use unique_ptr in AnalyaisDeclContextManager's ContextMap.Justin Lebar2016-10-101-9/+5
| | | | | | | | | | Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25426 llvm-svn: 283774
* [analyzer] Re-apply r283094 "Improve CloneChecker diagnostics"Artem Dergachev2016-10-081-11/+15
| | | | | | The parent commit (r283092) was reverted before and now finally landed. llvm-svn: 283661
* Revert r283106, "Wdocumentation fix"NAKAMURA Takumi2016-10-041-1/+1
| | | | | | It should depend on r283094 and r283182. llvm-svn: 283195
* Revert "[analyzer] Improve CloneChecker diagnostics" as its depends on ↵Vitaly Buka2016-10-041-14/+10
| | | | | | | | reverted r283092 This reverts commit r283094. llvm-svn: 283182
* Wdocumentation fixSimon Pilgrim2016-10-031-1/+1
| | | | llvm-svn: 283106
* [StaticAnalyzer] Fix UnreachableCode false positives.Daniel Marjamaki2016-10-031-11/+10
| | | | | | | | When there is 'do { } while (0);' in the code the ExplodedGraph and UnoptimizedCFG did not match. Differential Revision: https://reviews.llvm.org/D24759 llvm-svn: 283095
* [analyzer] Improve CloneChecker diagnosticsArtem Dergachev2016-10-031-10/+14
| | | | | | | | | | | | | | | | | | Highlight code clones referenced by the warning message with the help of the extra notes feature recently introduced in r283092. Change warning text to more clang-ish. Remove suggestions from the copy-paste error checker diagnostics, because currently our suggestions are strictly 50% wrong (we do not know which of the two code clones contains the error), and for that reason we should not sound as if we're actually suggesting this. Hopefully a better solution would bring them back. Make sure the suspicious clone pair structure always mentions the correct variable for the second clone. Differential Revision: https://reviews.llvm.org/D24916 llvm-svn: 283094
* Move UTF functions into namespace llvm.Justin Lebar2016-09-301-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This lets people link against LLVM and their own version of the UTF library. I determined this only affects llvm, clang, lld, and lldb by running $ git grep -wl 'UTF[0-9]\+\|\bConvertUTF\bisLegalUTF\|getNumBytesFor' | cut -f 1 -d '/' | sort | uniq clang lld lldb llvm Tested with ninja lldb ninja check-clang check-llvm check-lld (ninja check-lldb doesn't complete for me with or without this patch.) Reviewers: rnk Subscribers: klimek, beanz, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D24996 llvm-svn: 282822
* [analyzer] Fix CloneDetector crash on calling methods of class templates.Artem Dergachev2016-08-231-4/+3
| | | | | | | | | | | | | | If a call expression represents a method call of a class template, and the method itself isn't templated, then the method may be considered to be a template instantiation without template specialization arguments. No longer crash when we could not find template specialization arguments. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23780 llvm-svn: 279529
* Wdocumentation fixSimon Pilgrim2016-08-201-2/+2
| | | | llvm-svn: 279382
* [analyzer] Use faster hashing (MD5) in CloneDetector.Artem Dergachev2016-08-201-64/+189
| | | | | | | | | | | | | | | This replaces the old approach of fingerprinting every AST node into a string, which avoided collisions and was simple to implement, but turned out to be extremely ineffective with respect to both performance and memory. The collisions are now dealt with in a separate pass, which no longer causes performance problems because collisions are rare. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D22515 llvm-svn: 279378
* [Sema] Don't crash on scanf on forward-declared enums.Benjamin Kramer2016-08-202-4/+19
| | | | | | | | This is valid in GNU C, which allows pointers to incomplete enums. GCC just pretends that the underlying type is 'int' in those cases, follow that behavior. llvm-svn: 279374
* [analyzer] Make CloneDetector consider macro expansions.Artem Dergachev2016-08-201-4/+67
| | | | | | | | | | | | | | | | | So far macro-generated code was treated by the CloneDetector as normal code. This caused that some macros where reported as false-positive clones because large chunks of code coming from otherwise concise macro expansions were treated as copy-pasted code. This patch ensures that macros are treated in the same way as literals/function calls. This prevents macros that expand into multiple statements from being reported as clones. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23316 llvm-svn: 279367
* [analyzer] Make CloneDetector consider template arguments.Artem Dergachev2016-08-201-2/+20
| | | | | | | | | | | For example, code samples `isa<Stmt>(S)' and `isa<Expr>(S)' are no longer considered to be clones. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23555 llvm-svn: 279366
* [analyzer] Teach CloneDetector to find clones that look like copy-paste errors.Artem Dergachev2016-08-181-20/+123
| | | | | | | | | | | | | | | | | | | The original clone checker tries to find copy-pasted code that is exactly identical to the original code, up to minor details. As an example, if the copy-pasted code has all references to variable 'a' replaced with references to variable 'b', it is still considered to be an exact clone. The new check finds copy-pasted code in which exactly one variable seems out of place compared to the original code, which likely indicates a copy-paste error (a variable was forgotten to be renamed in one place). Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23314 llvm-svn: 279056
* [analyzer] Fix a crash in CloneDetector when calling functions by pointers.Artem Dergachev2016-08-101-2/+5
| | | | | | | | | | | CallExpr may have a null direct callee when the callee function is not known in compile-time. Do not try to take callee name in this case. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23320 llvm-svn: 278238
* [analyzer] Try to fix coverity CID 1360469.Vassil Vassilev2016-08-091-1/+1
| | | | | | Patch by Raphael Isemann! llvm-svn: 278110
* [analyzer] Make CloneDetector recognize different variable patterns.Artem Dergachev2016-08-041-3/+143
| | | | | | | | | | | | | | | | | CloneDetector should be able to detect clones with renamed variables. However, if variables are referenced multiple times around the code sample, the usage patterns need to be recognized. For example, (x < y ? y : x) and (y < x ? y : x) are no longer clones, however (a < b ? b : a) is still a clone of the former. Variable patterns are computed and compared during a separate filtering pass. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D22982 llvm-svn: 277757
* [CFG] Fix crash finding destructor of lifetime-extended temporary.Devin Coughlin2016-08-021-1/+11
| | | | | | | | | | | Fix a crash under -Wthread-safety when finding the destructor for a lifetime-extending reference. A patch by Nandor Licker! Differential Revision: https://reviews.llvm.org/D22419 llvm-svn: 277522
* [analyzer] Respect statement-specific data in CloneDetection.Artem Dergachev2016-08-021-3/+165
| | | | | | | | | | | | | | | | | So far the CloneDetector only respected the kind of each statement when searching for clones. This patch refines the way the CloneDetector collects data from each statement by providing methods for each statement kind, that will read the kind-specific attributes. For example, statements 'a < b' and 'a > b' are no longer considered to be clones, because they are different in operation code, which is an attribute specific to the BinaryOperator statement kind. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D22514 llvm-svn: 277449
* [analyzer] Add basic capabilities to detect source code clones.Artem Dergachev2016-07-262-0/+278
| | | | | | | | | | | | | | | | | | | | | This patch adds the CloneDetector class which allows searching source code for clones. For every statement or group of statements within a compound statement, CloneDetector computes a hash value, and finds clones by detecting identical hash values. This initial patch only provides a simple hashing mechanism that hashes the kind of each sub-statement. This patch also adds CloneChecker - a simple static analyzer checker that uses CloneDetector to report copy-pasted code. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D20795 llvm-svn: 276782
* [NFC] Header cleanupMehdi Amini2016-07-184-14/+2
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* P0305R0: Semantic analysis and code generation for C++17 init-statement for ↵Richard Smith2016-07-142-8/+35
| | | | | | | | | | 'if' and 'switch': if (stmt; condition) { ... } Patch by Anton Bikineev! Some minor formatting and comment tweets by me. llvm-svn: 275350
* CFGBuilder: Fix crash when visiting a range-based for over a dependent typeAlexander Kornienko2016-07-081-0/+2
| | | | | | | | | | | | | | | | | Summary: CFG generation is expected to fail in this case, but it should not crash. Also added a test that reproduces the crash. Reviewers: klimek Subscribers: cfe-commits Patch by Martin Boehme! Differential Revision: http://reviews.llvm.org/D21895 llvm-svn: 274834
* Use more ArrayRefsDavid Majnemer2016-06-241-1/+1
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* Implement p0292r2 (constexpr if), a likely C++1z feature.Richard Smith2016-06-231-2/+2
| | | | llvm-svn: 273602
* Re-commit "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-211-0/+6
| | | | | | | | | | MaterializeTemporaryExpr." Since D21243 fixes relative clang-tidy tests. This reverts commit a71d9fbd41e99def9159af2b01ef6509394eaeed. llvm-svn: 273312
* Revert "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-091-6/+0
| | | | | | | | | MaterializeTemporaryExpr." This reverts r272296, since there are clang-tidy failures that appear to be caused by this change. llvm-svn: 272310
* [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.Tim Shen2016-06-091-0/+6
| | | | | | | | | | | These ExprWithCleanups are added for holding a RunCleanupsScope not for destructor calls; rather, they are for lifetime marks. This requires ExprWithCleanups to keep a bit to indicate whether it have cleanups with side effects (e.g. dtor calls). Differential Revision: http://reviews.llvm.org/D20498 llvm-svn: 272296
* Turn copies into references as suggested by clang-tidy's ↵Benjamin Kramer2016-05-271-1/+1
| | | | | | performance-unnecessary-copy-initialization. llvm-svn: 270994
* Enable support for __float128 in Clang and enable it on pertinent platformsNemanja Ivanovic2016-05-091-0/+1
| | | | | | | | | | | | | | | | | | This patch corresponds to reviews: http://reviews.llvm.org/D15120 http://reviews.llvm.org/D19125 It adds support for the __float128 keyword, literals and target feature to enable it. Based on the latter of the two aforementioned reviews, this feature is enabled on Linux on i386/X86 as well as SystemZ. This is also the second attempt in commiting this feature. The first attempt did not enable it on required platforms which caused failures when compiling type_traits with -std=gnu++11. If you see failures with compiling this header on your platform after this commit, it is likely that your platform needs to have this feature enabled. llvm-svn: 268898
* Check 'r' and 'y specifiers of freebsd_kernel_printf format strings on PS4Sunil Srivastava2016-04-261-2/+2
| | | | | | This is an addendum to r229921. llvm-svn: 267625
* Revert 266186 as it breaks anything that includes type_traits on some platformsNemanja Ivanovic2016-04-151-1/+0
| | | | | | | | | | Since this patch provided support for the __float128 type but disabled it on all platforms by default, some platforms can't compile type_traits with -std=gnu++11 since there is a specialization with __float128. This reverts the patch until D19125 is approved (i.e. we know which platforms need this support enabled). llvm-svn: 266460
* Enable support for __float128 in ClangNemanja Ivanovic2016-04-131-0/+1
| | | | | | | | | | | | | | | | This patch corresponds to review: http://reviews.llvm.org/D15120 It adds support for the __float128 keyword, literals and a target feature to enable it. This support is disabled by default on all targets and any target that has support for this type is free to add it. Based on feedback that I've received from target maintainers, this appears to be the right thing for most targets. I have not heard from the maintainers of X86 which I believe supports this type. I will subsequently investigate the impact of enabling this on X86. llvm-svn: 266186
* [OpenCL] Move OpenCLImageTypes.def from clangAST to clangBasic library.Alexey Bader2016-04-131-1/+1
| | | | | | | | | | Putting OpenCLImageTypes.def to clangAST library violates layering requirement: "It's not OK for a Basic/ header to include an AST/ header". This fixes the modules build. Differential revision: http://reviews.llvm.org/D18954 Reviewers: Richard Smith, Vassil Vassilev. llvm-svn: 266180
* [OpenCL] Complete image types support.Alexey Bader2016-04-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I. Current implementation of images is not conformant to spec in the following points: 1. It makes no distinction with respect to access qualifiers and therefore allows to use images with different access type interchangeably. The following code would compile just fine: void write_image(write_only image2d_t img); kernel void foo(read_only image2d_t img) { write_image(img); } // Accepted code which is disallowed according to s6.13.14. 2. It discards access qualifier on generated code, which leads to generated code for the above example: call void @write_image(%opencl.image2d_t* %img); In OpenCL2.0 however we can have different calls into write_image with read_only and wite_only images. Also generally following compiler steps have no easy way to take different path depending on the image access: linking to the right implementation of image types, performing IR opts and backend codegen differently. 3. Image types are language keywords and can't be redeclared s6.1.9, which can happen currently as they are just typedef names. 4. Default access qualifier read_only is to be added if not provided explicitly. II. This patch corrects the above points as follows: 1. All images are encapsulated into a separate .def file that is inserted in different points where image handling is required. This avoid a lot of code repetition as all images are handled the same way in the code with no distinction of their exact type. 2. The Cartesian product of image types and image access qualifiers is added to the builtin types. This simplifies a lot handling of access type mismatch as no operations are allowed by default on distinct Builtin types. Also spec intended access qualifier as special type qualifier that are combined with an image type to form a distinct type (see statement above - images can't be created w/o access qualifiers). 3. Improves testing of images in Clang. Author: Anastasia Stulova Reviewers: bader, mgrang. Subscribers: pxli168, pekka.jaaskelainen, yaxunl. Differential Revision: http://reviews.llvm.org/D17821 llvm-svn: 265783
* [Sema] Handle UTF-8 invalid format string specifiersBruno Cardoso Lopes2016-03-294-5/+44
| | | | | | | | | | | | | | | | | Improve invalid format string specifier handling by printing out invalid specifiers characters with \x, \u and \U. Previously clang would print gargabe whenever the character is unprintable. Example, before: NSLog(@"%\u25B9"); => warning: invalid conversion specifier ' [-Wformat-invalid-specifier] after: NSLog(@"%\u25B9"); => warning: invalid conversion specifier '\u25b9' [-Wformat-invalid-specifier] Differential Revision: http://reviews.llvm.org/D18296 rdar://problem/24672159 llvm-svn: 264752
* [analyzer] Use BodyFarm-synthesized body even when actual body available.Devin Coughlin2016-03-281-6/+12
| | | | | | | | | | | | Change body autosynthesis to use the BodyFarm-synthesized body even when an actual body exists. This enables the analyzer to use the simpler, analyzer-provided body to model the behavior of the function rather than trying to understand the actual body. Further, this makes the analyzer robust against changes in headers that expose the implementations of those bodies. rdar://problem/25145950 llvm-svn: 264687
* P0184R0: Allow types of 'begin' and 'end' expressions in range-based for ↵Richard Smith2016-03-201-3/+6
| | | | | | loops to differ. llvm-svn: 263895
* [analyzer] Find ObjC 'self' decl even when block captures local named 'self'.Devin Coughlin2016-02-231-2/+6
| | | | | | | | | When looking up the 'self' decl in block captures, make sure to find the actual self declaration even when the block captures a local variable named 'self'. rdar://problem/24751280 llvm-svn: 261703
* Remove use of builtin comma operator.Richard Trieu2016-02-181-4/+12
| | | | | | Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261271
* [analyzer] Include comment mistakenly left out of r261243. NFC.Devin Coughlin2016-02-181-0/+8
| | | | | | It explains why we can't just synthesize bodies of setters in BodyFarm. llvm-svn: 261248
* [analyzer] Invalidate destination of std::copy() and std::copy_backward().Devin Coughlin2016-02-071-0/+15
| | | | | | | | | Now that the libcpp implementations of these methods has a branch that doesn't call memmove(), the analyzer needs to invalidate the destination for these methods explicitly. rdar://problem/23575656 llvm-svn: 260043
* Make headers self-contained.Benjamin Kramer2016-02-021-1/+1
| | | | llvm-svn: 259490
OpenPOWER on IntegriCloud