[PATCH] D38675: [analyzer] MisusedMovedObjectChecker: Moving the checker out of alpha state

2017-10-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Last time i was running on WebKit; i already lost my results, so i'd try to reproduce the results on the fixed checker and follow up. Apart from https://reviews.llvm.org/D31538, i've seen a few cases where a method was safe to be called on a moved-from object (which led me

[PATCH] D38797: [analyzer] CStringChecker: pr34460: Admit that some casts are hard to model.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. Herald added a subscriber: szepet. In https://bugs.llvm.org/show_bug.cgi?id=34460 CStringChecker tries to `evalCast()` a memory region from `void *` to `char *` for the purposes of modeling `mempcpy()`. The memory region turned out to be an element region of type `uns

[PATCH] D38797: [analyzer] CStringChecker: pr34460: Admit that some casts are hard to model.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: test/Analysis/casts.c:134-139 + clang_analyzer_eval(y1 == y2); // expected-warning{{TRUE}} + + // FIXME: should be FALSE (i.e. equal pointers). + clang_analyzer_eval(y1 - y2); // expected-warning{{UNKNOWN}} + // FIXME: should be TRUE (i.

[PATCH] D38801: [analyzer] In getSVal() API, disable auto-detection of void type as char type.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. Herald added a subscriber: szepet. In https://reviews.llvm.org/D38358, we ended up believing that reading the first byte of the void pointer is not the intended behavior of `ProgramState::getSVal(Loc)`. Hence the fix. Additionally, allow specifying the type in the `Pr

[PATCH] D23963: [analyzer] pr28449 - Move literal rvalue construction away from RegionStore.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 118625. NoQ added a comment. Herald added a subscriber: szepet. Because i didn't get back to this in a while, and similar crashes keep coming, i decided to leave this refactoring as a FIXME. https://reviews.llvm.org/D23963 Files: lib/StaticAnalyzer/Core/Regi

[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Ideas behind both hashing change and new testing mechanism look great to me. I think it would be great to split them into two different patches, to be able to easily see how the change in the hashing affects the tests (and maybe revert easily if something goes wrong). ==

[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. The other way round, i guess. I like the test change, it's easier to understand, so it's better to have it before starting to understand :) https://reviews.llvm.org/D38728 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D38877: [analyzer] RetainCount: Accept "safe" CFRetain wrappers.

2017-10-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. Herald added subscribers: szepet, xazax.hun. CoreFoundation users often look for a "safe" wrapper around `CFRetain` and `CFRelease` that would gracefully accept (and ignore) a null CF reference. Users are trying to annotate it with `CF_RETURNS_RETAINED`, which misleads

[PATCH] D38921: [analyzer] LoopUnrolling: update the matched assignment operators

2017-10-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Neat! Tests? https://reviews.llvm.org/D38921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D39174: [analyzer] Fix handling of labels in getLValueElement

2017-10-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Great. Probably one more reason to turn all `Loc`s into regions. Repository: rL LLVM https://reviews.llvm.org/D39174 ___ cfe-commits mailing list cf

[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-10-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. In https://reviews.llvm.org/D31868#904814, @MTC wrote: > > One of the possible improvements for future work here would be to actually > > bind the second argument value to the buffer instead of just invalidating > > it. Like, after `memset(buf, 0, sizeof(buf))` the analyzer

[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

2018-08-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added inline comments. This revision is now accepted and ready to land. Comment at: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:187-191 // If FR is a pointer pointing to a non-primitive type. if (Optional RecordV

[PATCH] D50855: [analyzer] pr37578: Fix lvalue/rvalue problem in field-of-temporary adjustments.

2018-08-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 162755. NoQ added a comment. Address comments. https://reviews.llvm.org/D50855 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/temporaries.cpp Index: test/Analysis/temporaries.cpp =

[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

2018-08-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: test/Analysis/cxx-uninitialized-object-inheritance.cpp:802 +struct DynTBase2 { + int x; // expected-note{{uninitialized field 'static_cast(this->bptr)->DynTBase2::x'}} +}; Mmm, what's the value of casting to derived type an

[PATCH] D51300: [analyzer][UninitializedObjectChecker] No longer using nonloc::LazyCompoundVal

2018-08-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Yup, looks correct to me! Comment at: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:448-449 Loc ThisLoc = Context.getSValBuilder().getCXXThis

[PATCH] D51385: [analyzer] InnerPointerChecker: Fix a segfault.

2018-08-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs. Herald added subscribers: cfe-commits, Szelethus, mikhail.ramalho, baloghadamsoftware. Return value of `dyn_cast_or_null` should be checked before use. Otherwise we may put a nul

[PATCH] D51388: [analyzer] Legalize state manager factory injection.

2018-08-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs. Herald added subscribers: cfe-commits, Szelethus, mikhail.ramalho, baloghadamsoftware. When a checker maintains a program state trait that isn't a simple list/set/map, but is a c

[PATCH] D51390: [analyzer] CallDescription: Improve array management.

2018-08-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs. Herald added subscribers: cfe-commits, Szelethus, mikhail.ramalho, baloghadamsoftware. `CallDescription` constructor now accepts an `ArrayRef`, instead of two different construct

[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: test/Analysis/cxx-uninitialized-object-inheritance.cpp:802 +struct DynTBase2 { + int x; // expected-note{{uninitialized field 'static_cast(this->bptr)->DynTBase2::x'}} +}; Szelethus wrote: > NoQ wrote: > > Mmm, what's the v

[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. Let's commit then? https://reviews.llvm.org/D50892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D51393: Provide a method for generating deterministic IDs for pointers allocated in BumpPtrAllocator

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. In https://reviews.llvm.org/D51393#1217644, @aprantl wrote: > Just for consideration: The raw pointers in dumps are sometimes useful while > in a debugger session, because you can cast a pointer and dump the object in > the debugger. Yup, i use that as well from time to t

[PATCH] D51390: [analyzer] CallDescription: Improve array management.

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Yeah, i guess i should've split those up. Well, i had to fix the other code when i fixed the first code, because it contains a hardcoded duplicate of the vector type. So i decided to fix it in a slightly more intelligent manner. Repository: rC Clang https://reviews.llv

[PATCH] D51300: [analyzer][UninitializedObjectChecker] No longer using nonloc::LazyCompoundVal

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:448-449 Loc ThisLoc = Context.getSValBuilder().getCXXThis(CtorDecl->getParent(), Context.getStackFrame(

[PATCH] D51393: Provide a method for generating deterministic IDs for pointers allocated in BumpPtrAllocator

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. In https://reviews.llvm.org/D51393#1218544, @george.karpenkov wrote: > In fact, generating a single "long" seems even better. `ptrdiff_t` seems to express what we're trying to say pretty accurately. https://reviews.llvm.org/D51393 __

[PATCH] D51385: [analyzer] InnerPointerChecker: Fix a segfault.

2018-08-30 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Ok, i'll get to the rest of the stuff a bit later (unless you pick it up). Repository: rC Clang https://reviews.llvm.org/D51385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/lis

[PATCH] D51300: [analyzer][UninitializedObjectChecker] No longer using nonloc::LazyCompoundVal

2018-09-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. In https://reviews.llvm.org/D51300#1220537, @Szelethus wrote: > Would you be comfortable me commiting this without that assert Yup sure. In https://reviews.llvm.org/D51300#1223042, @Szelethus wrote: > I'm not even sure how this is possible -- and unfortunately I've been u

[PATCH] D51393: Provide a method for generating deterministic IDs for pointers allocated in BumpPtrAllocator

2018-09-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: llvm/include/llvm/Support/Allocator.h:304 +// Use negative index to denote custom sized slabs. +int64_t CustomSlabOffset = 0; +for (size_t Idx = 0; Idx < CustomSizedSlabs.size(); Idx++) { We should start with -1

[PATCH] D51300: [analyzer][UninitializedObjectChecker] No longer using nonloc::LazyCompoundVal

2018-09-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Very easy: 1. Put preprocessed file that crashes into `repro.cpp` (`.c`, `.m`, whatever). 2. Write `repro.sh` as follows: #!/bin/bash blah/blah/path/to/clang -cc1 -analyze -blah-blah-arguments-you-need-to-cause-a-crash repro.cpp 2>&1 | grep "Any assertion message or wh

[PATCH] D51655: [analyzer] Remove traces of ubigraph visualization

2018-09-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. I actually thought it's just a different name for graphviz :/ I've definitely never heard of anybody using ubigraph for this purpose. And it's an analyzer-specific feature. Let's remove. https://r

[PATCH] D51395: [analyzer] Dump a reproducible, deterministic ID of program state to exploded graph

2018-09-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. I very very much appreciate this. https://reviews.llvm.org/D51395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin

[PATCH] D51393: Provide a method for generating deterministic IDs for pointers allocated in BumpPtrAllocator

2018-09-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. I'm happy with the code. Comment at: llvm/include/llvm/Support/Allocator.h:298 + if (P >= S && P < S + computeSlabSize(Idx)) +return InSlabIdx + static_cast(P - S); +

[PATCH] D45416: [AST, analyzer] Transform rvalue cast outputs to lvalues (fheinous-gnu-extensions)

2018-09-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Herald added a subscriber: Szelethus. Dunno, i guess you can just commit it. Comment at: lib/Sema/SemaStmtAsm.cpp:57 + } +Parent = Child; + } Like father, like son :D Repository: rC Clang https://reviews.llvm.org/D45416 __

[PATCH] D49722: [CStringSyntaxChecker] Check strlcat sizeof check

2018-09-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: test/Analysis/cstring-syntax.c:49 + strlcat(dest, "0123456789", badlen / 2); + strlcat(dest, "0123456789", badlen); // expected-warning {{The third argument allows to potentially copy more bytes than it should. Replace with the value 'ba

[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2018-09-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. I'm generally fine with landing the patch as long as the overall direction is chosen (and be moved towards) for how to safely identify the non-deterministic iterators (my previous inline question). This has to be addressed before we move out of alpha, but i believe we shoul

[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing

2018-09-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:126-127 if (V.isUndef()) { +assert(!FR->getDecl()->getType()->isReferenceType() && + "References must be initialized!"); return addFieldToUninits

[PATCH] D51417: [analyzer][UninitializedObjectChecker] Updated comments

2018-09-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Comments always welcome! Comment at: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:363-364 + + // ImmutableList::getHead() isn't a const method,

[PATCH] D52036: [Analyzer] Make plist tests less fragile

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. What do you think about the following approach: 1. Define a `lit` substitution `%diff_plist` that resolves to `diff -u -w -I "/" -I ".:" -I "version" -`. 2. Update these flags in your downstream fork. It's kinda cool because it'll allow us to test exactly what we want in th

[PATCH] D51824: StmtPrinter: allow customizing the end-of-line character

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Looks great to me and pretty trivial, should somebody who's more familiar with this code take a look? Comment at: clang/lib/AST/StmtPrinter.cpp:72 PrintingPolicy Policy; +

[PATCH] D51822: Support generating unique identifiers for Stmt objects

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Looks as expected. I hope that assertion does actually hold. Should AST folks have a look as well? Comment at: clang/lib/AST/Stmt.cpp:310 + return *Out / alignof(Stmt); + +}

[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Looks good i guess. I'm glad this is sorted out^^ https://reviews.llvm.org/D51057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.

[PATCH] D51531: [analyzer][UninitializedObjectChecker] Uninit regions are only reported once

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Hmm, so we're reporting the same region twice in the same bug report through different field chains, right? Why is a state trait necessary here? Maybe just de-duplicate them locally before throwing the report? https://reviews.llvm.org/D51531

[PATCH] D51531: [analyzer][UninitializedObjectChecker] Uninit regions are only reported once

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Hmm, i guess it's necessary to de-duplicate across multiple reports as well. https://reviews.llvm.org/D51531 ___ cfe-commits mailing list cfe-commits@l

[PATCH] D51531: [analyzer][UninitializedObjectChecker] Uninit regions are only reported once

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ requested changes to this revision. NoQ added a comment. This revision now requires changes to proceed. Or, wait, hmm, no, we can still de-duplicate the reports with a global set stored in the checker object. Because we would probably like to de-duplicate across different paths as well. ht

[PATCH] D51679: [analyzer][UninitializedObjectChecker] Refactored checker options

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added inline comments. This revision is now accepted and ready to land. Comment at: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h:61-63 + bool IsPedantic; + bool ShouldConvertNotesToWarnings; + bool CheckPointeeInitializ

[PATCH] D51680: [analyzer][UninitializedObjectChecker] New flag to ignore records based on it's fields

2018-09-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. I hope we'll be able to come up with a reasonable default regex. Comment at: test/Analysis/cxx-uninitialized-object-unionlike-constructs.cpp:1-4 +// RUN: %clang_analyze_cc1 -analy

[PATCH] D49536: [Analyzer] Quick Fix for exponential execution time when simpilifying complex additive expressions

2018-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. I was thinking of two flags, but that'll work too. https://reviews.llvm.org/D49536 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists

[PATCH] D49570: [analyzer] Improve warning messages and notes of DanglingInternalBufferChecker

2018-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp:253 + allocation_state::getContainerObjRegion(N->getState(), PtrToBuf); + const auto *TypedRegion = dyn_cast(ObjRegion); + QualType ObjTy = TypedRegion->getValueType(); ---

[PATCH] D49553: [analyzer] Rename DanglingInternalBufferChecker to InnerPointerChecker

2018-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. LGTM! Repository: rC Clang https://reviews.llvm.org/D49553 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mai

[PATCH] D49568: [analyzer][WIP] Scan the program state map in the visitor only once in DanglingInternalBufferChecker

2018-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Oh, this FIXME, i almost forgot about that. Not sure if we should focus on this now because it's kinda premature optimization, especially after @george.karpenkov has fixed a large performance problem that caused `VisitNode` to be called like ~30 times more often than necess

[PATCH] D49627: [CFG] [analyzer] Constructors of member CXXOperatorCallExpr's argument 0 are not argument constructors.

2018-07-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs, baloghadamsoftware. Herald added subscribers: cfe-commits, mikhail.ramalho. Because `CXXOperatorCallExpr`'s argument 0 is the `this`-argument of the operator if the operator is a

[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. I've just one thing to add. Comment at: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp:149 +C.addTransition(State); return; + } xazax.hun wrote: > Nit: This return is redundant. Because of how easy it is to accidentally split

[PATCH] D49627: [CFG] [analyzer] Constructors of member CXXOperatorCallExpr's argument 0 are not argument constructors.

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 156827. NoQ marked an inline comment as done. NoQ added a comment. In https://reviews.llvm.org/D49627#1172023, @george.karpenkov wrote: > I take it we are crashing otherwise? Not yet, but i'm about to commit code that would (https://reviews.llvm.org/D49443).

[PATCH] D49627: [CFG] [analyzer] Constructors of member CXXOperatorCallExpr's argument 0 are not argument constructors.

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. What i'm fixing here is a false detection of construction context of a certain kind. These are very bad in general, because they cause us to inline the constructor without knowing what object we're constructing or how to handle this object. https://reviews.llvm.org/D49627

[PATCH] D49703: [analyzer] pr38273: Admit that we can't handle the newly produced Loc<>NonLoc comparisons.

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs, mikhail.ramalho. Herald added subscribers: cfe-commits, baloghadamsoftware. This patch fixes the crash caused by https://reviews.llvm.org/D48650 and reported as https://bugs.llvm.

[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2934 +} else if (const auto *CallE = dyn_cast(S)) { + OS << CallE->getDirectCallee()->getNameAsString(); } rnkovacs wrote: > xazax.hun wrote

[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: test/Analysis/inner-pointer.cpp:41-42 +template< class T > +void func_ref(T& a); + Without a definition for this thing, we won't be able to test much. I suggest you to take a pointer to a function directly, i.e. define a

[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp:207-208 + +for (unsigned I = 0, E = FD->getNumParams(); I != E; ++I) { + QualType ParamTy = FD->getParamDecl(I)->getType(); + if (!ParamTy->isReferenceType() || --

[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp:207-208 + +for (unsigned I = 0, E = FD->getNumParams(); I != E; ++I) { + QualType ParamTy = FD->getParamDecl(I)->getType(); + if (!ParamTy->isReferenceType() || --

[PATCH] D49715: [analyzer] CallEvent: Add partially working methods for obtaining the callee stack frame.

2018-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs. Herald added subscribers: cfe-commits, mikhail.ramalho, baloghadamsoftware. These methods allow reasoning about the stack frame that will be (or was) used when the function will b

[PATCH] D49749: [analyzer] Admit that we can't simplify the newly produced mixed Loc/NonLoc expressions.

2018-07-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs, mikhail.ramalho. Herald added subscribers: cfe-commits, baloghadamsoftware. Add one more defensive check to prevent crashes on trying to simplify a `SymSymExpr` with different `Lo

[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. Looks great! Comment at: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp:192 - if (Call.isCalled(CStrFn) || Call.isCalled(DataFn)) { -SVal RawPtr = Call.getReturnValue(); -if (SymbolRef Sym = RawPtr.getAsSymbol(/*I

[PATCH] D49811: [analyzer] Obtain a ReturnStmt from a CFGAutomaticObjDtor

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Yet another great catch! I guess you could write a test with `debug.AnalysisOrder` (by making its `checkEndFunction` callback (that you'll have to define) print different things depending on the re

[PATCH] D49811: [analyzer] Obtain a ReturnStmt from a CFGAutomaticObjDtor

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Devin has recently pointed out that we might have as well reordered CFG elements to have return statement kick in after automatic destructors, so that callbacks were called in a different order. I don't see any problems with that solution, but let's stick to the current sol

[PATCH] D49361: [analyzer] Detect pointers escaped after return statement execution in MallocChecker

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Yup, tests for temporaries are great to have as well. Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2475-2477 // Check if we are returning freed memory. if (Sym)

[PATCH] D49826: [analyzer] NFC: Minor code reuse in simplifySVal().

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs. Herald added subscribers: cfe-commits, mikhail.ramalho, baloghadamsoftware. Satisfies a review comment in https://reviews.llvm.org/D49749. Repository: rC Clang https://reviews

[PATCH] D49749: [analyzer] Admit that we can't simplify the newly produced mixed Loc/NonLoc expressions.

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ requested review of this revision. NoQ marked an inline comment as done. NoQ added inline comments. Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:1300 + Loc::isLocType(S->getRHS()->getType())) { +SVal V = SVB.makeSymbolVal(S); +Cached[S] =

[PATCH] D48427: [Analyzer] Iterator Checker Hotfix: Defer deletion of container data until its last iterator is cleaned up

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Yep, that'll do, thanks! Sorry for not keeping up with all the incoming reviews. Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:536 if (!SR.isLiveRegion(Cont.firs

[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:605 + if (Pos && !Pos->isValid()) { +// If I do not put a tag here, some invalidation tests will fail +static CheckerProgramPointTag Tag("InvalidatedIteratorChecker",

[PATCH] D49536: [Analyzer] Quick Fix for exponential execution time when simpilifying complex additive expressions

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. In https://reviews.llvm.org/D49536#1176128, @mikhail.ramalho wrote: > I getting the following error when analyzing > `test/Analysis/plist-macros.cpp`, usign z3 as constraint manager > (`-analyzer-constraints=z3 -DANALYZER_CM_Z3`): > > /home/mgadelha/llvm/tools/clang/test/

[PATCH] D49228: [analyzer][UninitializedObjectChecker] Void pointer objects are casted back to their dynmic type in note message

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp:290 struct IntDynTypedVoidPointerTest1 { - void *vptr; // expected-note{{uninitialized pointee 'this->vptr'}} + void *vptr; // expected-note{{uninitialized pointee 'this->static_cast(vptr

[PATCH] D48436: [analyzer][UninitializedObjectChecker] Fixed a false negative by no longer filtering out certain constructor calls

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Sorry, i'm still lagging with my reviews because there are a lot of them and i have to balance it with doing actual work. I'll hopefully get to this soon. Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:681-689 +Optional OtherObj

[PATCH] D49536: [Analyzer] Quick Fix for exponential execution time when simpilifying complex additive expressions

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. The "Assuming..." diagnostic piece isn't the same as "Taking true/false branch" diagnostic piece. The former indicates that a constraint is added. The latter indicate how the path flows between program points. The absence of "Assuming..." indicates that Z3 didn't need to ma

[PATCH] D49715: [analyzer] CallEvent: Add partially working methods for obtaining the callee stack frame.

2018-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 157416. NoQ marked 4 inline comments as done. NoQ added a comment. Address comments by editing comments. https://reviews.llvm.org/D49715 Files: include/clang/Analysis/ConstructionContext.h include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h includ

[PATCH] D49715: [analyzer] CallEvent: Add partially working methods for obtaining the callee stack frame.

2018-07-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Core/CallEvent.cpp:197 + + // Recover CFG block via reverse lookup. Maybe it should just be a part of the + // CallEvent object? That would have been convenient. george.karpenkov wrote: > Can we remove

[PATCH] D49715: [analyzer] CallEvent: Add partially working methods for obtaining the callee stack frame.

2018-07-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 157550. NoQ added a comment. Add one more handy method, `getAdjustedParameterIndex()`, which helps using `getParameterLocation()`. https://reviews.llvm.org/D49715 Files: include/clang/Analysis/ConstructionContext.h include/clang/StaticAnalyzer/Core/PathSen

[PATCH] D49210: [CFG] [analyzer] NFC: Enumerate construction context layer kinds and re-use their code for ExprEngine keys.

2018-07-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 157789. NoQ added a comment. A better `ConstructedObjectKey::print()`. https://reviews.llvm.org/D49210 Files: include/clang/Analysis/ConstructionContext.h include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h lib/Analysis/CFG.cpp lib/Analysis/Con

[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker

2018-07-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp:192 - if (Call.isCalled(CStrFn) || Call.isCalled(DataFn)) { -SVal RawPtr = Call.getReturnValue(); -if (SymbolRef Sym = RawPtr.getAsSymbol(/*IncludeBaseRegions=*/true)) { - /

[PATCH] D49058: [analyzer] Move InnerPointerChecker out of alpha

2018-07-30 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. Ok, cool! Let's get this done. https://reviews.llvm.org/D49058 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D49361: [analyzer] Detect pointers escaped after return statement execution in MallocChecker

2018-07-30 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2488 + + checkPreStmt(S, C); +} Let's do a common sub-function, similarly to how `MallocChecker::checkPointerEscape` and `MallocChecker::checkConstPointerEscape` both call `M

[PATCH] D49986: [ADT] ImmutableList::add parameters are switched

2018-07-30 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Cool! Always bothered me. In https://reviews.llvm.org/D49986#1180403, @george.karpenkov wrote: > I'm a bit confused: does it mean these methods are never called in Clang? This patch *is* for clang

[PATCH] D50028: [analyzer] CStringChecker: Fix argument highlighting.

2018-07-30 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs. Herald added subscribers: cfe-commits, mikhail.ramalho, baloghadamsoftware. Sometimes it's important to do `BugReport->addRange()` in order to know which part of the expression is

[PATCH] D48436: [analyzer][UninitializedObjectChecker] Fixed a false negative by no longer filtering out certain constructor calls

2018-07-30 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:681-689 +Optional OtherObject = +getObjectVal(OtherCtor, Context); +if (!OtherObject) + continue; + +// If the CurrentObject is a field of OtherObject, it wi

[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:605 + if (Pos && !Pos->isValid()) { +// If I do not put a tag here, some invalidation tests will fail +static CheckerProgramPointTag Tag("InvalidatedIteratorChecker",

[PATCH] D49749: [analyzer] Admit that we can't simplify the newly produced mixed Loc/NonLoc expressions.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ closed this revision. NoQ marked an inline comment as done. NoQ added a comment. Committed in https://reviews.llvm.org/rC338420 but i accidentally screwed the revision link. Repository: rC Clang https://reviews.llvm.org/D49749 ___ cfe-commit

[PATCH] D49826: [analyzer] NFC: Minor code reuse in simplifySVal().

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Uhm, sry, https://reviews.llvm.org/rC338425 is not relevant, i screwed up the revision link again. Repository: rL LLVM https://reviews.llvm.org/D49826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm

[PATCH] D48249: [CFG] [analyzer] Add stubs for argument construction contexts for arguments of C++ constructors and Objective-C messages.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ closed this revision. NoQ added a comment. Committed in https://reviews.llvm.org/rC338425 but i accidentally screwed up the revision link. https://reviews.llvm.org/D48249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm

[PATCH] D49627: [CFG] [analyzer] Constructors of member CXXOperatorCallExpr's argument 0 are not argument constructors.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. In https://reviews.llvm.org/D49627#1176326, @baloghadamsoftware wrote: > How much different is a correct `this`-argument construction context from > real argument construction contexts? It's identified in a similar manner; this patch pretty much already shows how to ident

[PATCH] D49210: [CFG] [analyzer] NFC: Enumerate construction context layer kinds and re-use their code for ExprEngine keys.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ closed this revision. NoQ added a comment. Committed as https://reviews.llvm.org/rC338439 but Phabricator didn't pick it up because i put a `.` after the phabricator link. https://reviews.llvm.org/D49210 ___ cfe-commits mailing list cfe-commits

[PATCH] D48681: [CFG] [analyzer] Add construction contexts for function arguments.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ closed this revision. NoQ added a comment. Committed as https://reviews.llvm.org/rC338436 but Phabricator didn't pick it up because i put a `.` after the phabricator link. https://reviews.llvm.org/D48681 ___ cfe-commits mailing list cfe-commits

[PATCH] D49627: [CFG] [analyzer] Constructors of member CXXOperatorCallExpr's argument 0 are not argument constructors.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Hmm, AST has just changed in https://reviews.llvm.org/rC338135. While the current patch is still relevant, it might be that we'll need to treat this construction context as if it's a simple temporary now. https://reviews.llvm.org/D49627 _

[PATCH] D49627: [CFG] [analyzer] Constructors of member CXXOperatorCallExpr's argument 0 are not argument constructors.

2018-08-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 158668. NoQ added a comment. Ok, so with https://reviews.llvm.org/rC338135 operator this-argument constructors do indeed work exactly like temporaries. This patch is not necessary anymore. I'd still prefer to add tests and i've added a path-sensitive test as we

[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

2018-08-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. I suspect that with https://reviews.llvm.org/rC338135 your operator this-argument re-assignment mechanism is no longer necessary. Due to the combination of support for materializing temporaries that i added previously and the change in the AST that turns the operator this-a

[PATCH] D49715: [analyzer] CallEvent: Add partially working methods for obtaining the callee stack frame.

2018-08-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:431 +return ExprEngine::getObjectUnderConstruction( +getState(), {getOriginExpr(), Index}, getCalleeStackFrame()).hasValue(); + } Whoops, t

[PATCH] D49361: [analyzer] Detect pointers escaped after return statement execution in MallocChecker

2018-08-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. All this stuff looks great! Please commit. https://reviews.llvm.org/D49361 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D50211: [analyzer] Fix displayed checker name for InnerPointerChecker

2018-08-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. I see, so that's how it's done! I also noticed that checker name was weird in exploded graph dumps, i.e. it was showing regular new/delete stuff as if it was done by InnerPointer checker. I'll chec

[PATCH] D50211: [analyzer] Fix displayed checker name for InnerPointerChecker

2018-08-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Yay thx! Yeah, that's the best behavior i can imagine here. Repository: rC Clang https://reviews.llvm.org/D50211 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[PATCH] D42745: [analyzer] Add support for __builtin_constant_p to BuiltinFunctionChecker

2018-02-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Oh, i see what you did here. I thought you're evaluating the argument, but you're evaluating the whole builtin function call. In this case you don't need the else-branch: `EvaluateAsInt` will always succeed. Moreover, you can merge your code with the `BI__builtin_object_siz

[PATCH] D42672: [CFG] [analyzer] Heavier CFGConstructor elements.

2018-02-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 132908. NoQ marked an inline comment as done. NoQ added a comment. Fix uninitialized variables. https://reviews.llvm.org/D42672 Files: include/clang/Analysis/AnalysisDeclContext.h include/clang/Analysis/CFG.h include/clang/StaticAnalyzer/Core/AnalyzerOpti

[PATCH] D42672: [CFG] [analyzer] Heavier CFGConstructor elements.

2018-02-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: include/clang/Analysis/CFG.h:153 + + ConstructionContext() = default; + ConstructionContext(CXXConstructExpr *Constructor, Stmt *Trigger) xazax.hun wrote: > Maybe I am getting this wrong, but I think in this case the membe

[PATCH] D42876: [analyzer] Support returning objects by value.

2018-02-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ planned changes to this revision. NoQ added a comment. Destructor for the returned temporary is still evaluated conservatively: class C { public: int &x, &y; C(int &_x, int &_y) : x(_x), y(_y) { ++x; } C(const C &c) : x(c.x), y(c.y) { ++x; } ~C() { ++y; } }; C make(

<    1   2   3   4   5   6   7   8   9   10   >