summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/BodyFarm.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-25/+25
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [AST] Add a convenient getter from QualType to RecordDeclGeorge Karpenkov2018-07-281-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D49951 llvm-svn: 338187
* [analyzer] Do not crash on callback for call_once passed by valueGeorge Karpenkov2018-05-161-10/+13
| | | | | | | | | https://bugs.llvm.org/show_bug.cgi?id=37312 rdar://40270582 Differential Revision: https://reviews.llvm.org/D46913 llvm-svn: 332422
* [clang] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-15/+16
| | | | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Explicitly avoided changing the strings in the clang-format tests. Differential Revision: https://reviews.llvm.org/D44975 llvm-svn: 332350
* [analyzer] Fix yet-another-crash in body-farming std::call_onceGeorge Karpenkov2018-02-021-1/+10
| | | | | | | | | | | | | | Crash occurs when parameters to the callback and to std::call_once mismatch, and C++ is supposed to auto-construct an argument. Filed by Alexander Kornienko in https://bugs.llvm.org/show_bug.cgi?id=36149 rdar://37034403 Differential Revision: https://reviews.llvm.org/D42777 llvm-svn: 324046
* Track in the AST whether the operand to a UnaryOperator can overflow and ↵Aaron Ballman2018-01-091-3/+6
| | | | | | then use that logic when evaluating constant expressions and emitting codegen. llvm-svn: 322074
* [AST] Inline CompoundStmt contents into the parent allocation.Benjamin Kramer2017-12-241-1/+1
| | | | | | Saves a pointer on every CompoundStmt. llvm-svn: 321429
* [analyzer] Model correct dispatch_once() 'done' value in BodyFarmDevin Coughlin2017-11-061-21/+16
| | | | | | | | | | | | | | | | | | | | | | | The analyzer's BodyFarm models dispatch_once() by comparing the passed-in predicate against a known 'done' value. If the predicate does not have that value, the model updates the predicate to have that value and executes the passed in block. Unfortunately, the current model uses the wrong 'done' value: 1 instead of ~0. This interferes with libdispatch's static inline function _dispatch_once(), which enables a fast path if the block has already been executed. That function uses __builtin_assume() to tell the compiler that the done flag is set to ~0 on exit. When r302880 added modeling of __builtin_assume(), this caused the analyzer to assume 1 == ~0. This in turn caused the analyzer to never explore any code after a call to dispatch_once(). This patch regains the missing coverage by updating BodyFarm to use the correct 'done' value. rdar://problem/34413048 Differential Revision: https://reviews.llvm.org/D39691 llvm-svn: 317516
* [analyzer] do not crash on libcxx03 call_once implementationGeorge Karpenkov2017-11-031-8/+16
| | | | | | | | Addresses https://bugs.llvm.org/show_bug.cgi?id=35075, rdar://35230961 Differential Revision: https://reviews.llvm.org/D39518 llvm-svn: 317293
* [Analyzer] Remove spaces inside comments mentioning the parameter name,George Karpenkov2017-10-251-34/+34
| | | | | | | to aid clang-tidy comprehension. Requested by @alexfh in https://reviews.llvm.org/D39015 llvm-svn: 316539
* [Analyzer] Handle implicit function reference in bodyfarming std::call_onceGeorge Karpenkov2017-10-241-8/+20
| | | | | | Differential Revision: https://reviews.llvm.org/D39201 llvm-svn: 316402
* [Analyzer] Do not use static storage to for implementations created in ↵George Karpenkov2017-10-231-1/+1
| | | | | | | | BodyFarm.cpp Differential Revision: https://reviews.llvm.org/D39208 llvm-svn: 316400
* [Analyzer] Correctly handle parameters passed by reference when bodyfarming ↵George Karpenkov2017-10-201-14/+44
| | | | | | | | | | std::call_once Explicitly not supporting functor objects. Differential Revision: https://reviews.llvm.org/D39031 llvm-svn: 316249
* [Analyzer] Always use non-reference types when creating expressions in BodyFarm.George Karpenkov2017-10-171-22/+14
| | | | | | | | | | | | | | Remove an option to use a reference type (on by default!) since a non-reference type is always needed for creating expressions, functions with multiple boolean parameters are very hard to use, and in general it was just a booby trap for further crashes. Furthermore, generalize call_once test case to fix some of the crashes mentioned https://bugs.llvm.org/show_bug.cgi?id=34869 Also removes std::call_once crash. Differential Revision: https://reviews.llvm.org/D39015 llvm-svn: 316041
* [Analyzer] Support bodyfarming libstdc++ implementation of std::call_once.George Karpenkov2017-10-111-19/+25
| | | | | | Differential Revision: https://reviews.llvm.org/D38810 llvm-svn: 315508
* [Analyzer] Do not segfault on unexpected call_once implementationGeorge Karpenkov2017-10-091-16/+22
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=34869 Differential Revision: https://reviews.llvm.org/D38702 llvm-svn: 315250
* [Analyzer] Avoid copy and modifying passed reference in ↵George Karpenkov2017-10-021-16/+18
| | | | | | | | BodyFarm::create_call_once Differential Revision: https://reviews.llvm.org/D38475 llvm-svn: 314722
* [Analysis] Remove unused makeLvalueToRValue variant.Davide Italiano2017-09-301-13/+0
| | | | llvm-svn: 314605
* [Analyzer] Synthesize function body for std::call_onceGeorge Karpenkov2017-09-301-28/+288
| | | | | | Differential Revision: https://reviews.llvm.org/D37840 llvm-svn: 314571
* 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 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
* P0305R0: Semantic analysis and code generation for C++17 init-statement for ↵Richard Smith2016-07-141-4/+4
| | | | | | | | | | 'if' and 'switch': if (stmt; condition) { ... } Patch by Anton Bikineev! Some minor formatting and comment tweets by me. llvm-svn: 275350
* Implement p0292r2 (constexpr if), a likely C++1z feature.Richard Smith2016-06-231-2/+2
| | | | llvm-svn: 273602
* [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
* Class Property: class property and instance property can have the same name.Manman Ren2016-01-281-1/+1
| | | | | | | | | | | | | | | | | | | Add "enum ObjCPropertyQueryKind" to a few APIs that used to only take the name of the property: ObjCPropertyDecl::findPropertyDecl, ObjCContainerDecl::FindPropertyDeclaration, ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass, ObjCImplDecl::FindPropertyImplDecl, and Sema::ActOnPropertyImplDecl. ObjCPropertyQueryKind currently has 3 values: OBJC_PR_query_unknown, OBJC_PR_query_instance, OBJC_PR_query_class This extra parameter specifies that we are looking for an instance property with the given name, or a class property with the given name, or any property with the given name (if both exist, the instance property will be returned). rdar://23891898 llvm-svn: 259070
* [analyzer] Body farm: Look for property ivar in shadowing readwrite property.Devin Coughlin2016-01-261-1/+40
| | | | | | | | | | | | After r251874, readonly properties that are shadowed by a readwrite property in a class extension no longer have an instance variable, which caused the body farm to not synthesize getters. Now, if a readonly property does not have an instance variable look for a shadowing property and try to get the instance variable from there. rdar://problem/24060091 llvm-svn: 258886
* Refactor: simplify boolean conditional return statements in lib/AnalysisAlexander Kornienko2015-11-061-4/+1
| | | | | | | | Patch by Richard Thomson! Differential revision: http://reviews.llvm.org/D10008 llvm-svn: 252256
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* [cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.pyChandler Carruth2015-01-141-1/+1
| | | | | | | | | | Sorry for the noise, I managed to miss a bunch of recent regressions of include orderings here. This should actually sort all the includes for Clang. Again, no functionality changed, this is just a mechanical cleanup that I try to run periodically to keep the #include lines as regular as possible across the project. llvm-svn: 225979
* Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFCAlexey Bataev2015-01-121-1/+1
| | | | llvm-svn: 225624
* Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.Alexey Bataev2014-12-161-1/+1
| | | | | | | Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments. No functional changes. llvm-svn: 224329
* Add support for the static analyzer to synthesize function implementations ↵Ted Kremenek2014-08-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from external model files. Currently the analyzer lazily models some functions using 'BodyFarm', which constructs a fake function implementation that the analyzer can simulate that approximates the semantics of the function when it is called. BodyFarm does this by constructing the AST for such definitions on-the-fly. One strength of BodyFarm is that all symbols and types referenced by synthesized function bodies are contextual adapted to the containing translation unit. The downside is that these ASTs are hardcoded in Clang's own source code. A more scalable model is to allow these models to be defined as source code in separate "model" files and have the analyzer use those definitions lazily when a function body is needed. Among other things, it will allow more customization of the analyzer for specific APIs and platforms. This patch provides the initial infrastructure for this feature. It extends BodyFarm to use an abstract API 'CodeInjector' that can be used to synthesize function bodies. That 'CodeInjector' is implemented using a new 'ModelInjector' in libFrontend, which lazily parses a model file and injects the ASTs into the current translation unit. Models are currently found by specifying a 'model-path' as an analyzer option; if no path is specified the CodeInjector is not used, thus defaulting to the current behavior in the analyzer. Models currently contain a single function definition, and can be found by finding the file <function name>.model. This is an initial starting point for something more rich, but it bootstraps this feature for future evolution. This patch was contributed by Gábor Horváth as part of his Google Summer of Code project. Some notes: - This introduces the notion of a "model file" into FrontendAction and the Preprocessor. This nomenclature is specific to the static analyzer, but possibly could be generalized. Essentially these are sources pulled in exogenously from the principal translation. Preprocessor gets a 'InitializeForModelFile' and 'FinalizeForModelFile' which could possibly be hoisted out of Preprocessor if Preprocessor exposed a new API to change the PragmaHandlers and some other internal pieces. This can be revisited. FrontendAction gets a 'isModelParsingAction()' predicate function used to allow a new FrontendAction to recycle the Preprocessor and ASTContext. This name could probably be made something more general (i.e., not tied to 'model files') at the expense of losing the intent of why it exists. This can be revisited. - This is a moderate sized patch; it has gone through some amount of offline code review. Most of the changes to the non-analyzer parts are fairly small, and would make little sense without the analyzer changes. - Most of the analyzer changes are plumbing, with the interesting behavior being introduced by ModelInjector.cpp and ModelConsumer.cpp. - The new functionality introduced by this change is off-by-default. It requires an analyzer config option to enable. llvm-svn: 216550
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-5/+3
| | | | | | just letting them be implicitly created. llvm-svn: 216528
* [C++11] Use 'nullptr'. Analysis edition.Craig Topper2014-05-201-38/+39
| | | | llvm-svn: 209191
* [C++11] Replacing ObjCCategoryDecl iterators propimpl_begin() and ↵Aaron Ballman2014-03-141-4/+1
| | | | | | propimpl_end() with iterator_range property_impls(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203930
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-3/+3
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* [analyzer] Tighten up sanity checks on Objective-C property getter synthesis.Jordan Rose2014-01-231-5/+22
| | | | | | | | | | | If there are non-trivially-copyable types /other/ than C++ records, we won't have a synthesized copy expression, but we can't just use a simple load/return. Also, add comments and shore up tests, making sure to test in both ARC and non-ARC. llvm-svn: 199869
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-2/+1
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* [analyzer] Use synthesized ASTs for property getters when available.Jordan Rose2014-01-141-6/+18
| | | | | | | This allows the analyzer to handle properties with C++ class type, finishing up the FIXME from r198953. llvm-svn: 199226
* [analyzer] Model getters of known-@synthesized Objective-C properties.Jordan Rose2014-01-101-0/+70
| | | | | | | | | | | | | | | | | | | | | ...by synthesizing their body to be "return self->_prop;", with an extra nudge to RetainCountChecker to still treat the value as +0 if we have no other information. This doesn't handle weak properties, but that's mostly correct anyway, since they can go to nil at any time. This also doesn't apply to properties whose implementations we can't see, since they may not be backed by an ivar at all. And finally, this doesn't handle properties of C++ class type, because we can't invoke the copy constructor. (Sema has actually done this work already, but the AST it synthesizes is one the analyzer doesn't quite handle -- it has an rvalue DeclRefExpr.) Modeling setters is likely to be more difficult (since it requires handling strong/copy), but not impossible. <rdar://problem/11956898> llvm-svn: 198953
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-4/+4
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* Include llvm::Optional in clang/Basic/LLVM.hDavid Blaikie2013-02-201-1/+1
| | | | | | Post-commit CR feedback from Jordan Rose regarding r175594. llvm-svn: 175679
* [analyzer] add commentAnna Zaks2013-02-051-1/+5
| | | | llvm-svn: 174435
* ArrayRefize a CompoundStmt constructor.Nico Weber2012-12-291-3/+1
| | | | llvm-svn: 171238
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-3/+3
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Conditionally use an integral cast for BodyFarm support for ↵Ted Kremenek2012-10-121-6/+19
| | | | | | OSAtomicCompareAndSwap if the return type is not a boolean. llvm-svn: 165774
* Switch over to BodyFarm implementation of OSAtomicCompareAndSwap andTed Kremenek2012-10-111-12/+129
| | | | | | objc_atomicCompareAndSwap. llvm-svn: 165743
* Add FP_CONTRACT support for clang.Lang Hames2012-10-021-1/+1
| | | | | | | | Clang will now honor the FP_CONTRACT pragma and emit LLVM fmuladd intrinsics for expressions of the form A * B + C (when they occur in a single statement). llvm-svn: 164989
* Experiment in BodyFarm of structuring AST creation calls in a hierarchy,Ted Kremenek2012-09-211-12/+21
| | | | | | so that they visually look like an AST dump. llvm-svn: 164401
OpenPOWER on IntegriCloud