summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
...
* [analyzer] print() JSONify: ProgramPoint revisionCsaba Dabis2019-06-241-1/+2
| | | | | | | | | | | | | | | | | Summary: Now we also print out the filename with its path. Reviewers: NoQ Reviewed By: NoQ Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63438 llvm-svn: 364197
* [analyzer] Fix JSON dumps for location contexts.Artem Dergachev2019-06-191-2/+3
| | | | | | | | | | | Location context ID is a property of the location context, not of an item within it. It's useful to know the id even when there are no items in the context, eg. for the purposes of figuring out how did contents of the Environment for the same location context changed across states. Differential Revision: https://reviews.llvm.org/D62754 llvm-svn: 363895
* [analyzer] RetainCount: Add support for OSRequiredCast().Artem Dergachev2019-06-191-1/+8
| | | | | | | | | | | | | | It's a new API for custom RTTI in Apple IOKit/DriverKit framework that is similar to OSDynamicCast() that's already supported, but crashes instead of returning null (and therefore causing UB when the cast fails unexpectedly). Kind of like cast_or_null<> as opposed to dyn_cast_or_null<> in LLVM's RTTI. Historically, RetainCountChecker was responsible for modeling OSDynamicCast. This is simply an extension of the same functionality. Differential Revision: https://reviews.llvm.org/D63117 llvm-svn: 363891
* [analyzer] ProgramPoint: more explicit printJson()Csaba Dabis2019-06-121-17/+26
| | | | | | | | | | | | | | | | | Summary: Now we print out every possible kinds of ProgramPoints. Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62946 llvm-svn: 363187
* For DR712: store on a MemberExpr whether it constitutes an odr-use.Richard Smith2019-06-111-1/+1
| | | | llvm-svn: 363087
* [Analysis] Only build Analysis plugins when CLANG_ENABLE_STATIC_ANALYZER is ↵Don Hinton2019-06-041-1/+1
| | | | | | | | | | enabled. Fixes bug introduced in r362328. Thanks to Nathan Chancellor for reporting this! llvm-svn: 362555
* Re-check in clang support gun asm goto after fixing tests.Jennifer Yu2019-06-031-16/+58
| | | | llvm-svn: 362410
* [test] Fix plugin testsDon Hinton2019-06-0211-0/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recommit of r361790 that was temporarily reverted in r361793 due to bot breakage. Summary: The following changes were required to fix these tests: 1) Change LLVM_ENABLE_PLUGINS to an option and move it to llvm/CMakeLists.txt with an appropriate default -- which matches the original default behavior. 2) Move the plugins directory from clang/test/Analysis clang/lib/Analysis. It's not enough to add an exclude to the lit.local.cfg file because add_lit_testsuites recurses the tree and automatically adds the appropriate `check-` targets, which don't make sense for the plugins because they aren't tests and don't have `RUN` statements. Here's a list of the `clang-check-anlysis*` targets with this change: ``` $ ninja -t targets all| sed -n "s/.*\/\(check[^:]*\):.*/\1/p" | sort -u | grep clang-analysis check-clang-analysis check-clang-analysis-checkers check-clang-analysis-copypaste check-clang-analysis-diagnostics check-clang-analysis-engine check-clang-analysis-exploration_order check-clang-analysis-html_diagnostics check-clang-analysis-html_diagnostics-relevant_lines check-clang-analysis-inlining check-clang-analysis-objc check-clang-analysis-unified-sources check-clang-analysis-z3 ``` 3) Simplify the logic and only include the subdirectories under clang/lib/Analysis/plugins if LLVM_ENABLE_PLUGINS is set. Reviewed By: NoQ Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62445 llvm-svn: 362328
* Revert "clang support gnu asm goto."Erich Keane2019-05-301-58/+16
| | | | | | | | | | | This reverts commit 954ec09aed4f2be04bb5f4e10dbb4ea8bd19ef9a. Reverting due to test failures as requested by Jennifer Yu. Conflicts: clang/test/CodeGen/asm-goto.c llvm-svn: 362106
* clang support gnu asm goto.Jennifer Yu2019-05-301-16/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Syntax: asm [volatile] goto ( AssemblerTemplate : : InputOperands : Clobbers : GotoLabels) https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html New llvm IR is "callbr" for inline asm goto instead "call" for inline asm For: asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop); IR: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@foo, %label_true), i8* blockaddress(@foo, %loop)) #1 to label %asm.fallthrough [label %label_true, label %loop], !srcloc !3 asm.fallthrough: Compiler need to generate: 1> a dummy constarint 'X' for each label. 2> an unique fallthrough label for each asm goto stmt " asm.fallthrough%number". Diagnostic 1> duplicate asm operand name are used in output, input and label. 2> goto out of scope. llvm-svn: 362045
* [analyzer] print() JSONify: CFG implementationCsaba Dabis2019-05-292-6/+21
| | | | | | | | | | | | | | | | | Summary: - Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: cfe-commits, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D62496 llvm-svn: 362003
* [analyzer] print() JSONify: Decl revisionCsaba Dabis2019-05-291-6/+4
| | | | | | | | | | | | | | | | | Summary: - Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: cfe-commits, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D62495 llvm-svn: 362002
* [analyzer][AST] print() JSONify: Stmt implementationCsaba Dabis2019-05-291-27/+22
| | | | | | | | | | | | | | | | | | | | Summary: This patch also adds a function called `JsonFormat()` which: - Flattens the string so removes the new-lines. - Escapes double quotes. Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: cfe-commits, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D62494 llvm-svn: 362000
* [analyzer] print() JSONify: getNodeLabel implementationCsaba Dabis2019-05-291-93/+109
| | | | | | | | | | | | | | | | | Summary: This patch also rewrites the ProgramPoint printing. Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: cfe-commits, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D62346 llvm-svn: 361997
* [analyzer] print() JSONify: Environment implementationCsaba Dabis2019-05-291-20/+75
| | | | | | | | | | | | | | | | | Summary: - Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D62081 llvm-svn: 361976
* Revert [test] Fix plugin testsDon Hinton2019-05-2811-169/+0
| | | | | | | | This reverts r361790 (git commit fe5eaab2b5b4523886bd63aebcfea8cfce586fa1) It's causing buildbot breakage, so reverting while I investigate. llvm-svn: 361793
* [test] Fix plugin testsDon Hinton2019-05-2811-0/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The following changes were required to fix these tests: 1) Change LLVM_ENABLE_PLUGINS to an option and move it to llvm/CMakeLists.txt with an appropriate default -- which matches the original default behavior. 2) Move the plugins directory from clang/test/Analysis clang/lib/Analysis. It's not enough to add an exclude to the lit.local.cfg file because add_lit_testsuites recurses the tree and automatically adds the appropriate `check-` targets, which don't make sense for the plugins because they aren't tests and don't have `RUN` statements. Here's a list of the `clang-check-anlysis*` targets with this change: ``` $ ninja -t targets all| sed -n "s/.*\/\(check[^:]*\):.*/\1/p" | sort -u | grep clang-analysis check-clang-analysis check-clang-analysis-checkers check-clang-analysis-copypaste check-clang-analysis-diagnostics check-clang-analysis-engine check-clang-analysis-exploration_order check-clang-analysis-html_diagnostics check-clang-analysis-html_diagnostics-relevant_lines check-clang-analysis-inlining check-clang-analysis-objc check-clang-analysis-unified-sources check-clang-analysis-z3 ``` 3) Simplify the logic and only include the subdirectories under clang/lib/Analysis/plugins if LLVM_ENABLE_PLUGINS is set. Reviewed By: NoQ Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62445 llvm-svn: 361790
* [CFG] Add branch to skip vbase inits when they're handled by superclass.Artem Dergachev2019-05-242-3/+38
| | | | | | | | | | | | | | | | | | | This patch adds the run-time CFG branch that would skip initialization of virtual base classes depending on whether the constructor is called from a superclass constructor or not. Previously the Static Analyzer was already skipping virtual base-class initializers in such constructors, but it wasn't skipping their arguments and their potential side effects, which was causing pr41300 (and was generally incorrect). The previous skipping behavior is now replaced with a hard assertion that we're not even getting there due to how our CFG works. The new CFG element is under a CFG build option so that not to break other consumers of the CFG by this change. Static Analyzer support for this change is implemented. Differential Revision: https://reviews.llvm.org/D61816 llvm-svn: 361681
* [CFG] NFC: Remove implicit conversion from CFGTerminator to Stmt *.Artem Dergachev2019-05-248-28/+36
| | | | | | | | | | | Turn it into a variant class instead. This conversion does indeed save some code but there's a plan to add support for more kinds of terminators that aren't necessarily based on statements, and with those in mind it becomes more and more confusing to have CFGTerminators implicitly convertible to a Stmt *. Differential Revision: https://reviews.llvm.org/D61814 llvm-svn: 361586
* [c++20] Implement P1009R2: allow omitting the array bound in an arrayRichard Smith2019-05-061-2/+2
| | | | | | | | | | new expression. This was voted into C++20 as a defect report resolution, so we retroactively apply it to all prior language modes (though it can never actually be used before C++11 mode). llvm-svn: 360006
* [analyzer] Treat functions without run-time branches as "small".Artem Dergachev2019-04-301-0/+45
| | | | | | | | | | | | | | | | | | Currently we always inline functions that have no branches, i.e. have exactly three CFG blocks: ENTRY, some code, EXIT. This makes sense because when there are no branches, it means that there's no exponential complexity introduced by inlining such function. Such functions also don't trigger various fundamental problems with our inlining mechanism, such as the problem of inlined defensive checks. Sometimes the CFG may contain more blocks, but in practice it still has linear structure because all directions (except, at most, one) of all branches turned out to be unreachable. When this happens, still treat the function as "small". This is useful, in particular, for dealing with C++17 if constexpr. Differential Revision: https://reviews.llvm.org/D61051 llvm-svn: 359531
* [analyzer] RetainCount: Add a suppression for "the Matching rule".Artem Dergachev2019-04-261-14/+21
| | | | | | | | | | | | | | | | In the OSObject universe there appears to be another slightly popular contract, apart from "create" and "get", which is "matching". It optionally consumes a "table" parameter and if a table is passed, it fills in the table and returns it at +0; otherwise, it creates a new table, fills it in and returns it at +1. For now suppress false positives by doing a conservative escape on all functions that end with "Matching", which is the naming convention that seems to be followed by all such methods. Differential Revision: https://reviews.llvm.org/D61161 llvm-svn: 359264
* Use llvm::stable_sortFangrui Song2019-04-241-5/+1
| | | | llvm-svn: 359098
* [analyzer] Unbreak body farms in presence of multiple declarations.Artem Dergachev2019-04-231-2/+0
| | | | | | | | | | | | | | When growing a body on a body farm, it's essential to use the same redeclaration of the function that's going to be used during analysis. Otherwise our ParmVarDecls won't match the ones that are used to identify argument regions. This boils down to trusting the reasoning in AnalysisDeclContext. We shouldn't canonicalize the declaration before farming the body because it makes us not obey the sophisticated decision-making process of AnalysisDeclContext. Differential Revision: https://reviews.llvm.org/D60899 llvm-svn: 358946
* Thread Safety: also look at ObjC methodsJF Bastien2019-03-251-8/+13
| | | | | | | | | | | | | | | | | Summary: SExprBuilder::translateDeclRefExpr was only looking at FunctionDecl and not also looking at ObjCMethodDecl. It should consider both because the attributes can be used on Objective-C as well. <rdar://problem/48941331> Reviewers: dexonsmith, erik.pilkington Subscribers: jkorous, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59523 llvm-svn: 356940
* [CFG] [analyzer] pr41142: C++17: Skip transparent InitListExprs in constructors.Artem Dergachev2019-03-211-0/+9
| | | | | | | | | | | | | | When searching for construction contexts, i.e. figuring out which statements define the object that is constructed by each construct-expression, ignore transparent init-list expressions because they don't add anything to the context. This allows the Static Analyzer to model construction, destruction, materialization, lifetime extension correctly in more cases. Also fixes a crash caused by incorrectly evaluating initial values of variables initialized with such expressions. Differential Revision: https://reviews.llvm.org/D59573 llvm-svn: 356634
* Thread safety analysis: Add note for unlock kind mismatchAaron Puchert2019-03-181-2/+2
| | | | | | | | | | | | | | | | | | Summary: Similar to D56967, we add the existing diag::note_locked_here to tell the user where we saw the locking that isn't matched correctly. Reviewers: aaron.ballman, delesley Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59455 llvm-svn: 356427
* [analyzer] RetainCount: A function isn't a CFRetain if it takes no arguments.Artem Dergachev2019-03-151-6/+7
| | | | | | | | | | | | | Don't crash when a function has a name that starts with "CF" and ends with "Retain" but takes 0 arguments. In particular, don't try to treat it as if it returns its first argument. These problems are inevitable because the checker is naming-convention-based, but at least we shouldn't crash. Differential Revision: https://reviews.llvm.org/D59123 llvm-svn: 356223
* [analyzer] handle modification of vars inside an expr with comma operatorPetar Jovanovic2019-03-071-13/+33
| | | | | | | | | | | | | | | | | We should track mutation of a variable within a comma operator expression. Current code in ExprMutationAnalyzer does not handle it. This will handle cases like: (a, b) ++ < == b is modified (a, b) = c < == b is modifed Patch by Djordje Todorovic. Differential Revision: https://reviews.llvm.org/D58894 llvm-svn: 355605
* Fix file headers. NFCFangrui Song2019-03-011-1/+1
| | | | llvm-svn: 355176
* Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a ↵Sam McCall2019-02-151-4/+0
| | | | | | | | foreach loop" This reverts commit r354102. llvm-svn: 354109
* [Analysis] -Wunreachable-code shouldn't fire on the increment of a foreach loopSam McCall2019-02-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The idea is that the code here isn't written, so doesn't indicate a bug. Similar to code expanded from macros. This means the warning no longer fires on this code: for (auto C : collection) { process(C); return; } handleEmptyCollection(); Unclear whether this is more often a bug or not in practice, I think it's a reasonable idiom in some cases. Either way, if we want to warn on "loop that doesn't loop", I think it should be a separate warning, and catch `while(1) break;` Reviewers: ilya-biryukov, ioeric Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58134 llvm-svn: 354102
* [analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track ↵George Karpenkov2019-02-051-6/+6
| | | | | | | | CXX method calls Differential Revision: https://reviews.llvm.org/D57782 llvm-svn: 353227
* [AST] Update the comments of the various Expr::Ignore* + Related cleanupsBruno Ricci2019-02-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The description of what the various Expr::Ignore* do has drifted from the actual implementation. Inspection reveals that IgnoreParenImpCasts() is not equivalent to doing IgnoreParens() + IgnoreImpCasts() until reaching a fixed point, but IgnoreParenCasts() is equivalent to doing IgnoreParens() + IgnoreCasts() until reaching a fixed point. There is also a fair amount of duplication in the various Expr::Ignore* functions which increase the chance of further future inconsistencies. In preparation for the next patch which will factor out the implementation of the various Expr::Ignore*, do the following cleanups: Remove Stmt::IgnoreImplicit, in favor of Expr::IgnoreImplicit. IgnoreImplicit is the only function among all of the Expr::Ignore* which is available in Stmt. There are only a few users of Stmt::IgnoreImplicit. They can just use instead Expr::IgnoreImplicit like they have to do for the other Ignore*. Move Expr::IgnoreImpCasts() from Expr.h to Expr.cpp. This made no difference in the run-time with my usual benchmark (-fsyntax-only on all of Boost). While we are at it, make IgnoreParenNoopCasts take a const reference to the ASTContext for const correctness. Update the comments to match what the Expr::Ignore* are actually doing. I am not sure that listing exactly what each Expr::Ignore* do is optimal, but it certainly looks better than the current state which is in my opinion between misleading and just plain wrong. The whole patch is NFC (if you count removing Stmt::IgnoreImplicit as NFC). Differential Revision: https://reviews.llvm.org/D57266 Reviewed By: aaron.ballman llvm-svn: 353006
* Add a new builtin: __builtin_dynamic_object_sizeErik Pilkington2019-01-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This builtin has the same UI as __builtin_object_size, but has the potential to be evaluated dynamically. It is meant to be used as a drop-in replacement for libraries that use __builtin_object_size when a dynamic checking mode is enabled. For instance, __builtin_object_size fails to provide any extra checking in the following function: void f(size_t alloc) { char* p = malloc(alloc); strcpy(p, "foobar"); // expands to __builtin___strcpy_chk(p, "foobar", __builtin_object_size(p, 0)) } This is an overflow if alloc < 7, but because LLVM can't fold the object size intrinsic statically, it folds __builtin_object_size to -1. With __builtin_dynamic_object_size, alloc is passed through to __builtin___strcpy_chk. rdar://32212419 Differential revision: https://reviews.llvm.org/D56760 llvm-svn: 352665
* [analyzer] [RetainCountChecker] Bugfix for tracking top-level parameters of ↵George Karpenkov2019-01-301-2/+2
| | | | | | | | Objective-C methods Differential Revision: https://reviews.llvm.org/D57433 llvm-svn: 352588
* Thread safety analysis: Improve diagnostics for double lockingAaron Puchert2019-01-291-4/+5
| | | | | | | | | | | | | | | | Summary: We use the existing diag::note_locked_here to tell the user where we saw the first locking. Reviewers: aaron.ballman, delesley Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56967 llvm-svn: 352549
* [analyzer] [RetainCountChecker] Track input parameters to the top-level functionGeorge Karpenkov2019-01-291-1/+44
| | | | | | | | | | Track them for ISL/OS objects by default, and for NS/CF under a flag. rdar://47536377 Differential Revision: https://reviews.llvm.org/D57356 llvm-svn: 352534
* [analyzer] [RetainSummaryManager] [NFC] Split one function into two, as it's ↵George Karpenkov2019-01-291-56/+42
| | | | | | | | really doing two things Differential Revision: https://reviews.llvm.org/D57201 llvm-svn: 352533
* [analyzer] [ARCMT] [NFC] Unify entry point into RetainSummaryManagerGeorge Karpenkov2019-01-291-31/+6
| | | | | | | | Just use one single entry point, since we have AnyCall utility now. Differential Revision: https://reviews.llvm.org/D57346 llvm-svn: 352532
* [analyzer] [RetainCountChecker] Support 'taggedRetain' and 'taggedRelease'George Karpenkov2019-01-291-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D57211 llvm-svn: 352530
* [analyzer] Port RetainSummaryManager to the new AnyCall interface, decouple ↵George Karpenkov2019-01-252-0/+1269
| | | | | | | | | | ARCMT from the analyzer rdar://19694750 Differential Revision: https://reviews.llvm.org/D57127 llvm-svn: 352149
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1923-92/+69
| | | | | | | | | | | | | | | | | 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] Do not try to body-farm Objective-C properties with custom accessors.Artem Dergachev2019-01-181-0/+5
| | | | | | | | | | | | | | | | If a property is defined with a custom getter, we should not behave as if the getter simply returns an instance variable. We don't support setters, so they aren't affected. On top of being the right thing to do, this also fixes a crash on the newly added test - in which a property and its getter are defined in two separate categories. rdar://problem/47051544 Differential Revision: https://reviews.llvm.org/D56823 llvm-svn: 351609
* [AST] Remove ASTContext from getThisType (NFC)Brian Gesiak2019-01-111-10/+6
| | | | | | | | | | | | | | | | | | | | | Summary: https://reviews.llvm.org/D54862 removed the usages of `ASTContext&` from within the `CXXMethodDecl::getThisType` method. Remove the parameter altogether, as well as all usages of it. This does not result in any functional change because the parameter was unused since https://reviews.llvm.org/D54862. Test Plan: check-clang Reviewers: akyrtzi, mikael Reviewed By: mikael Subscribers: mehdi_amini, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D56509 llvm-svn: 350914
* [AST] Store the callee and argument expressions of CallExpr in a trailing array.Bruno Ricci2018-12-211-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since CallExpr::setNumArgs has been removed, it is now possible to store the callee expression and the argument expressions of CallExpr in a trailing array. This saves one pointer per CallExpr, CXXOperatorCallExpr, CXXMemberCallExpr, CUDAKernelCallExpr and UserDefinedLiteral. Given that CallExpr is used as a base of the above classes we cannot use llvm::TrailingObjects. Instead we store the offset in bytes from the this pointer to the start of the trailing objects and manually do the casts + arithmetic. Some notes: 1.) I did not try to fit the number of arguments in the bit-fields of Stmt. This leaves some space for future additions and avoid the discussion about whether x bits are sufficient to hold the number of arguments. 2.) It would be perfectly possible to recompute the offset to the trailing objects before accessing the trailing objects. However the trailing objects are frequently accessed and benchmarks show that it is slightly faster to just load the offset from the bit-fields. Additionally, because of 1), we have plenty of space in the bit-fields of Stmt. Differential Revision: https://reviews.llvm.org/D55771 Reviewed By: rjmccall llvm-svn: 349910
* [AST][NFC] Pass the AST context to one of the ctor of DeclRefExpr.Bruno Ricci2018-12-212-4/+7
| | | | | | | | | All of the other constructors already take a reference to the AST context. This avoids calling Decl::getASTContext in most cases. Additionally move the definition of the constructor from Expr.h to Expr.cpp since it is calling DeclRefExpr::computeDependence. NFC. llvm-svn: 349901
* [analyzer] Fix some expressions staying live too long. Add a debug checker.Artem Dergachev2018-12-161-0/+48
| | | | | | | | | | | | | | | | | | | | | StaticAnalyzer uses the CFG-based RelaxedLiveVariables analysis in order to, in particular, figure out values of which expressions are still needed. When the expression becomes "dead", it is garbage-collected during the dead binding scan. Expressions that constitute branches/bodies of control flow statements, eg. `E1' in `if (C1) E1;' but not `E2' in `if (C2) { E2; }', were kept alive for too long. This caused false positives in MoveChecker because it relies on cleaning up loop-local variables when they go out of scope, but some of those live-for-too-long expressions were keeping a reference to those variables. Fix liveness analysis to correctly mark these expressions as dead. Add a debug checker, debug.DumpLiveStmts, in order to test expressions liveness. Differential Revision: https://reviews.llvm.org/D55566 llvm-svn: 349320
* Thread safety analysis: Avoid intermediate copies [NFC]Aaron Puchert2018-12-161-21/+31
| | | | | | | The main reason is to reduce the number of constructor arguments though, especially since many of them had the same type. llvm-svn: 349308
* Thread safety analysis: Allow scoped releasing of capabilitiesAaron Puchert2018-12-161-39/+73
| | | | | | | | | | | | | | | | | | | | | | Summary: The pattern is problematic with C++ exceptions, and not as widespread as scoped locks, but it's still used by some, for example Chromium. We are a bit stricter here at join points, patterns that are allowed for scoped locks aren't allowed here. That could still be changed in the future, but I'd argue we should only relax this if people ask for it. Fixes PR36162. Reviewers: aaron.ballman, delesley, pwnall Reviewed By: delesley, pwnall Subscribers: pwnall, cfe-commits Differential Revision: https://reviews.llvm.org/D52578 llvm-svn: 349300
OpenPOWER on IntegriCloud