150 Commits

Author SHA1 Message Date
Ziqing Luo
7446601c6a
[-Wunsafe-buffer-usage] Fix a potential overflow bug reported by #126334 (#129169)
`MeasureTokenLength` may return an unsigned 0 representing failure in
obtaining length of a token. The analysis now gives up on such cases.
Otherwise, there might be issues caused by unsigned integer "overflow".
2025-02-28 10:33:32 -08:00
Malavika Samak
ab9cd53b86
[Wunsafe-buffer-usage] False positives for & expression indexing constant size array (arr[anything & 0]) (#112284)
Do not warn when a constant sized array is indexed with an expression
that contains bitwise and operation
involving constants and it always results in a bound safe access.

(rdar://136684050)

---------

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2025-02-25 00:31:52 +05:30
Thomas Sepez
7438a024b6
[-Wunsafe-buffer-usage] Fix assert when constexpr size passed to snprintf() (#119786) (#124022)
EvaluateAsConstExpr() can return an lvalue which is not compatible
with a subsequent getInt() call. Instead, use EvaluateAsInt() which
will use all techniques availble to get an int result compatible
with the subsequent getInt() call.
2025-02-10 19:34:50 +01:00
Malavika Samak
2a8c12b29f
"Reland "[Wunsafe-buffer-usage] Fix false positive when const sized array is indexed by const evaluatable expressions (#119340)"" (#123713)
This reverts commit 7dd34baf5505d689161c3a8678322a394d7a2929.

Fixed the assertion violation reported by
7dd34baf5505d689161c3a8678322a394d7a2929

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2025-01-21 15:00:30 +05:30
Nico Weber
7dd34baf55 Revert "[Wunsafe-buffer-usage] Fix false positive when const sized array is indexed by const evaluatable expressions (#119340)"
This reverts commit 64c2156d8802b0d7724f65ce854844670e4ec457.
Causes asserts, see
https://github.com/llvm/llvm-project/pull/119340#issuecomment-2595858729
2025-01-16 09:33:01 -05:00
Malavika Samak
64c2156d88
[Wunsafe-buffer-usage] Fix false positive when const sized array is indexed by const evaluatable expressions (#119340)
Do not warn when constant sized array is indexed by expressions that
evaluate to a const value. For instance, sizeof(T) expression value can
be evaluated at compile time and if an array is indexed by such an
expression, it's bounds can be validated.

(rdar://140320289)

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2025-01-14 08:15:15 +05:30
Malavika Samak
9c50182bf4
[-Wunsafe-buffer-usage] Suppress warning for multi-dimensional constant arrays (#118249)
Do not warn about unsafe buffer access, when multi-dimensional constant
arrays are accessed and their indices are within the bounds of the
buffer. Warning in such cases would be a false positive. Such a
suppression already exists for 1-d
arrays and it is now extended to multi-dimensional arrays.

(rdar://137926311)
(rdar://140320139)

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2024-12-12 13:27:39 +05:30
Zequan Wu
c60b055d46 Reapply "Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (#91991)"
It was originally reverted due to an [existing bug](https://github.com/llvm/llvm-project/issues/116286). Relanding it as the bug was fixed by https://github.com/llvm/llvm-project/pull/116433.
2024-11-27 11:18:05 -08:00
Congcong Cai
65c36179be
[clang][analysis][NFC]add static for internal linkage function (#117481)
Detected by misc-use-internal-linkage
2024-11-26 21:50:35 +08:00
Sirraide
dde802b153
[Clang] [NFC] Refactor AST visitors in Sema and the static analyser to use DynamicRecursiveASTVisitor (#115144)
This pr refactors all recursive AST visitors in `Sema`, `Analyze`, and
`StaticAnalysis` to inherit from DRAV instead. This is over half of the
visitors that inherit from RAV directly.

See also #115132, #110040, #93462

LLVM Compile-Time Tracker link for this branch:
https://llvm-compile-time-tracker.com/compare.php?from=5adb5c05a2e9f31385fbba8b0436cbc07d91a44d&to=b58e589a86c06ba28d4d90613864d10be29aa5ba&stat=instructions%3Au
2024-11-15 08:04:08 +01:00
Zequan Wu
b05d37d0d2 Revert "Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (#91991)"
This reverts commit a518ed2d815c16010a6262edd0414a5f60a63a39 because it causes regression. See https://github.com/llvm/llvm-project/pull/91991#issuecomment-2477456171 for detail.
2024-11-14 13:43:59 -08:00
Malavika Samak
0dcb0acf82
[-Wunsafe-buffer-usage] Fix false positives in warning againt 2-parameter std::span constructor (#115797)
Do not warn when two parameter constructor receives pointer address from
a std::addressof method and the span size is set to 1.

(rdar://139298119)

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2024-11-13 13:08:52 -08:00
Malavika Samak
da032a609c
[Wunsafe-buffer-usage] Fix false positives in handling string literals. (#115552)
Do not warn when a string literal is indexed and the idex value is
within the bounds of the length of the string.

(rdar://139106996)

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2024-11-11 16:47:28 -08:00
Dana Jansens
a518ed2d81
Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (#91991)
CXXCtorInitializers are not statements , but they point to an
initializer expression which is. When visiting a FunctionDecl, also
walk through any constructor initializers and run the warning
checks/matchers against their initializer expressions. This catches
warnings for initializing fields and calling other constructors, such
as:
    
struct C {
  C(P* Ptr) : AnUnsafeCtor(Ptr) {}
}

Field initializers can be found by traversing CXXDefaultInitExprs. This
catches warnings in places such as:
    
struct C {
  P* Ptr;
  AnUnsafeCtor U{Ptr};
};

We add tests for explicit construction, for field initialization, base
class constructor calls, delegated constructor calls, and aggregate
initialization.

Note that aggregate initialization is not fully covered where a field
specifies an initializer and it's not overridden in the aggregate initialization,
such as in:

struct AggregateViaValueInit {
    UnsafeMembers f1;
    // FIXME: A construction of this class does initialize the field
    // through this initializer, so it should warn. Ideally it should
    // also point to where the site of the construction is in
    // testAggregateViaValueInit().
    UnsafeMembers f2{3};
};

void testAggregateViaValueInit() {
    auto A = AggregateViaValueInit();
};

There are 3 tests for different types of aggregate initialization with
FIXMEs documenting this future work.

One attempt to fix this involved returning true from
MatchDescendantVisitor::shouldVisitImplicitCode(), however, it breaks expectations
for field in-class initializers by moving the SourceLocation, possibly
to inside the implicit ctor instead of on the line where the field
initialization happens.

struct C {
  P* Ptr;
  AnUnsafeCtor U{Ptr};  // expected-warning{{this is never seen then}}
};

Tests are also added for std::span(ptr, size) constructor being called
from a field initializer and a constructor initializer.

Issue #80482
2024-10-30 14:30:53 -04:00
Jay Foad
4dd55c567a
[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)
Follow up to #109133.
2024-10-24 10:23:40 +01:00
Malavika Samak
e913a33fcf
[-Wunsafe-buffer-usage] Emit a warning if pointer returned by vector::data and array::data is cast to larger type (#111910)
Emit a warning when the raw pointer retrieved from std::vector and
std::array instances are cast to a larger type. Such a cast followed by
a field dereference to the resulting pointer could cause an OOB access.
This is similar to the existing span::data warning.

(rdar://136704278)

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2024-10-17 13:48:35 -07:00
Ziqing Luo
090dc77a8d
[-Wunsafe-buffer-usage] Fix a bug and suppress libc warnings for C files (#109496)
- Fix a bug in UnsafeBufferUsage.cpp related to casting to PointerType
- Suppress -Wunsafe-buffer-usage-in-libc-call for C files

(rdar://117182250)
2024-09-22 12:29:06 -07:00
ziqingluo-90
48498ec7a4
[-Wunsafe-buffer-usage] Fix a bug in "Re-land [-Wunsafe-buffer-usage] Warning Libc functions (#101583)"
StringLiteral::getString() is not applicable to strings of wide
characters.  Added handling for that.

(rdar://117182250)
2024-09-16 17:21:24 -07:00
Ziqing Luo
ebf25d9509
[-Wunsafe-buffer-usage] Reduce false positives with constant arrays in libc warnings (#108308)
For `snprintf(a, sizeof a, ...)`, the first two arguments form a safe
pattern if `a` is a constant array. In such a case, this commit will
suppress the warning.

(rdar://117182250)
2024-09-13 13:47:07 -07:00
ziqingluo-90
de88d7db7b
[-Wunsafe-buffer-usage] Fix a bug in "warning libc functions (#101583)"
The commit d7dd2c468fecae871ba67e891a3519c758c94b63 crashes for such
an example:
```
void printf() { printf(); }
```
Because it assumes `printf` must have arguments. This commit fixes
this issue.

(rdar://117182250)
2024-09-06 12:57:47 -07:00
ziqingluo-90
d7dd2c468f
Re-land "[-Wunsafe-buffer-usage] Warning Libc functions (#101583)"
Revert commit 23457964392d00fc872fa6021763859024fb38da, and re-land
with a new flag "-Wunsafe-buffer-usage-in-libc-call" for the new
warning.

(rdar://117182250)
2024-09-05 16:56:34 -07:00
ziqingluo-90
2345796439
Revert "[-Wunsafe-buffer-usage] Warning Libc functions (#101583)"
This reverts commit 0fffdeb5f46078ddcc61e112cd38856b1165f050.

Will re-land this commit soon with a way to opt-out
2024-09-04 16:26:44 -07:00
Ziqing Luo
0fffdeb5f4
[-Wunsafe-buffer-usage] Warning Libc functions (#101583)
[-Wunsafe-buffer-usage] Add warn on unsafe calls to libc functions

Warning about calls to libc functions involving buffer access.  Warned
functions are hardcoded by names.

(rdar://117182250)
2024-09-04 12:34:43 -07:00
Fangrui Song
99313575b6 [-Wunsafe-buffer-usage] Fix warning after #102953 2024-08-15 14:17:26 -07:00
Ziqing Luo
9aa3b53ac5
[-Wunsafe-buffer-usage] Fix a small bug recently found (#102953)
`QualType::isConstantArrayType()` checks canonical type. So a following
cast should be applied to canonical type as well:

```
if (Ty->isConstantArrayType())
  cast<ConstantArrayType>(Ty.getCanonicalType());  //  cast<ConstantArrayType>(Ty) is incorrect
```
2024-08-15 12:34:15 -07:00
Malavika Samak
6b652f6eda
[attributes][-Wunsafe-buffer-usage] Support adding unsafe_buffer_usage attribute to struct fields (#101585)
Extend the unsafe_buffer_usage attribute, so they can also be added to
struct fields. This will cause the compiler to warn about the unsafe
field at their access sites.

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2024-08-14 10:45:43 -07:00
Dana Jansens
5ac3435818
Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (#91777)
The -Wunsafe-buffer-usage warning should fire on any call to a function
annotated with [[clang::unsafe_buffer_usage]], however it omitted calls
to constructors, since the expression is a CXXConstructExpr which does
not subclass CallExpr. Thus the matcher on callExpr() does not find
these expressions.

Add a new WarningGadget that matches cxxConstructExpr that are calling a
CXXConstructDecl annotated by [[clang::unsafe_buffer_usage]] and fires
the warning. The new UnsafeBufferUsageCtorAttrGadget gadget explicitly
avoids matching against the std::span(ptr, size) constructor because
that is handled by SpanTwoParamConstructorGadget and we never want two
gadgets to match the same thing (and this is guarded by asserts).

The gadgets themselves do not report the warnings, instead each gadget's
Stmt is passed to the UnsafeBufferUsageHandler (implemented by
UnsafeBufferUsageReporter). The Reporter is previously hardcoded that a
CXXConstructExpr statement must be a match for std::span(ptr, size), but
that is no longer the case. We want the Reporter to generate different
warnings (in the -Wunsafe-buffer-usage-in-container subgroup) for the
span contructor. And we will want it to report more warnings for other
std-container-specific gadgets in the future. To handle this we allow
the gadget to control if the warning is general (it calls
handleUnsafeBufferUsage()) or is a std-container-specific warning (it
calls handleUnsafeOperationInContainer()).

Then the WarningGadget grows a virtual method to dispatch to the
appropriate path in the UnsafeBufferUsageHandler. By doing so, we no
longer need getBaseStmt in the Gadget interface. The only use of it for
FixableGadgets was to get the SourceLocation, so we make an explicit
virtual method for that on Gadget. Then the handleUnsafeOperation()
dispatcher can be a virtual method that is only in WarningGadget.

The SpanTwoParamConstructorGadget gadget dispatches to
handleUnsafeOperationInContainer() while the other WarningGadgets all
dispatch to the original handleUnsafeBufferUsage().

Tests are added for annotated constructors, conversion operattors, call
operators, fold expressions, and regular methods.

Issue #80482
2024-05-16 11:01:08 -04:00
juan.vazquez
13ea36db16
Fix UPCAddressofArraySubscriptGadget::getClaimedVarUseSites() (#88406)
UPCAddressofArraySubscriptGadget::getClaimedVarUseSites should skip
parentheses when accessing the DeclRefExpr, otherwise a crash happens
with parenthesized references.
2024-04-16 12:42:59 -07:00
Chris B
28ddbd4a86
[NFC] Refactor ConstantArrayType size storage (#85716)
In PR #79382, I need to add a new type that derives from
ConstantArrayType. This means that ConstantArrayType can no longer use
`llvm::TrailingObjects` to store the trailing optional Expr*.

This change refactors ConstantArrayType to store a 60-bit integer and
4-bits for the integer size in bytes. This replaces the APInt field
previously in the type but preserves enough information to recreate it
where needed.

To reduce the number of places where the APInt is re-constructed I've
also added some helper methods to the ConstantArrayType to allow some
common use cases that operate on either the stored small integer or the
APInt as appropriate.

Resolves #85124.
2024-03-26 14:15:56 -05:00
jkorous-apple
3fa9102125
[-Wunsafe-buffer-usage][NFC] clang-format UnsafeBufferUsage.cpp (#82027) 2024-02-28 02:05:20 -08:00
Mikael Holmen
19f6689f3b [clang] Remove unused variable [NFC]
Without the fix gcc warned like
 ../../clang/lib/Analysis/UnsafeBufferUsage.cpp:2203:26: warning: unused variable 'CArrTy' [-Wunused-variable]
  2203 |   } else if (const auto *CArrTy = Ctx.getAsConstantArrayType(
       |                          ^~~~~~
2024-02-19 13:03:17 +01:00
Danny Mösch
5023fd09b4 [NFC] Trim trailing whitespace 2024-02-17 19:37:39 +01:00
jkorous-apple
fde4b80cb7
[-Wunsafe-buffer-usage] Minimize fixit range for pointer variables (#81935)
Example:
int * const my_var = my_initializer;

Currently when transforming my_var to std::span the fixits:
- replace "int * const my_var = " with "std::span<int> const my_var {"
- add ", SIZE}" after "my_initializer" where SIZE is either inferred or
a placeholder

This patch makes that behavior less intrusive by not modifying variable
cv-qualifiers and initialization syntax.
The new behavior is:
- replace "int *" with "std::span<int>"
- add "{" before "my_initializer"
- add ", SIZE}" after "my_initializer"

This is an improvement on its own - since we don't touch the identifier,
we automatically can handle macros in them.
It also simplifies future work on initializer fixits.
2024-02-16 14:25:21 -08:00
Fangrui Song
c92dfefd46 [-Wunsafe-buffer-usage] Remove unused function after 7c3ad9e72bc034ad655a7e16aa73b9864c58768b. NFC 2024-02-16 14:10:43 -08:00
jkorous-apple
7c3ad9e72b
[-Wunsafe-buffer-usage] Fix fixits for span initialized from const size array (#81927)
Example:
int arr[10];
int * ptr = arr;

If ptr is unsafe and we transform it to std::span then the fixit we'd
currently provide transforms the code to:
std::span<int> ptr{arr, 10};

That's suboptimal as that repeats the size of the array in the code.
The idiomatic transformation should rely on the span constructor
that takes just the array argument and relies on template
parameter autodeduction to set the span size.

The transformed code should look like:
std::span<int> ptr = arr;

Note that it just should not change the initializer at all and that also
works for other forms of initialization like:
int * ptr {arr};
becoming:
std::span<int> ptr{arr};

This patch changes the initializer handling to the desired (empty)
fixit.
2024-02-16 13:10:51 -08:00
jkorous-apple
6fce42f89a
[-Wunsafe-buffer-usage] Add fixits for array to pointer assignment (#81343)
Introducing CArrayToPtrAssignment gadget and implementing fixits for some cases
of array being assigned to pointer.

Key observations:
- const size array can be assigned to std::span and bounds are propagated
- const size array can't be on LHS of assignment
This means array to pointer assignment has no strategy implications.

Fixits are implemented for cases where one of the variables in the assignment is
safe. For assignment of a safe array to unsafe pointer we know that the RHS will
never be transformed since it's safe and can immediately emit the optimal fixit.
Similarly for assignment of unsafe array to safe pointer.
(Obviously this is not and can't be future-proof in regards to what
variables we consider unsafe and that is fine.)

Fixits for assignment from unsafe array to unsafe pointer (from Array to Span
strategy) are not implemented in this patch as that needs to be properly designed
first - we might possibly implement optimal fixits for partially transformed
cases, put both variables in a single fixit group or do something else.
2024-02-14 19:03:37 -08:00
jkorous-apple
9a1e6373ab
[-Wunsafe-buffer-usage] Ignore constant safe indices in array subscripts (#80504)
[-Wunsafe-buffer-usage] Ignore safe array subscripts
Don't emit warnings for array subscripts on constant size arrays where the index is constant and within bounds.

Example:
int arr[10];
arr[5] = 0; //safe, no warning

This patch recognizes only array indices that are integer literals - it doesn't understand more complex expressions (arithmetic on constants, etc.).

-Warray-bounds implemented in Sema::CheckArrayAccess() already solves a similar
(opposite) problem, handles complex expressions and is battle-tested.

Adding -Wunsafe-buffer-usage diagnostics to Sema is a non-starter as we need to emit
both the warnings and fixits and the performance impact of the fixit machine is
unacceptable for Sema.

CheckArrayAccess() as is doesn't distinguish between "safe" and "unknown" array
accesses. It also mixes the analysis that decides if an index is out of bounds
with crafting the diagnostics.

A refactor of CheckArrayAccess() might serve both the original purpose
and help us avoid false-positive with -Wunsafe-buffer-usage on constant
size arrrays.
2024-02-14 18:16:44 -08:00
jkorous-apple
4cd7616f6b
[-Wunsafe-buffer-usage] Fixits for array args of func-ptr calls (#80358)
Currently we ignore calls on function pointers (unlike direct calls of
functions and class methods). This patch adds support for function pointers as
well.

The change is to simply replace use of forEachArgumentWithParam matcher in UPC
gadget with forEachArgumentWithParamType.

from the documentation of forEachArgumentWithParamType:
/// Matches all arguments and their respective types for a \c CallExpr or
/// \c CXXConstructExpr. It is very similar to \c forEachArgumentWithParam but
/// it works on calls through function pointers as well.

Currently the matcher also uses hasPointerType() which checks that the
canonical type of an argument is pointer and won't match on arrays decayed to
pointer. Replacing hasPointerType() with isAnyPointerType() which allows
implicit casts allows for the arrays to be matched as well and this way we get
fixits for array arguments to function pointer calls too.
2024-02-14 17:19:39 -08:00
jkorous-apple
e06f3522cc
[-Wunsafe-buffer-usage] Emit fixits for array decayed to pointer (#80347)
Covers cases where DeclRefExpr referring to a const-size array decays to a
pointer and is used "as a pointer" (e. g. passed to a pointer type
parameter).

Since std::array<T, N> doesn't implicitly convert to pointer to its element
type T* the cast needs to be done explicitly as part of the fixit
when we retrofit std::array to code that previously worked with constant
size array. std::array::data() method is used for the explicit
cast.

In terms of the fixit machine this covers the UPC(DRE) case for Array fixit strategy.
The emitted fixit inserts call to std::array::data() method similarly to
analogous fixit for Span strategy.
2024-02-13 14:31:11 -08:00
jkorous-apple
644ac2a018
[-Wunsafe-buffer-usage] Introduce std::array fixits (#80084)
Array subscript on a const size array is not bounds-checked. The idiomatic
replacement is std::array which is bounds-safe in hardened mode of libc++.

This commit extends the fixit-producing machine to consider std::array as a
transformation target type and teaches it to handle the array subscript on const
size arrays with a trivial (empty) fixit.
2024-02-12 15:52:20 -08:00
jkorous-apple
2f490583c3
[-Wunsafe-buffer-usage] Fix debug notes for unclaimed DREs (#80787)
Debug notes for unclaimed DeclRefExpr should report any DRE of an unsafe
variable that is not covered by a Fixable (i. e. fixit for the
particular AST pattern isn't implemented for whatever reason). Currently
not all unclaimed DeclRefExpr-s are reported which is a bug. The debug
notes report only those DREs where the referred VarDecl has at least one
other DeclRefExpr which is claimed (covered by a fixit). If there is an
unsafe VarDecl that has exactly one DRE and the DRE isn't claimed then
the debug note about missing fixit won't be emitted. That is because the
debug note is emitted from within a loop over set of successfully
matched FixableGadgets which by-definition is missing those DRE that are
not matched at all.

The new code simply iterates over all unsafe VarDecls and all of their
unclaimed DREs.
2024-02-06 16:19:46 -08:00
jkorous-apple
e5cebec521
[-Wunsafe-buffer-usage] Fix AST matcher of UUCAddAssignGadget (#79392)
We are not interested in nonpointers being added to.
2024-01-30 14:28:35 -08:00
Ziqing Luo
9816863dd4
[-Wunsafe-buffer-usage] Add a new warning for uses of std::span two-parameter constructors (#77148)
Constructing `std::span` objects with the two parameter constructors
could introduce mismatched bounds information, which defeats the
purpose of using `std::span`.  Therefore, we warn every use of such
constructors.

rdar://115817781
2024-01-26 15:43:46 -08:00
Malavika Samak
414df7051a
[-Wunsafe-buffer-usage] Fix the crash introduced by the unsafe invocation of span::data warning (#78815)
The patch fixes the crash introduced by the DataInvocation warning
gadget designed to warn against unsafe invocations of span::data method.

It also now considers the invocation of span::data method inside
parenthesis.

Radar: 121223051

---------

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2024-01-22 10:46:59 -08:00
Malavika Samak
7122f55c63
[-Wunsafe-buffer-usage] Warning for unsafe invocation of span::data (#75650)
…-Wunsafe-buffer-usage,

there maybe accidental re-introduction of new OutOfBound accesses into
the code bases. One such case is invoking span::data() method on a span
variable to retrieve a pointer, which is then cast to a larger type and
dereferenced. Such dereferences can introduce OutOfBound accesses.

To address this, a new WarningGadget is being introduced to warn against
such invocations.

---------

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2024-01-02 15:41:00 -08:00
smanna12
a9b3054544
[NFC][CLANG] Fix static analyzer bugs about large copy by values (#75060)
Reported by Static Analyzer tool:

In getSourceRangeToTokenEnd(clang::Decl const *, clang::SourceManager
const &, clang::LangOptions): A very large function call parameter
exceeding the high threshold is passed by value

pass_by_value: Passing parameter LangOpts of type clang::LangOptions
(size 1784 bytes) by value, which exceeds the high threshold of 512
bytes
2023-12-12 08:07:55 -06:00
Rashmi Mudduluru
e1655a98cb
[-Wunsafe-buffer-usage] Add FixableGadget for AddAssign in UnspecifiedUntypedContext (#71862) 2023-12-11 15:00:08 -08:00
ziqingluo-90
a4323586fc [-Wunsafe-buffer-usage] Add AST info to the unclaimed DRE debug notes for analysis
- For a better understand of what the unsupported cases are, we add
  more information to the debug note---a string of ancestor AST nodes
  of the unclaimed DRE. For example, an unclaimed DRE p in an
  expression `*(p++)` will result in a string starting with
  `DRE ==> UnaryOperator(++) ==> Paren ==> UnaryOperator(*)`.

- To find out the most common patterns of those unsupported use cases,
  we add a simple script to build a prefix tree over those strings and
  count each prefix. The script reads input line by line, assumes a
  line is a list of words separated by `==>`s, and builds a prefix tree
  over those lists.

Reviewed by: t-rasmud (Rashmi Mudduluru), NoQ (Artem Dergachev)

Differential revision: https://reviews.llvm.org/D158561
2023-10-20 14:27:14 -07:00
Manna, Soumi
06c9cc7eaa [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto
Reviewed By: tahonermann

Differential Revision: https://reviews.llvm.org/D159474
2023-09-28 09:00:55 -07:00
Ziqing Luo
700baeb765 [-Wunsafe-buffer-usage] Use Strategy to determine whether to fix a parameter
- Use Strategy to determine whether to fix a parameter
- Fix the `Strategy` construction so that only variables on the graph
are assigned the `std::span` strategy

Reviewed by: t-rasmud (Rashmi Mudduluru), NoQ (Artem Dergachev)

Differential revision: https://reviews.llvm.org/D157441
2023-09-21 15:06:22 -07:00