summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
* [clang] Fix handling of "%zd" format specifierAlexander Shaposhnikov2017-07-141-3/+2
| | | | | | | | | | | | | This diff addresses FIXME in lib/Analysis/PrintfFormatString.cpp and makes PrintfSpecifier::getArgType return the correct type. In particular, this change enables Clang to emit a warning on incorrect using of "%zd"/"%zn" format specifiers. Differential revision: https://reviews.llvm.org/D35427 Test plan: make check-all llvm-svn: 308067
* CFG: Add CFGElement for automatic variables that leave the scopeMatthias Gehre2017-07-122-45/+181
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This mimics the implementation for the implicit destructors. The generation of this scope leaving elements is hidden behind a flag to the CFGBuilder, thus it should not affect existing code. Currently, I'm missing a test (it's implicitly tested by the clang-tidy lifetime checker that I'm proposing). I though about a test using debug.DumpCFG, but then I would have to add an option to StaticAnalyzer/Core/AnalyzerOptions to enable the scope leaving CFGElement, which would only be useful to that particular test. Any other ideas how I could make a test for this feature? Reviewers: krememek, jordan_rose Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15031 llvm-svn: 307759
* [analyzer] Faster hashing of subsequences in CompoundStmts.Raphael Isemann2017-07-091-9/+20
| | | | | | | | | | | | | | Summary: This patches improves the hashing subsequences in CompoundStmts by incrementally hashing all subsequences with the same starting position. This results in a reduction of the time for this constraint while running over SQLite from 1.10 seconds to 0.55 seconds (-50%). Reviewers: NoQ Reviewed By: NoQ Subscribers: cfe-commits, xazax.hun, v.g.vassilev Differential Revision: https://reviews.llvm.org/D34364 llvm-svn: 307509
* [analyzer] Make StmtDataCollector part of the CloneDetection APIRaphael Isemann2017-07-091-185/+3
| | | | | | | | | | | | | | Summary: We probably want to use this useful templates in other pieces of code (e.g. the one from D34329), so we should make this public. Reviewers: NoQ Reviewed By: NoQ Subscribers: cfe-commits, xazax.hun, v.g.vassilev, johannes Differential Revision: https://reviews.llvm.org/D34880 llvm-svn: 307501
* Changed wording in commentRaphael Isemann2017-06-211-2/+1
| | | | llvm-svn: 305878
* [analyzer] Teach CloneDetection about Qt Meta-Object Compiler to filter auto ↵Leslie Zhai2017-06-201-1/+1
| | | | | | | | | | | | generated files Reviewers: v.g.vassilev, teemperor Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D34353 llvm-svn: 305774
* [analyzer] Teach CloneDetection about Qt Meta-Object CompilerLeslie Zhai2017-06-191-1/+18
| | | | | | | | | | Reviewers: v.g.vassilev, zaks.anna, NoQ, teemperor Reviewed By: v.g.vassilev, zaks.anna, NoQ, teemperor Differential Revision: https://reviews.llvm.org/D31320 llvm-svn: 305659
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-033-0/+4
| | | | llvm-svn: 304641
* [coroutines] Fix fallthrough diagnostics for coroutinesEric Fiselier2017-05-251-0/+2
| | | | | | | | | | | | | | | | | | | | Summary: This patch fixes a number of issues with the analysis warnings emitted when a coroutine may reach the end of the function w/o returning. * Fix bug where coroutines with `return_value` are incorrectly diagnosed as missing `co_return`'s. * Rework diagnostic message to no longer say "non-void coroutine", because that implies the coroutine doesn't have a void return type, which it might. In this case a non-void coroutine is one who's promise type does not contain `return_void()` As a side-effect of this patch, coroutine bodies that contain an invalid coroutine promise objects are marked as invalid. Reviewers: GorNishanov, rsmith, aaron.ballman, majnemer Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33532 llvm-svn: 303831
* Fix PR13910: Don't warn that __builtin_unreachable() is unreachableAlex Lorenz2017-04-111-2/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D25321 llvm-svn: 299951
* Fix unused lambda capture. Follow up to r299653.Ivan Krasin2017-04-061-1/+1
| | | | llvm-svn: 299671
* [analyzer] Reland r299544 "Add a modular constraint system to the CloneDetector"Artem Dergachev2017-04-061-519/+368
| | | | | | | | | | | | | | | | | | | | | | | | | | | Hopefully fix crashes by unshadowing the variable. Original commit message: A big part of the clone detection code is functionality for filtering clones and clone groups based on different criteria. So far this filtering process was hardcoded into the CloneDetector class, which made it hard to understand and, ultimately, to extend. This patch splits the CloneDetector's logic into a sequence of reusable constraints that are used for filtering clone groups. These constraints can be turned on and off and reodreder at will, and new constraints are easy to implement if necessary. Unit tests are added for the new constraint interface. This is a refactoring patch - no functional change intended. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23418 llvm-svn: 299653
* Revert "[analyzer] Add a modular constraint system to the CloneDetector"Artem Dergachev2017-04-051-368/+519
| | | | | | | | This reverts commit r299544. Crashes on tests on some buildbots. llvm-svn: 299550
* [analyzer] Add a modular constraint system to the CloneDetectorArtem Dergachev2017-04-051-519/+368
| | | | | | | | | | | | | | | | | | | | | | A big part of the clone detection code is functionality for filtering clones and clone groups based on different criteria. So far this filtering process was hardcoded into the CloneDetector class, which made it hard to understand and, ultimately, to extend. This patch splits the CloneDetector's logic into a sequence of reusable constraints that are used for filtering clone groups. These constraints can be turned on and off and reodreder at will, and new constraints are easy to implement if necessary. Unit tests are added for the new constraint interface. This is a refactoring patch - no functional change intended. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23418 llvm-svn: 299544
* -Wunreachable-code: 'true' and 'false' should not be treated as configurationAlex Lorenz2017-04-051-1/+7
| | | | | | | | | macros Clang should emit -Wunreachable-code warnings in C mode for code that's unreachable because of a 'false' or '!true' condition. llvm-svn: 299541
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-301-2/+2
| | | | llvm-svn: 299083
* Encapsulate FPOptions and use it consistentlyAdam Nemet2017-03-271-2/+2
| | | | | | | | | | | | | | | | | | Sema holds the current FPOptions which is adjusted by 'pragma STDC FP_CONTRACT'. This then gets propagated into expression nodes as they are built. This encapsulates FPOptions so that this propagation happens opaquely rather than directly with the fp_contractable on/off bit. This allows controlled transitioning of fp_contractable to a ternary value (off, on, fast). It will also allow adding more fast-math flags later. This is toward moving fp-contraction=fast from an LLVM TargetOption to a FastMathFlag in order to fix PR25721. Differential Revision: https://reviews.llvm.org/D31166 llvm-svn: 298877
* [analyzer] Fix crash when building CFG with variable of incomplete typeMartin Bohme2017-03-071-1/+1
| | | | | | | | | | | | | | | | | | Summary: I've included a unit test with a function template containing a variable of incomplete type. Clang compiles this without errors (the standard does not require a diagnostic in this case). Without the fix, this case triggers the crash. Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30636 llvm-svn: 297129
* Make helpers static. NFC.Benjamin Kramer2017-02-111-0/+2
| | | | llvm-svn: 294838
* Remove unused 'using' declaration. Found by clang-tidy: ↵Sylvestre Ledru2017-01-281-1/+0
| | | | | | misc-unused-using-decls NFC llvm-svn: 293381
* [analyzer] Consider function call arguments while building CallGraph.Artem Dergachev2017-01-271-0/+1
| | | | | | | | | | | | | | Function call can appear in the arguments of another function call, eg.: foo(bar()); This patch adds support for such cases. Patch by Ivan Sidorenko! Differential revision: https://reviews.llvm.org/D28905 llvm-svn: 293280
* PR31631: fix bad CFG (and bogus warnings) when an if-statement has an ↵Richard Smith2017-01-131-41/+36
| | | | | | init-statement and has binary operator as its condition. llvm-svn: 291964
* Avoid multiple -Wunreachable-code diagnostics that are triggered byAlex Lorenz2017-01-121-5/+15
| | | | | | | | | | | the same source range and use the unary operator fixit only when it actually silences the warning. rdar://24570531 Differential Revision: https://reviews.llvm.org/D28231 llvm-svn: 291757
* [analyzer] Fix crash in body farm for getter without implicit self.Devin Coughlin2017-01-111-0/+2
| | | | | | | | | | | | | | | | | Fix a crash in body farm when synthesizing a getter for a property synthesized for a property declared in a protocol on a class extension that shadows a declaration of the property in a category. In this case, Sema doesn't fill in the implicit 'self' parameter for the getter in the category, which leads to a crash when trying to synthesize the getter for it. To avoid the crash, skip getter synthesis in body farm if the self parameter is not filled int. rdar://problem/29938138 llvm-svn: 291635
* Extend -Wtautological-overlap-compare to more cases.Richard Trieu2017-01-041-3/+7
| | | | | | | | | | | Previously, -Wtautological-overlap-compare did not warn on cases where the boolean expression was in an assignment or return statement. This patch should cause all boolean statements to be passed to the tautological compare checks in the CFG analysis. This is one of the issues from PR13101 llvm-svn: 290920
* Fix os_log formating with arbitrary precision and field widthMehdi Amini2016-12-151-2/+27
| | | | llvm-svn: 289761
* [StaticAnalysis] Remove unnecessary parameter in CallGraphNode::addCallee.Haojian Wu2016-12-121-2/+2
| | | | | | | | | | | | | | | Summary: Remove the CallGraph in addCallee as it is not used in addCallee. It decouples addCallee from CallGraph, so that we can use CallGraphNode within our customized CallGraph. Reviewers: bkramer Subscribers: cfe-commits, ioeric Differential Revision: https://reviews.llvm.org/D27674 llvm-svn: 289431
* DR1295 and cleanup for P0135R1: Make our initialization code more directlyRichard Smith2016-12-091-6/+8
| | | | | | | | | | | | | | | mirror the description in the standard. Per DR1295, this means that binding a const / rvalue reference to a bit-field no longer "binds directly", and per P0135R1, this means that we materialize a temporary in reference binding after adjusting cv-qualifiers and before performing a derived-to-base cast. In C++11 onwards, this should have fixed the last case where we would materialize a temporary of the wrong type (with a subobject adjustment inside the MaterializeTemporaryExpr instead of outside), but we still have to deal with that possibility in C++98, unless we want to start using xvalues to represent materialized temporaries there too. llvm-svn: 289250
* CFGBuilder: Fix crash when visiting delete expression on dependent typeMartin Bohme2016-12-051-5/+7
| | | | | | | | | | | | | | Summary: CXXDeleteExpr::getDestroyedType() can return a null QualType if the destroyed type is a dependent type. This patch protects against this. Reviewers: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27350 llvm-svn: 288665
* DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith2016-12-032-1/+4
| | | | | | | temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
* [ReachableCode] Skip over ExprWithCleanups in isConfigurationValueTim Shen2016-11-011-0/+2
| | | | | | | | | | | | Summary: Fixes pr29152. Reviewers: rsmith, pirama, krememek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24010 llvm-svn: 285657
* NFC small formatPiotr Padlewski2016-10-291-1/+2
| | | | llvm-svn: 285496
* Fix handling of %% format specifier in os_log builtins.Mehdi Amini2016-10-251-1/+1
| | | | | | | Returning `false` was stopping the parsing of further arguments, which wasn't intended. llvm-svn: 285047
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-244-2/+222
| | | | | | | | | | | | | | | | | This reverts commit r285007 and reapply r284990, with a fix for the opencl test that I broke. Original commit message follows: 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: 285019
* 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
OpenPOWER on IntegriCloud