189 Commits

Author SHA1 Message Date
Rohan Jacob-Rao
b4a32db1f2
[NFC][Clang][unsafe-buffer-usage] Simplify isPtrBufferSafe with helper. (#178768)
Also change parameter type to a reference since it's assumed to be
nonnull.
2026-02-06 00:58:49 +00:00
Rohan Jacob-Rao
2b3d97ad2d
[NFC][Clang][UnsafeBufferUsage] Remove unnecessary struct. (#178801)
The struct has no members and has a surrounding namespace that can be
used for disambiguating names. This was also mentioned in a previous PR
review:
https://github.com/llvm/llvm-project/pull/101583/changes#r1737089937
2026-02-05 16:15:09 -08:00
Rohan Jacob-Rao
90f575ba81
[NFC][Clang][UnsafeBufferUsage] Simplify libc function matchers. (#178985) 2026-02-03 10:51:15 -08:00
Rohan Jacob-Rao
4aaa2d7e4d
[Clang][-Wunsafe-buffer-usage] Allow safe form of libc memset. (#178107)
This allows a common, memory-safe form of memset, `memset(&x, val,
sizeof(x))`. There are potentially other safe forms that we can allow in
later PRs. The tests cover some of the possible cases.
2026-01-29 13:31:37 -08:00
Rohan Jacob-Rao
c75868d957
[NFC][Clang] Minor cleanups in UnsafeLibcFunctionCallGadget::matches(). (#177514)
- Remove unneeded dynamic cast
- Add consts
- Simplify boolean condition
2026-01-23 13:28:59 -08:00
Ziqing Luo
6438ddf252
[-Wunsafe-buffer-usage] Improve null-termination analysis on conditionals (#176262)
This commit adds two improvements to null-termination analysis on
conditionals:
- perform recursive constant folding
- when the condition is not a constant, analyze both branches for
null-termination

rdar://168256816
2026-01-20 09:16:54 -08:00
Hans Wennborg
3d90b7a2d7
[-Wunsafe-buffer-usage] Separate flag for format-attributed functions (#175749)
PR #173096 extended -Wunsafe-buffer-usage-in-libc-call to apply to all
functions with the 'format' attribute.

This change moves those warnings behind a separate
-Wunsafe-buffer-usage-in-format-attr-call flag (implicitly enabled by
-Wunsafe-buffer-usage), allowing projects to decide whether they want to
opt in to this or not.
2026-01-19 10:11:34 +00:00
Max
762a44f2c3
[clang][Wunsafe-buffer-usage] Add -Wunsafe-buffer-usage-in-static-sized-array (#176466)
This PR adds support for toggling on/off warnings around static sized
arrays. This supports / addresses
https://github.com/llvm/llvm-project/issues/87284, for those who use
-fsanitize=array-bounds which inserts checks for fixed sized arrays
already.
2026-01-16 21:27:36 +00:00
Rohan Jacob-Rao
4a4fa0a730
[NFC][Clang][-Wunsafe-buffer-usage] Rename variable to upper camel case. (#176286)
Trivial renaming following the [style
guide](https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly).

This is mostly to familiarize myself with the workflow for contributing
to LLVM.
2026-01-16 21:06:35 +00:00
Max
eb82ddc53a
[clang][-Wunsafe-buffer-usage] Ignore consteval functions (#171503)
We dont need to visit or warn on consteval functions as they can't have
UB.

---------

Co-authored-by: mxms <mxms@google.com>
2026-01-15 12:42:05 -05:00
Henry
c6f6efba3b
[NFC] Implicit container copy cleanup (#174702)
A set of cleanup for redundant implicit container copies. Fixed with
const reference or move semantics.

e8996cb24 [AMDGPU] replace copy with const reference (NFC)
25ceecee8 [-Wunsafe-buffer-usage] Replace vector copy with reference
(NFC)
e1f5254e0 [AMDGPU] Replace copy with move semantics (NFC)
8261250d7 [InstCombine] Replace vector copy with move semantic (NFC)
749bb21de [CommandLine] Avoid vector copy for const argument (NFC)
b89526f90 [LoongArch] Remove unnecessary vector copy (NFC)
6b22bcf56 [TextAPI] Replace map copy with const reference (NFC)
a121519d8 [BlockExtract] Avoid copy semantic for ctor (NFC)
3034d3063 [LifetimeSafety] Avoid map copy for dump methods (NFC)

---------

Co-authored-by: sfu <afwbu8tp6@mozmail.com>
2026-01-14 11:16:32 +01:00
Hans Wennborg
853a8b4f33
[-Wunsafe-buffer-usage] Allow strerror for %s in printf-like calls (#175208)
Passing strerror(errno) to printf of printf-like logging functions is a
common pattern, and strerror() returns a null-terminated string.

Follow-up to #173096
2026-01-10 07:41:49 +01:00
Ziqing Luo
2926b4100d
[-Wunsafe-buffer-usage] Fix crashes in "Add check for custom printf/scanf functions #173096" (#174683)
The previous PR #173096 assumes that format attribute parameters always
refer to valid indices of arguments. It is a wrong assumption in itself
because the second attribute parameter could specify the index after the
last named parameter for variadic functions and no actual arguments
passed beyond named parameters. In addition, clang (possibly
incorrectly) allows the following uses of the attribute:

```
void f(const char *) __attribute__((__format__ (__printf__, 1, 2))); // The second attribute argument 2 will not refer to any valid argument at any call of 'f'

void g(const char *) __attribute__((__format__ (__printf__, 1, 99))); // Clang is even quiet on this, if assertions are disabled :(
```
2026-01-08 09:20:27 -08:00
willmafh
2eb8ee137f
[NFC] Delete unnecessary apostrophe at the end of its (#173974) 2026-01-04 20:02:40 +08:00
Ziqing Luo
e9b2b21f74
[-Wunsafe-buffer-usage] Fix a false negative introduced in #173096 (#174253)
A downstream test recovers a false negative introduced in #173096, where
it changed the use of variable `FmtArgIdx` to `FmtArgStartingIdx`. The
two variables are different in that `FmtArgIdx` refers to the index of
the format string and `FmtArgStartingIdx` refers to the index of the
first format argument. The consequence is that the analysis will miss
reporting an unsafe format string.

This fix also upstreams the test catching the FN.
2026-01-02 17:48:43 -08:00
Ziqing Luo
81b46646fb
[-Wunsafe-buffer-usage] Add check for custom printf/scanf functions (#173096)
This commit adds support for functions annotated with
`__attribute__((__format__(__printf__, ...)))` (or `__scanf__`). These
functions will be treated the same way as printf/scanf functions in the
standard C library by `-Wunsafe-buffer-usage`

rdar://143233737
2026-01-02 11:10:31 -08:00
flovent
b5dd6cc746
[clang][BufferUsage] Fix crash when parsing invalid format string (#170496)
`clang::analyze_format_string::ParsePrintfString` also returns `true`
when we get an invalid or erroneous format string, so `UnsafeArg` will
not be set, but `hasUnsafeFormatOrSArg`'s caller assumes `UnsafeArg`
will be valid when it returns true, which leads to crash.

Closes #169629
2025-12-17 09:56:38 -08:00
Ziqing Luo
a630642585
[-Wunsafe-buffer-usage] Check isValueDependent before EvaluateAsBooleanCondition (#172091)
The function `EvaluateAsBooleanCondition` assumes (asserts) that the
input `Expr` is not in a dependent context. So it is caller's
responsibility to check the condition before the call. This commit fixes
the issue in `UnsafeBufferUsage.cpp`.

The issue was first found downstream because of some code not
upstreamed. This commit also includes those un-upstreamed code.

rdar://166217941
2025-12-13 19:54:22 +00:00
Ziqing Luo
3f60d22051
[-Wunsafe-buffer-usage] Fold the expression "cond ? E1 : E2" when checking safe patterns, if "cond" is a constant (#167989)
In `-Wunsafe-buffer-usage`, many safe pattern checks can benefit from
constant folding. This commit improves null-terminated pointer checks by
folding conditional expressions.

rdar://159374822

---------

Co-authored-by: Balázs Benics <benicsbalazs@gmail.com>
2025-11-17 13:43:53 -08:00
shreya-jain
9aa94f6b29
[-Wunsafe-buffer-usage] Add unique_ptr <T[]> accesses (#156773)
Add operator[] accesses of `unique_ptr<T[]>` to `-Wunsafe-buffer-usage`
as a subcategory under `-Wunsafe-buffer-usage-unique-ptr-array-access`.

Also discussed in
https://github.com/issues/assigned?issue=llvm%7Cllvm-project%7C73452
2025-10-08 10:55:34 -07:00
Timm Baeder
d6315a260b
[clang][BufferUsage] Fix a StringRef lifetime issue (#159109)
The code before assigned the `std::string` returned from
`tryEvaluateString()` to the `StringRef`, but it was possible that the
underlying data of that string vanished in the meantime, passing invalid
stack memory to `ParsePrintfString`.

Fix this by using two different code paths for the `getCharByteWidth()
== 1` case and the `tryEvaluateString()` one.
2025-09-17 16:07:12 +02:00
Matheus Izvekov
249167a898
[clang] NFC: reintroduce clang/include/clang/AST/Type.h (#155050)
This reintroduces `Type.h`, having earlier been renamed to `TypeBase.h`,
as a redirection to `TypeBase.h`, and redirects most users to include
the former instead.

This is a preparatory patch for being able to provide inline definitions
for `Type` methods which would otherwise cause a circular dependency
with `Decl{,CXX}.h`.

Doing these operations into their own NFC patch helps the git rename
detection logic work, preserving the history.

This patch makes clang just a little slower to build (~0.17%), just
because it makes more code indirectly include `DeclCXX.h`.
2025-08-27 13:11:34 -03:00
Matheus Izvekov
bcd1530836
[clang] NFC: rename clang/include/clang/AST/Type.h to TypeBase.h (#155049)
This is a preparatory patch, to be able to provide inline definitions
for `Type` functions which depend on `Decl{,CXX}.h`. As the latter also
depends on `Type.h`, this would not be possible without some
reorganizing.

Splitting this rename into its own patch allows git to track this as a
rename, and preserve all git history, and not force any code
reformatting.

A later NFC patch will reintroduce `Type.h` as redirection to
`TypeBase.h`, rewriting most places back to directly including `Type.h`
instead of `TypeBase.h`, leaving only a handful of places where this is
necessary.

Then yet a later patch will exploit this by making more stuff inline.
2025-08-27 13:09:48 -03:00
Kazu Hirata
136b541304
[clang] Replace SmallSet with SmallPtrSet (NFC) (#154262)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 30 instances that rely on this "redirection", with about
half of them under clang/.  Since the redirection doesn't improve
readability, this patch replaces SmallSet with SmallPtrSet for pointer
element types.

I'm planning to remove the redirection eventually.
2025-08-19 07:11:39 -07:00
Matheus Izvekov
91cdd35008
[clang] Improve nested name specifier AST representation (#147835)
This is a major change on how we represent nested name qualifications in
the AST.

* The nested name specifier itself and how it's stored is changed. The
prefixes for types are handled within the type hierarchy, which makes
canonicalization for them super cheap, no memory allocation required.
Also translating a type into nested name specifier form becomes a no-op.
An identifier is stored as a DependentNameType. The nested name
specifier gains a lightweight handle class, to be used instead of
passing around pointers, which is similar to what is implemented for
TemplateName. There is still one free bit available, and this handle can
be used within a PointerUnion and PointerIntPair, which should keep
bit-packing aficionados happy.
* The ElaboratedType node is removed, all type nodes in which it could
previously apply to can now store the elaborated keyword and name
qualifier, tail allocating when present.
* TagTypes can now point to the exact declaration found when producing
these, as opposed to the previous situation of there only existing one
TagType per entity. This increases the amount of type sugar retained,
and can have several applications, for example in tracking module
ownership, and other tools which care about source file origins, such as
IWYU. These TagTypes are lazily allocated, in order to limit the
increase in AST size.

This patch offers a great performance benefit.

It greatly improves compilation time for
[stdexec](https://github.com/NVIDIA/stdexec). For one datapoint, for
`test_on2.cpp` in that project, which is the slowest compiling test,
this patch improves `-c` compilation time by about 7.2%, with the
`-fsyntax-only` improvement being at ~12%.

This has great results on compile-time-tracker as well:

![image](https://github.com/user-attachments/assets/700dce98-2cab-4aa8-97d1-b038c0bee831)

This patch also further enables other optimziations in the future, and
will reduce the performance impact of template specialization resugaring
when that lands.

It has some other miscelaneous drive-by fixes.

About the review: Yes the patch is huge, sorry about that. Part of the
reason is that I started by the nested name specifier part, before the
ElaboratedType part, but that had a huge performance downside, as
ElaboratedType is a big performance hog. I didn't have the steam to go
back and change the patch after the fact.

There is also a lot of internal API changes, and it made sense to remove
ElaboratedType in one go, versus removing it from one type at a time, as
that would present much more churn to the users. Also, the nested name
specifier having a different API avoids missing changes related to how
prefixes work now, which could make existing code compile but not work.

How to review: The important changes are all in
`clang/include/clang/AST` and `clang/lib/AST`, with also important
changes in `clang/lib/Sema/TreeTransform.h`.

The rest and bulk of the changes are mostly consequences of the changes
in API.

PS: TagType::getDecl is renamed to `getOriginalDecl` in this patch, just
for easier to rebasing. I plan to rename it back after this lands.

Fixes #136624
Fixes https://github.com/llvm/llvm-project/issues/43179
Fixes https://github.com/llvm/llvm-project/issues/68670
Fixes https://github.com/llvm/llvm-project/issues/92757
2025-08-09 05:06:53 -03:00
Ziqing Luo
0abf4975bb
[-Wunsafe-buffer-usage] Do not warn about class methods with libc function names (#151270)
This commit fixes the false positive that C++ class methods with libc
function names would be false warned about. For example,

```
struct T {void strcpy() const;};
void test(const T& t) {  str.strcpy(); // no warn }
```

rdar://156264388
2025-08-07 14:31:13 +08:00
Ziqing Luo
e10b182a5f
[-Wunsafe-buffer-usage] Support safe patterns of "%.*s" in printf functions (#145862)
The character buffer passed to a "%.*s" specifier may be safely bound if
the precision is properly specified, even if the buffer does not
guarantee null-termination.
For example,
```
void f(std::span<char> span) {
  printf("%.*s", (int)span.size(), span.data());  // "span.data()" does not guarantee null-termination but is safely bound by "span.size()", so this call is safe
}
```
rdar://154072130
2025-07-30 11:57:04 +08:00
Ziqing Luo
29436737ba
[NFC][-Wunsafe-buffer-usage] Refactor safe pattern check for pointer-size pairs (#145626)
Refactor the safe pattern analysis of pointer and size expression pairs
so that the check can be re-used in more places. For example, it can be
used to check whether the following cases are safe:
- `std::span<T>{ptr, size}        // span construction`
- `snprintf(ptr, size, "%s", ...)  // unsafe libc call`
- `printf("%.*s", size, ptr)        // unsafe libc call`
2025-07-15 16:48:20 +08:00
Ziqing Luo
3140333872
[-Wunsafe-buffer-usage] Support span creation from std::initializer_list and begin/end pairs (#145311)
Support safe construction of `std::span` from `begin` and `end` calls on
hardened containers or views or `std::initializer_list`s.

For example, the following code is safe:
```
void create(std::initializer_list<int> il) {
    std::span<int> input{ il.begin(), il.end() }; // no warn
}
```

rdar://152637380
2025-06-25 09:32:03 +08:00
Kazu Hirata
c01532177f
[clang] Remove unused includes (NFC) (#144285)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-06-15 21:00:36 -07:00
Abhina Sree
680463bab1
Fix error that reference to PointerType is ambiguous in clang/lib/Analysis/UnsafeBufferUsage.cpp (#142966)
The CI on my PR https://github.com/llvm/llvm-project/pull/138895 is
failing with errors like

`clang/lib/Analysis/UnsafeBufferUsage.cpp:971:45: error: reference to
'PointerType' is ambiguous`

This patch should resolve it by removing `using namespace llvm`
2025-06-05 11:51:12 -04:00
Malavika Samak
39315663a4
[-Wunsafe-buffer-usage] Fix false warnings when const sized array is safely accessed (array [idx %const]) (#140113)
The -Wunsafe-buffer-usage analysis currently warns when a const sized
array is safely accessed, with an index that is bound by the remainder
operator. The false alarm is now suppressed.

Example:

int circular_buffer(int array[10], uint idx) {
   return array[idx %10]; // Safe operation
}

rdar://148443453

---------

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2025-05-16 18:33:51 -07:00
Ziqing Luo
be48c0df77
[-Wunsafe-buffer-usage] Fix a bug that wrongly assumed CXXMethodDecl always has an identifier (#137248)
Fix a bug in UnsafeBufferUsage.cpp that wrongly assumed that
CXXMethodDecl always has an identifier.

rdar://149071318
2025-04-24 17:03:06 -07:00
Jan Korous
ee801cdd6e
[-Wunsafe-buffer-usage] Add findUnsafePointers (#135421) 2025-04-11 13:28:18 -07:00
Jan Korous
de5b099dd1
[-Wunsafe-buffer-usage][NFC] Factor out FixitUtil (#135100) 2025-04-11 10:47:52 -07:00
Ilya Biryukov
da69eb75cb
[NFC] [ASTMatchers] Share code of forEachArgumentWithParamType with UnsafeBufferUsage (#132387)
This changes exposes a low-level helper that is used to implement
`forEachArgumentWithParamType` but can also be used without matchers,
e.g. if performance is a concern.

Commit f5ee10538b68835112323c241ca7db67ca78bf62 introduced a copy of the
implementation of the `forEachArgumentWithParamType` matcher that was
needed for optimizing performance of `-Wunsafe-buffer-usage`.

This change shares the code between the two so that we do not repeat
ourselves and any bugfixes or changes will be picked up by both
implementations in the future.
2025-04-04 14:35:15 +02:00
Kazu Hirata
c6c394634c
[clang] Use *Set::insert_range (NFC) (#132507)
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently
gained C++23-style insert_range.  This patch replaces:

  Dest.insert(Src.begin(), Src.end());

with:

  Dest.insert_range(Src);

This patch does not touch custom begin like succ_begin for now.
2025-03-22 08:06:38 -07:00
Ivana Ivanovska
f5ee10538b
[Clang] Optimize -Wunsafe-buffer-usage. (#125492)
The Clang disgnostic `-Wunsafe-buffer-usage` was adding up to +15%
compilation time when used. Profiling showed that most of the overhead
comes from the use of ASTMatchers.

This change replaces the ASTMatcher infrastructure with simple matching
functions and keeps the functionality unchanged. It reduces the overhead
added by `-Wunsafe-buffer-usage` by 87.8%, leaving a negligible
additional compilation time of 1.7% when the diagnostic is used.

**Old version without -Wunsafe-buffer-usage:**
```
$ hyperfine -i -w 1 --runs 5 '/tmp/old_clang -c -std=c++20 /tmp/preprocessed.cc -ferror-limit=20' 
Benchmark 1: /tmp/old_clang -c -std=c++20 /tmp/preprocessed.cc -ferror-limit=20
  Time (mean ± σ):     231.035 s ±  3.210 s    [User: 229.134 s, System: 1.704 s]
  Range (min … max):   228.751 s … 236.682 s    5 runs
```

**Old version with -Wunsafe-buffer-usage:**
```
$ hyperfine -i -w 1 --runs 10 '/tmp/old_clang -c -std=c++20 /tmp/preprocessed.cc -ferror-limit=20 -Wunsafe-buffer-usage'
Benchmark 1: /tmp/old_clang -c -std=c++20 /tmp/preprocessed.cc -ferror-limit=20 -Wunsafe-buffer-usage
  Time (mean ± σ):     263.840 s ±  0.854 s    [User: 262.043 s, System: 1.575 s]
  Range (min … max):   262.442 s … 265.142 s    10 runs
```

**New version with -Wunsafe-buffer-usage:**
```
$ hyperfine -i -w 1 --runs 10 '/tmp/new_clang -c -std=c++20 /tmp/preprocessed.cc -ferror-limit=20 -Wunsafe-buffer-usage'
Benchmark 1: /tmp/new_clang -c -std=c++20 /tmp/preprocessed.cc -ferror-limit=20 -Wunsafe-buffer-usage
  Time (mean ± σ):     235.169 s ±  1.408 s    [User: 233.406 s, System: 1.561 s]
  Range (min … max):   232.221 s … 236.792 s    10 runs
```
2025-03-20 11:58:50 +01:00
Ziqing Luo
b2563028cf
[-Wunsafe-buffer-usage] Add alloc_size knowledge to the 2-param span constructor warning (#114894)
We can take advantage of the attribute `alloc_size`.  For example, 
```
void * malloc(size_t size) __attribute__((alloc_size(1)));

std::span<char>{(char *)malloc(x), x}; // this is safe
```

rdar://136634730
2025-03-07 15:05:20 -08:00
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