Commit Graph

4513 Commits

Author SHA1 Message Date
Ryosuke Niwa
61a6439f35 Introduce a new WebKit checker for a unchecked local variable (#113708)
This PR introduces alpha.webkit.UncheckedLocalVarsChecker which detects
a raw reference or a raw pointer local, static, or global variable to a
CheckedPtr capable object without a guardian variable in an outer scope.
2024-10-31 23:53:07 -07:00
Ella Ma
f4af60dfbb [analyzer] Fix false double free when including 3rd-party headers with overloaded delete operator as system headers (#85224)
Fixes #62985
Fixes #58820

When 3rd-party header files are included as system headers, their
overloaded `new` and `delete` operators are also considered as the std
ones. However, those overloaded operator functions will also be inlined.
This makes the same
symbolic memory marked as released twice: during `checkPreCall` of the
overloaded `delete` operator and when calling `::operator delete` after
inlining the overloaded operator function (if it has).

This patch attempts to fix this bug by adjusting the strategy of
verifying whether the callee is a standard `new` or `delete` operator in
the `isStandardNewDelete` function.
2024-10-31 17:02:28 +01:00
Ryosuke Niwa
dadfd4a288 Revert "[webkit.UncountedLambdaCapturesChecker] Ignore trivial functions and [[clang::noescape]]." (#114372)
Reverts llvm/llvm-project#113845. Introduced a test failure.
2024-10-31 00:30:18 -07:00
Ryosuke Niwa
287781c7c9 [webkit.UncountedLambdaCapturesChecker] Ignore trivial functions and [[clang::noescape]]. (#113845)
This PR makes webkit.UncountedLambdaCapturesChecker ignore trivial
functions as well as the one being passed to an argument with
[[clang::noescape]] attribute. This dramatically reduces the false
positive rate for this checker.

To do this, this PR replaces VisitLambdaExpr in favor of checking
lambdas via VisitDeclRefExpr and VisitCallExpr. The idea is that if a
lambda is defined but never called or stored somewhere, then capturing
whatever variable in such a lambda is harmless.

VisitCallExpr explicitly looks for direct invocation of lambdas and
registers its DeclRefExpr to be ignored in VisitDeclRefExpr. If a lambda
is being passed to a function, it checks whether its argument is
annotated with [[clang::noescape]]. If it's not annotated such, it
checks captures for their safety.

Because WTF::switchOn could not be annotated with [[clang::noescape]] as
function type parameters are variadic template function so we hard-code
this function into the checker.

Finally, this PR also converts the accompanying test to use -verify and
adds a bunch of tests.
2024-10-31 00:14:24 -07:00
Ryosuke Niwa
b47e2316bf [alpha.webkit.UncountedLocalVarsChecker] Warn the use of a raw pointer/reference when the guardian variable gets mutated. (#113859)
This checker has a notion of a guardian variable which is a variable and
keeps the object pointed to by a raw pointer / reference in an inner
scope alive long enough to "guard" it from use-after-free. But such a
guardian variable fails to flawed to keep the object alive if it ever
gets mutated within the scope of a raw pointer / reference.

This PR fixes this bug by introducing a new AST visitor class,
GuardianVisitor, which traverses the compound statements of a guarded
variable (raw pointer / reference) and looks for any operator=, move
constructor, or calls to "swap", "leakRef", or "releaseNonNull"
functions.
2024-10-29 23:13:23 -07:00
vabridgers
3d6923dbac RFC: [clang-tidy] [analyzer] Move nondeterministic pointer usage check to tidy (#110471)
This change moves the `alpha.nondeterministic.PointerSorting` and
`alpha.nondeterministic.PointerIteration` static analyzer checkers to a
single `clang-tidy` check. Those checkers were implemented as simple
`clang-tidy` check-like code, wrapped in the static analyzer framework.
The documentation was updated to describe what the checks can and cannot
do, and testing was completed on a broad set of open-source projects.

Co-authored-by: Vince Bridgers <vince.a.bridgers@ericsson.com>
2024-10-28 03:53:36 -05:00
isuckatcs
a917ae0b4f [analyzer] Fix a crash from element region construction during ArrayInitLoopExpr analysis (#113570)
This patch generalizes the way element regions are constructed when an
`ArrayInitLoopExpr` is being analyzed. Previously the base region of the
`ElementRegion` was determined with pattern matching, which led to
crashes, when an unhandled pattern was encountered.

Fixes #112813
2024-10-26 17:41:55 +02:00
Ryosuke Niwa
5c20891b2b [WebKit Checkers] Allow a guardian CheckedPtr/CheckedRef (#110222)
This PR makes WebKit checkers allow a guardian variable which is
CheckedPtr or CheckedRef as in addition to RefPtr or Ref.
2024-10-25 08:52:56 -07:00
Rashmi Mudduluru
a291f00eda [WebKit Checkers] Make TrivialFunctionAnalysis recognize std::array::operator[] as trivial (#113377)
TFA wasn't recognizing `__libcpp_verbose_abort` as trivial causing `std::array::operator[]` also not being recognized as trivial.
2024-10-24 14:23:29 -07:00
Balazs Benics
4affb2d59a [analyzer] Use dynamic type when invalidating by a member function call (#111138)
When instantiating "callable<T>", the "class CallableType" nested type
will only have a declaration in the copy for the instantiation - because
it's not refereed to directly by any other code that would need a
complete definition.

However, in the past, when conservative eval calling member function, we
took the static type of the "this" expr, and looked up the CXXRecordDecl
it refereed to to see if it has any mutable members (to decide if it
needs to refine invalidation or not). Unfortunately, that query needs a
definition, and it asserts otherwise, thus we crashed.

To fix this, we should consult the dynamic type of the object, because
that will have the definition.
I anyways added a check for "hasDefinition" just to be on the safe side.

Fixes #77378
2024-10-24 13:22:19 +02:00
z1nke
684c26c89b [analyzer] Remove redundant "returned to caller" suffix for compound literal in StackAddressEscape
This patch simplifies the diagnostic message in the core.StackAddrEscape
for stack memory associated with compound literals by removing the
redundant "returned to caller" suffix.
Example: https://godbolt.org/z/KxM67vr7c

```c
// clang --analyze -Xanalyzer -analyzer-checker=core.StackAddressEscape
void* compound_literal() {
  return &(unsigned short){((unsigned short)0x22EF)};
}
```

warning: Address of stack memory associated with a compound literal
declared on line 2 **returned to caller returned to caller**
[core.StackAddressEscape]
2024-10-23 10:46:36 +02:00
Balazs Benics
67e84213f5 [analyzer][Solver] Teach SymbolicRangeInferrer about commutativity (2/2) (#112887)
This patch should not introduce much overhead as it only does one more
constraint map lookup, which is really quick.

Depends on #112583
2024-10-18 16:15:33 +02:00
Balazs Benics
4995d09355 [analyzer][Solver] Improve getSymVal and friends (1/2) (#112583) 2024-10-18 13:51:20 +02:00
Ryosuke Niwa
71b81e93d2 [alpha.webkit.UncountedLocalVarsChecker] Recursive functions are erroneously treated as non-trivial (#110973)
This PR fixes the bug that alpha.webkit.UncountedLocalVarsChecker
erroneously treats a trivial recursive function as non-trivial. This was
caused by TrivialFunctionAnalysis::isTrivialImpl which takes a statement
as an argument populating the cache with "false" while traversing the
statement to determine its triviality within a recursive function in
TrivialFunctionAnalysisVisitor's WithCachedResult. Because
IsFunctionTrivial honors an entry in the cache, this resulted in the
whole function to be treated as non-trivial.

Thankfully, TrivialFunctionAnalysisVisitor::IsFunctionTrivial already
handles recursive functions correctly so this PR applies the same logic
to TrivialFunctionAnalysisVisitor::WithCachedResult by sharing code
between the two functions. This avoids the cache to be pre-populated
with "false" while traversing statements in a recurisve function.
2024-10-17 16:52:31 -07:00
Balázs Kéri
9df8d8d05c [clang][analyzer] Improve test and documentation in cstring NotNullTerminated checker (#112019)
CStringChecker has a sub-checker alpha.unix.cstring.NotNullTerminated
which checks for invalid objects passed to string functions. The checker
and its name are not exact and more functions could be checked, this
change only adds some tests and improves documentation.
2024-10-16 10:17:34 +02:00
Balázs Kéri
f74f568b29 [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical type (#111846)
Pointer values casted to integer (non-pointer) type should be able to be
subtracted as usual.
2024-10-11 11:58:14 +02:00
Ryosuke Niwa
820bab8fb5 [alpha.webkit.UncountedCallArgsChecker] Add the support for trivial CXXInheritedCtorInitExpr. (#111198) 2024-10-10 10:01:35 -07:00
Ryosuke Niwa
0fc3e4093c [alpha.webkit.UncountedCallArgsChecker] Skip std::forward in tryToFindPtrOrigin. (#111222)
Ignore std::forward when it appears while looking for the pointer
origin.
2024-10-10 10:00:42 -07:00
Balazs Benics
068d76b480 [analyzer] Fix crash when casting the result of a malformed fptr call (#111390)
Ideally, we wouldn't workaround our current cast-modeling, but the
experimental "support-symbolic-integer-casts" is not finished so we need
to live with our current modeling.

Ideally, we could probably bind `UndefinedVal` as the result of the call
even without evaluating the call, as the result types mismatch between
the static type of the `CallExpr` and the actually function that happens
to be called.

Nevertheless, let's not crash.
https://compiler-explorer.com/z/WvcqK6MbY

CPP-5768
2024-10-09 11:39:56 +02:00
Pavel Skripkin
fba6c887c1 [analyzer] Fix wrong builtin_*_overflow return type (#111253)
`builtin_*_overflow` functions return `_Bool` according to [1].
`BuiltinFunctionChecker` was using `makeTruthVal` w/o specifying
explicit type, which creates an `int` value, since it's the type of any
compassion according to C standard.

Fix it by directly passing `BoolTy` to `makeTruthVal`

Closes: #111147

[1]
https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins
2024-10-05 17:21:31 +02:00
Pavel Skripkin
8d661fd9fd [analyzer] use invalidateRegions() in VisitGCCAsmStmt (#109838) 2024-10-04 16:12:29 +03:00
Pavel Skripkin
a017ed04cc [analyzer] Model overflow builtins (#102602)
Add basic support for `builtin_*_overflow`  primitives.
 
These helps a lot for checking custom calloc-like functions with
inlinable body. Without such support code like

```c
#include <stddef.h>
#include <stdlib.h>

static void *myMalloc(size_t a1, size_t a2)
{
    size_t res;

    if (__builtin_mul_overflow(a1, a2, &res))
        return NULL;
    return malloc(res);
}

void test(void)
{
    char *ptr = myMalloc(10, 1);
    ptr[20] = 10;
}
````

does not trigger any warnings.
2024-10-03 12:27:25 +02:00
Balázs Kéri
1701895c36 [clang][analyzer] Less redundant warnings from FixedAddressChecker (#110458)
If a fixed value is assigned to a pointer variable, the checker did emit
a warning. If the pointer variable is assigned to another pointer
variable, this resulted in another warning. The checker now emits
warning only if a value with non-pointer type is assigned (to a pointer
variable).
2024-10-03 09:17:51 +02:00
Daniel Krupp
09b8dbfa80 [analyzer] Add optin.taint.TaintedDiv checker (#106389)
Tainted division operation is separated out from the core.DivideZero
checker into the optional optin.taint.TaintedDiv checker. The checker
warns when the denominator in a division operation is an attacker
controlled value.
2024-10-01 11:33:06 +02:00
Balázs Kéri
0d384fe978 [clang][analyzer] Move 'alpha.core.PointerSub' checker into 'security.PointerSub' (#107596) 2024-09-30 09:16:27 +02:00
Ryosuke Niwa
3c0984309e [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (#108352)
This PR introduces new WebKit checker to warn a member variable that is
a raw reference or a raw pointer to an object, which is capable of
creating a CheckedRef/CheckedPtr.
2024-09-27 00:42:18 -07:00
Ryosuke Niwa
91ec9cb960 [alpha.webkit.UncountedCallArgsChecker] Use canonical type (#109393)
This PR fixes a bug in UncountedCallArgsChecker that calling a function
with a member variable which is Ref/RefPtr is erroneously treated as
safe by canoniclizing the type before checking whether it's ref counted
or not.
2024-09-26 22:18:07 -07:00
Pavel Skripkin
9abf6d3506 [analyzer] [MallocChecker] Assume functions with ownership_returns return unknown memory (#110115)
There is no good way to tell CSA if function with `ownership_returns`
attribute returns initialized or not initialized memory. To make FP rate
lower, let's assume that memory returned from such functions is unknown
and do not reason about it.

In future it would be great to add a way to annotate such behavior
2024-09-26 15:45:08 +03:00
Daniel Krupp
f82fb06cd1 [analyzer] Moving TaintPropagation checker out of alpha (#67352)
This commit moves the **alpha.security.taint.TaintPropagation** and
**alpha.security.taint.GenericTaint** checkers to the **optin.taint**
optional package.

These checkers were stabilized and improved by recent commits thus 
they are ready for production use.
2024-09-26 14:00:13 +02:00
Balázs Kéri
ae54a00cc1 [clang][analyzer] FixedAddressChecker: no warning if system macro is used (#108993) 2024-09-26 09:49:29 +02:00
Sean Perry
a514457e62 Mark tests as unsupported when targeting z/OS (#107916)
Set up these tests so these are marked as unsupported when targeting
z/OS. Most would already be unsupported if you ran lit on z/OS. However,
they also need to be unsupported if the default triple is z/OS.
2024-09-25 10:43:02 -04:00
Arseniy Zaostrovnykh
be0b1142df [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (#109655)
Fixes #107852

Make it explicit that the checker skips `alloca` regions to avoid the
risk of producing false positives for code with advanced memory
management.
StackAddrEscapeChecker already used this strategy when it comes to
malloc'ed regions, so this change relaxes the assertion and explicitly
silents the issues related to memory regions generated with `alloca`.
2024-09-23 16:47:35 +02:00
vabridgers
9ca62c5302 [analyzer] Indicate UnarySymExpr is not supported by Z3 (#108900)
Random testing found that the Z3 wrapper does not support UnarySymExpr,
which was added recently and not included in the original Z3 wrapper.
For now, just avoid submitting expressions to Z3 to avoid compiler
crashes.

Some crash context ...

clang -cc1 -analyze -analyzer-checker=core z3-unarysymexpr.c
-analyzer-constraints=z3

Unsupported expression to reason about!
UNREACHABLE executed at
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h:297!

Stack dump:
3. <root>/clang/test/Analysis/z3-unarysymexpr.c:13:7: Error evaluating
branch #0 <addr> llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) #1
<addr> llvm::sys::RunSignalHandlers() #8 <addr>
clang::ento::SimpleConstraintManager::assumeAux(
llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>,
clang::ento::NonLoc, bool) #9 <addr>
clang::ento::SimpleConstraintManager::assume(
llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>,
clang::ento::NonLoc, bool)

Co-authored-by: einvbri <vince.a.bridgers@ericsson.com>
2024-09-19 09:57:25 -05:00
Kristóf Umann
752e10379c [analyzer] Explicitly register NoStoreFuncVisitor from alpha.unix.cst… (#108373)
…ring.UninitRead

This is a drastic simplification of #106982. If you read that patch,
this is the same thing with all BugReporterVisitors.cpp and
SValBuilder.cpp changes removed! (since all replies came regarding
changed to those files, I felt the new PR was justified)

The patch was inspired by a pretty poor bug report on FFMpeg:

![image](https://github.com/user-attachments/assets/8f4e03d8-45a4-4ea2-a63d-3ab78d097be9)

In this bug report, block is uninitialized, hence the bug report that it
should not have been passed to memcpy. The confusing part is in line 93,
where block was passed as a non-const pointer to seq_unpack_rle_block,
which was obviously meant to initialize block. As developers, we know
that clang likely didn't skip this function and found a path of
execution on which this initialization failed, but NoStoreFuncVisitor
failed to attach the usual "returning without writing to block" message.

I fixed this by instead of tracking the entire array, I tracked the
actual element which was found to be uninitialized (Remember, we
heuristically only check if the first and last-to-access element is
initialized, not the entire array). This is how the bug report looks
now, with 'seq_unpack_rle_block' having notes describing the path of
execution and lack of a value change:

![image](https://github.com/user-attachments/assets/8de5d101-052e-4ecb-9cd9-7c29724333d2)

![image](https://github.com/user-attachments/assets/8bf52a95-62de-44e7-aef8-03a46a3fa08e)

Since NoStoreFuncVisitor was a TU-local class, I moved it back to
BugReporterVisitors.h, and registered it manually in CStringChecker.cpp.
This was done because we don't have a good trackRegionValue() function,
only a trackExpressionValue() function. We have an expression for the
array, but not for its first (or last-to-access) element, so I only had
a MemRegion on hand.
2024-09-19 10:04:47 +02:00
Balazs Benics
2e3c7dbbcb [analyzer] Note last "fclose" call from "ensureStreamOpened" (#109112)
Patch by Arseniy Zaostrovnykh!
2024-09-18 12:22:02 +02:00
Ryosuke Niwa
fd21b7911f [webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings (#108656)
Improve the fix in 203a2ca8cd by allowing
variable references and more ignoring of parentheses.
2024-09-17 22:23:27 -07:00
Ryosuke Niwa
33533baf63 [alpha.webkit.UncountedCallArgsChecker] Add support for Objective-C++ property access (#108669)
Treat a function call or property access via a Objective-C++ selector
which returns a Ref/RefPtr as safe.
2024-09-17 18:39:22 -07:00
Pavel Skripkin
4c6f313cb3 [analyzer] [MallocChecker] suspect all release functions as candidate for suppression (#104599)
Current MalloChecker logic suppresses FP caused by refcounting only for
C++ destructors. The same pattern occurs a lot in C in objects with
intrusive refcounting. See #104229 for code example.

To extend current logic to C, suspect all release functions as candidate
for suppression.

Closes: #104229
2024-09-16 19:44:13 +03:00
Pavel Skripkin
339282d49f [analyzer] Refactor MallocChecker to use BindExpr in evalCall (#106081)
PR refactors `MallocChecker` to not violate invariant of `BindExpr`,
which should be called only during `evalCall` to avoid conflicts.

To achieve this, most of `postCall` logic was moved to `evalCall` with
addition return value binding in case of processing of allocation
functions. Check functions prototypes was changed to use `State` with
bound return value.

`checkDelim` logic was left in `postCall` to avoid conflicts with
`StreamChecker` which also evaluates `getline` and friends.

PR also introduces breaking change in the unlikely case when the
definition of an allocation function (e.g. `malloc()`) is visible: now
checker does not try to inline allocation functions and assumes their
initial semantics.

Closes #73830
2024-09-16 06:48:07 +02:00
Balazs Benics
2e30f8d114 [analyzer] Fix StreamChecker crash in fread modeling (#108393)
In #93408
69bc159142
I refined how invalidation is done for `fread`. It can crash, if the
"size" or "count" parameters of "fread" is a perfectly constrained
negative value. In such cases, when it will try to allocate a
SmallVector with a negative size, which will cause a crash.

To mitigate this issue, let's just guard against negative values.

CPP-3247
2024-09-12 17:06:52 +02:00
yronglin
060137038a Reapply "[Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer" (#108039)
The PR reapply https://github.com/llvm/llvm-project/pull/97308. 

- Implement [CWG1815](https://wg21.link/CWG1815): Support lifetime
extension of temporary created by aggregate initialization using a
default member initializer.

- Fix crash that introduced in
https://github.com/llvm/llvm-project/pull/97308. In
`InitListChecker::FillInEmptyInitForField`, when we enter
rebuild-default-init context, we copy all the contents of the parent
context to the current context, which will cause the `MaybeODRUseExprs`
to be lost. But we don't need to copy the entire context, only the
`DelayedDefaultInitializationContext` was required, which is used to
build `SourceLocExpr`, etc.

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-09-12 06:29:48 +08:00
Ryosuke Niwa
b06954a5d0 [alpha.webkit.UncountedCallArgsChecker] Allow protector functions in Objective-C++ (#108184)
This PR fixes the bug that WebKit checkers didn't recognize the return
value of an Objective-C++ selector which returns Ref or RefPtr to be
safe.
2024-09-11 12:06:04 -07:00
Ryosuke Niwa
882f21ec87 [WebKit Checkers] Allow "singleton" suffix to be camelCased. (#108257)
We should allow singleton and fooSingleton as singleton function names.
2024-09-11 12:03:23 -07:00
Ryosuke Niwa
7721db4896 [WebKit Static Analyzer] Treat WTFReportBacktrace as a trivial function. (#108167)
Treat WTFReportBacktrace, which prints out the backtrace, as trivial.
2024-09-11 10:08:30 -07:00
Ryosuke Niwa
203a2ca8cd [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (#107676)
This PR makes WebKit's RefCntblBaseVirtualDtor checker not generate a
warning for ThreadSafeRefCounted when the destruction thread is a
specific thread.

Prior to this PR, we only allowed CRTP classes without a virtual
destructor if its deref function had an explicit cast to the derived
type, skipping any lambda declarations which aren't invoked. This ends
up generating a warning for ThreadSafeRefCounted when a specific thread
is used to destruct the object because there is no inline body /
definition for ensureOnMainThread and ensureOnMainRunLoop and
DerefFuncDeleteExprVisitor concludes that there is no explicit delete of
the derived type.

This PR relaxes the condition DerefFuncDeleteExprVisitor checks by
allowing a delete expression to appear within a lambda declaration if
it's an argument to an "opaque" function; i.e. a function without
definition / body.
2024-09-10 22:25:03 -07:00
Pavel Skripkin
db6051dae0 [analyzer] fix crash on binding to symbolic region with void * type (#107572)
As reported in
https://github.com/llvm/llvm-project/pull/103714#issuecomment-2295769193.
CSA crashes on trying to bind value to symbolic region with `void *`.
This happens when such region gets passed as inline asm input and engine
tries to bind `UnknownVal` to that region.

Fix it by changing type from void to char before calling
`GetElementZeroRegion`
2024-09-09 18:12:38 +02:00
Martin Storsjö
cca54e347a Revert "Reapply "[Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer" (#97308)"
This reverts commit 45c8766973
and 049512e39d.

This change triggers failed asserts on inputs like this:

    struct a {
    } constexpr b;
    class c {
    public:
      c(a);
    };
    class B {
    public:
      using d = int;
      struct e {
        enum { f } g;
        int h;
        c i;
        d j{};
      };
    };
    B::e k{B::e::f, int(), b};

Compiled like this:

    clang -target x86_64-linux-gnu -c repro.cpp
    clang: ../../clang/lib/CodeGen/CGExpr.cpp:3105: clang::CodeGen::LValue
    clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(const clang::DeclRefExpr*):
    Assertion `(ND->isUsed(false) || !isa<VarDecl>(ND) || E->isNonOdrUse() ||
    !E->getLocation().isValid()) && "Should not use decl without marking it used!"' failed.
2024-09-09 15:09:45 +03:00
Nicolas van Kempen
d84d9559bd [clang][analyzer] Fix #embed crash (#107764)
Fix #107724.
2024-09-09 13:12:46 +02:00
vabridgers
da11ede57d [analyzer] Remove overzealous "No dispatcher registered" assertion (#107294)
Random testing revealed it's possible to crash the analyzer with the
command line invocation:

clang -cc1 -analyze -analyzer-checker=nullability empty.c

where the source file, empty.c is an empty source file.

```
clang: <root>/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:56:
   void clang::ento::CheckerManager::finishedCheckerRegistration():
     Assertion `Event.second.HasDispatcher && "No dispatcher registered for an event"' failed.

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/

Stack dump:
0.      Program arguments: clang -cc1 -analyze -analyzer-checker=nullability nullability-nocrash.c
 #0 ...
 ...
 #7 <addr> clang::ento::CheckerManager::finishedCheckerRegistration()
 #8 <addr> clang::ento::CheckerManager::CheckerManager(clang::ASTContext&,
             clang::AnalyzerOptions&, clang::Preprocessor const&,
             llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>,
             std::allocator<char>>>, llvm::ArrayRef<std::function<void (clang::ento::CheckerRegistry&)>>)
```

This commit removes the assertion which failed here, because it was
logically incorrect: it required that if an Event is handled by some
(enabled) checker, then there must be an **enabled** checker which can
emit that kind of Event. It should be OK to disable the event-producing
checkers but enable an event-consuming checker which has different
responsibilities in addition to handling the events.
 
Note that this assertion was in an `#ifndef NDEBUG` block, so this
change does not impact the non-debug builds.

Co-authored-by: Vince Bridgers <vince.a.bridgers@ericsson.com>
2024-09-09 03:47:39 -05:00
yronglin
45c8766973 Reapply "[Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer" (#97308)
The PR reapply https://github.com/llvm/llvm-project/pull/92527.
Implemented CWG1815 and fixed the bugs mentioned in the comments of
https://github.com/llvm/llvm-project/pull/92527 and
https://github.com/llvm/llvm-project/pull/87933.

The reason why the original PR was reverted was that errors might occur
during the rebuild.

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-09-08 22:36:49 +08:00