Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Artem Dergachev via cfe-commits

Thanks! Should get better with r285000.

On 10/24/16 9:34 PM, Evgenii Stepanov wrote:

This code also fails with UBSan:

tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:285:62:
runtime error: signed integer overflow: 9223372036854775807 + 1 cannot
be represented in type 'long'
 #0 0x5e1642f in (anonymous
namespace)::StdLibraryFunctionsChecker::ValueRange::applyAsWithinRange(llvm::IntrusiveRefCntPtr, clang::ento::CallEvent const&, (anonymous
namespace)::StdLibraryFunctionsChecker::FunctionSummaryTy const&)
const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:285:62
 #1 0x5e0f4c3 in (anonymous
namespace)::StdLibraryFunctionsChecker::ValueRange::apply(llvm::IntrusiveRefCntPtr, clang::ento::CallEvent const&, (anonymous
namespace)::StdLibraryFunctionsChecker::FunctionSummaryTy const&)
const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:149:16
 #2 0x5e0eb00 in (anonymous
namespace)::StdLibraryFunctionsChecker::checkPostCall(clang::ento::CallEvent
const&, clang::ento::CheckerContext&) const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:350:21


http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/18/steps/check-clang%20ubsan/logs/stdio


On Mon, Oct 24, 2016 at 6:23 AM, Renato Golin via cfe-commits
 wrote:

On 24 October 2016 at 14:09, Artem Dergachev  wrote:

Strange, i'm not receiving any buildbot emails again. Will look through bots
manually next time, that doesn't sound too hard. Pushed a hotfix in r284969.

The buildmaster was restarted this weekend and got all old builds data wiped.

I only know because I have a monitoring page.

Galina,

Any info on the server migration and the email configuration?

Thanks!
--renato
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Evgenii Stepanov via cfe-commits
This code also fails with UBSan:

tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:285:62:
runtime error: signed integer overflow: 9223372036854775807 + 1 cannot
be represented in type 'long'
#0 0x5e1642f in (anonymous
namespace)::StdLibraryFunctionsChecker::ValueRange::applyAsWithinRange(llvm::IntrusiveRefCntPtr, clang::ento::CallEvent const&, (anonymous
namespace)::StdLibraryFunctionsChecker::FunctionSummaryTy const&)
const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:285:62
#1 0x5e0f4c3 in (anonymous
namespace)::StdLibraryFunctionsChecker::ValueRange::apply(llvm::IntrusiveRefCntPtr, clang::ento::CallEvent const&, (anonymous
namespace)::StdLibraryFunctionsChecker::FunctionSummaryTy const&)
const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:149:16
#2 0x5e0eb00 in (anonymous
namespace)::StdLibraryFunctionsChecker::checkPostCall(clang::ento::CallEvent
const&, clang::ento::CheckerContext&) const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:350:21


http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/18/steps/check-clang%20ubsan/logs/stdio


On Mon, Oct 24, 2016 at 6:23 AM, Renato Golin via cfe-commits
 wrote:
> On 24 October 2016 at 14:09, Artem Dergachev  wrote:
>> Strange, i'm not receiving any buildbot emails again. Will look through bots
>> manually next time, that doesn't sound too hard. Pushed a hotfix in r284969.
>
> The buildmaster was restarted this weekend and got all old builds data wiped.
>
> I only know because I have a monitoring page.
>
> Galina,
>
> Any info on the server migration and the email configuration?
>
> Thanks!
> --renato
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Renato Golin via cfe-commits
On 24 October 2016 at 14:09, Artem Dergachev  wrote:
> Strange, i'm not receiving any buildbot emails again. Will look through bots
> manually next time, that doesn't sound too hard. Pushed a hotfix in r284969.

The buildmaster was restarted this weekend and got all old builds data wiped.

I only know because I have a monitoring page.

Galina,

Any info on the server migration and the email configuration?

Thanks!
--renato
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Artem Dergachev via cfe-commits
Strange, i'm not receiving any buildbot emails again. Will look through 
bots manually next time, that doesn't sound too hard. Pushed a hotfix in 
r284969.


On 10/24/16 3:08 PM, Renato Golin wrote:

On 24 October 2016 at 10:41, Artem Dergachev via cfe-commits
 wrote:

Author: dergachev
Date: Mon Oct 24 04:41:38 2016
New Revision: 284960

URL: http://llvm.org/viewvc/llvm-project?rev=284960=rev
Log:
[analyzer] Add StdLibraryFunctions checker.

Hi Artem,

I'm not sure what you're checking, but this failed on the ARM bots:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/14
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/14

error: 'warning' diagnostics expected but not seen:
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 35: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 38: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 44: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 52: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 54: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 66: FALSE
error: 'warning' diagnostics seen but not expected:
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 35: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 38: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 44: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 52: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 54: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 66: UNKNOWN
12 errors generated.

If it's not trivial to fix, let's revert and try to find it offline.

cheers,
--renato


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Renato Golin via cfe-commits
On 24 October 2016 at 10:41, Artem Dergachev via cfe-commits
 wrote:
> Author: dergachev
> Date: Mon Oct 24 04:41:38 2016
> New Revision: 284960
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284960=rev
> Log:
> [analyzer] Add StdLibraryFunctions checker.

Hi Artem,

I'm not sure what you're checking, but this failed on the ARM bots:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/14
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/14

error: 'warning' diagnostics expected but not seen:
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 35: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 38: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 44: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 52: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 54: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 66: FALSE
error: 'warning' diagnostics seen but not expected:
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 35: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 38: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 44: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 52: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 54: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 66: UNKNOWN
12 errors generated.

If it's not trivial to fix, let's revert and try to find it offline.

cheers,
--renato
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 24 04:41:38 2016
New Revision: 284960

URL: http://llvm.org/viewvc/llvm-project?rev=284960=rev
Log:
[analyzer] Add StdLibraryFunctions checker.

This checker does not emit reports, however it influences the analysis
by providing complete summaries for, or otherwise improving modeling of,
various standard library functions.

This should reduce the number of infeasible paths explored during analysis.
The custom function summary format used in this checker is superior to
body farms by causing less unnecessary state splits,
which would result in better analysis performance.

Differential Revision: https://reviews.llvm.org/D20811

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
cfe/trunk/test/Analysis/std-c-library-functions.c
cfe/trunk/test/Analysis/std-c-library-functions.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=284960=284959=284960=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Oct 24 
04:41:38 2016
@@ -416,6 +416,10 @@ def VforkChecker : Checker<"Vfork">,
   HelpText<"Check for proper usage of vfork">,
   DescFile<"VforkChecker.cpp">;
 
+def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
+  HelpText<"Improve modeling of the C standard library functions">,
+  DescFile<"StdLibraryFunctionsChecker.cpp">;
+
 } // end "unix"
 
 let ParentPackage = UnixAlpha in {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=284960=284959=284960=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Oct 24 04:41:38 
2016
@@ -71,6 +71,7 @@ add_clang_library(clangStaticAnalyzerChe
   ReturnUndefChecker.cpp
   SimpleStreamChecker.cpp
   StackAddrEscapeChecker.cpp
+  StdLibraryFunctionsChecker.cpp
   StreamChecker.cpp
   TaintTesterChecker.cpp
   TestAfterDivZeroChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp?rev=284960=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp Mon 
Oct 24 04:41:38 2016
@@ -0,0 +1,943 @@
+//=== StdLibraryFunctionsChecker.cpp - Model standard functions -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker improves modeling of a few simple library functions.
+// It does not generate warnings.
+//
+// This checker provides a specification format - `FunctionSummaryTy' - and
+// contains descriptions of some library functions in this format. Each
+// specification contains a list of branches for splitting the program state
+// upon call, and range constraints on argument and return-value symbols that
+// are satisfied on each branch. This spec can be expanded to include more
+// items, like external effects of the function.
+//
+// The main difference between this approach and the body farms technique is
+// in more explicit control over how many branches are produced. For example,
+// consider standard C function `ispunct(int x)', which returns a non-zero 
value
+// iff `x' is a punctuation character, that is, when `x' is in range
+//   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
+// `FunctionSummaryTy' provides only two branches for this function. However,
+// any attempt to describe this range with if-statements in the body farm
+// would result in many more branches. Because each branch needs to be analyzed
+// independently, this significantly reduces performance. Additionally,
+// once we consider a branch on which `x' is in range, say, ['!', '/'],
+// we assume that such branch is an important separate path through the 
program,
+// which may lead to false positives because considering this particular path
+// was not consciously intended, and therefore it might have been unreachable.
+//
+// This checker uses eval::Call for modeling "pure" functions, for which
+// their `FunctionSummaryTy' is a precise model. This