]> granicus.if.org Git - clang/commit
[analyzer] Allow checkers to supply call stack diagnostic hints for the
authorAnna Zaks <ganna@apple.com>
Thu, 15 Mar 2012 21:13:02 +0000 (21:13 +0000)
committerAnna Zaks <ganna@apple.com>
Thu, 15 Mar 2012 21:13:02 +0000 (21:13 +0000)
commit368a0d565f078666ca5bfb7fe08d04648688e4bc
tree8d66a659b31243797f2f1c374a4da344c3e8a1a5
parent2b2bbee3071cee1b03520d9bf0c80c4f0bbe60eb
[analyzer] Allow checkers to supply call stack diagnostic hints for the
BugVisitor DiagnosticPieces.

When checkers create a DiagnosticPieceEvent, they can supply an extra
string, which will be concatenated with the call exit message for every
call on the stack between the diagnostic event and the final bug report.
(This is a simple version, which could be/will be further enhanced.)

For example, this is used in Malloc checker to produce the ",
which allocated memory" in the following example:

static char *malloc_wrapper() { // 2. Entered call from 'use'
    return malloc(12);    // 3. Memory is allocated
}

void use() {
    char *v;
    v = malloc_wrapper(); // 1. Calling 'malloc_wrappers'
        // 4. Returning from 'malloc_wrapper', which allocated memory
}                         // 5. Memory is never released; potential
memory leak

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152837 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
lib/StaticAnalyzer/Core/BugReporter.cpp
lib/StaticAnalyzer/Core/PathDiagnostic.cpp
test/Analysis/malloc-plist.c