10 Commits

Author SHA1 Message Date
Rose Hudson
c8a62d84b9
[Clang][NFC] remove getUnqualifiedType() when it's already unqualified (#172504)
Since 8c4950951269ec58296afbeba14e99aef467f84d,
getCanonicalTypeUnqualified() calls getUnqualifiedType(), so there's no
point in calling that again on its return value.
2026-01-05 21:21:45 +01: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
Florian Mayer
842f25a5fb
[NFC] [dataflow] generalize smart pointer caching (#133350)
This allows us to use it for classes that use other names than get /
value.
2025-03-28 17:51:30 -07:00
Florian Mayer
1cbcaa4580
[clang][dataflow] Add matcher for pointer-like types to be cached (#132314)
This is used e.g. for iterators.
2025-03-21 13:27:11 -04:00
Florian Mayer
f1540484ea
[clang] [dataflow] use unqualified type for smart pointer matching (#125958)
one would assume that `getCanonicalTypeUnqualified` returns an
unqualified type, but sadly one would be wrong. the current logic fails
for std::optional as implemented in libcxx, because Star and Arrow types
mismatch in their const qualification.

there are other places in clang that use
getCanonicalTypeUnqualified().getUnqualifiedType().
2025-02-05 18:22:59 -08:00
Jan Voung
59a9a8f2ea
[clang][dataflow] Fix smart pointer accessor caching to handle aliases (#124964)
Check the canonical type in the matchers to handle aliases.
For example std::optional uses add_pointer_t<...>.
2025-01-30 09:50:21 -05:00
Jan Voung
72a28a3bf0
[clang][dataflow] Use smart pointer caching in unchecked optional accessor (#120249)
Part 2 (and final part) following
https://github.com/llvm/llvm-project/pull/120102
Allows users to do things like:

```
if (o->x.has_value()) {
  ((*o).x).value();
}
```
where the `->` and `*` are operator overload calls.

A user could instead extract the nested optional into a local variable
once instead of doing two accessor calls back to back, but currently
they are unsure why the code is flagged.
2025-01-08 08:27:16 -05:00
Jan Voung
2d5dc5c208
[clang][dataflow] Fix a missing break from a switch case -Wimplicit-fallthrough (#120739)
Missed when changing code in
https://github.com/llvm/llvm-project/pull/120102
2024-12-20 14:57:30 +00:00
Jan Voung
54309b1c2f
[clang][dataflow] Add matchers for smart pointer accessors to be cached (#120102)
This is part 1 of caching for smart pointer accessors, building on top
of the CachedConstAccessorsLattice, which caches "normal" accessors.

Smart pointer accessors are a bit different in that they may:
- have aliases to access the same underlying data (but potentially
  returning slightly different types like `&` vs `*`). Within a
  "checked" sequence users may mix uses of the different aliases and the
  check should apply to any of the spellings.
- may have non-const overloads in addition to the const version, where
  the non-const doesn't actually modify the container

Part 2 will follow and add transfer functions utilities. It will also
add a user UncheckedOptionalAccessModel. We'd seen false positives when
nesting StatusOr<optional<T>> and optional<StatusOr<T>>, etc. which this
can help address.
2024-12-20 09:01:13 -05:00