History log of /llvm-project/clang/lib/AST/CXXInheritance.cpp (Results 1 – 25 of 90)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6
# 01710aa3 09-Dec-2024 Vladislav Belov <vladislav.belov@syntacore.com>

[clang] Fix cast for injected types in case name lookup for dependent bases (#119024)

An assertion failure occurs in Clang when attempting to compile such an
example:

```c++
template <typename, typ

[clang] Fix cast for injected types in case name lookup for dependent bases (#119024)

An assertion failure occurs in Clang when attempting to compile such an
example:

```c++
template <typename, typename, bool> struct MozPromise {
class Private;

private:
int mMagic4 = 42;
};

template <typename ResolveValueT, typename RejectValueT, bool IsExclusive>
struct MozPromise<ResolveValueT, RejectValueT, IsExclusive>::Private : MozPromise {
void SetTaskPriority() { mMagic4 ; }
};
```

Output:
```
clang: llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = clang::RecordType; From = clang::QualType]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
```

The reason is in the incorrect way of casting types when searching for
names in base classes

```c++
return Specifier->getType()->castAs<RecordType>()->getDecl()->getCanonicalDecl() == BaseRecord;
```

It loses injected types for template class names.

This patch provides fix for such cases

show more ...


# e1cb316c 03-Dec-2024 Vladislav Belov <vladislav.belov@syntacore.com>

Reapply "[clang] Fix name lookup for dependent bases" (#118003)

Unlike the previous version
(https://github.com/llvm/llvm-project/pull/114978), this patch also
removes an unnecessary assert that c

Reapply "[clang] Fix name lookup for dependent bases" (#118003)

Unlike the previous version
(https://github.com/llvm/llvm-project/pull/114978), this patch also
removes an unnecessary assert that causes Clang to crash when compiling
such tests. (clang/lib/AST/DeclCXX.cpp)

https://lab.llvm.org/buildbot/#/builders/52/builds/4021

```c++
template <class T>
class X {
public:
X() = default;
virtual ~X() = default;

virtual int foo(int x, int y, T &entry) = 0;

void bar() {
struct Y : public X<T> {
Y() : X() {}

int foo(int, int, T &) override {
return 42;
}
};
}
};
```

the assertions:

```c++
llvm-project/clang/lib/AST/DeclCXX.cpp:2508: void clang::CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *): Assertion `!MD->getParent()->isDependentContext() && "Can't add an overridden method to a class template!"' failed.
```

I believe that this assert is unnecessary and contradicts the logic of
this patch. After its removal, Clang was successfully built using
itself, and all tests passed.

show more ...


Revision tags: llvmorg-19.1.5
# f7dc1d0a 26-Nov-2024 Anton Sidorenko <anton.sidorenko@syntacore.com>

Revert "[Clang] Fix name lookup for dependent bases (#114978)" (#117727)

This reverts commit 486644723038555a224fd09d462bb5099e64809e as
requested by the commit author.

Buildbots fail:
* https:

Revert "[Clang] Fix name lookup for dependent bases (#114978)" (#117727)

This reverts commit 486644723038555a224fd09d462bb5099e64809e as
requested by the commit author.

Buildbots fail:
* https://lab.llvm.org/buildbot/#/builders/164/builds/4945
* https://lab.llvm.org/buildbot/#/builders/52/builds/4021

show more ...


# 48664472 26-Nov-2024 Vladislav Belov <vladislav.belov@syntacore.com>

[Clang] Fix name lookup for dependent bases (#114978)

Currently the following example is a compilation failure:
```cpp
template<typename T> struct A {
typedef int M;
struct B {
t

[Clang] Fix name lookup for dependent bases (#114978)

Currently the following example is a compilation failure:
```cpp
template<typename T> struct A {
typedef int M;
struct B {
typedef void M;
struct C;
};
};

template<typename T> struct A<T>::B::C : A<T> {
M m; // void or int ?
};
```

According to the point 13.8.3.2

```
A dependent base class is a base class that is a dependent type and is not the current instantiation.
Note 2 : A base class can be the current instantiation in the case of a nested class naming an enclosing class as a base.
```

The base class `A` is the current instantiation, because `C` is a nested
class for an enclosing class `A<T>`, it's is the not-dependent base
class and we need to search the names through its scope.

This patch makes this example compile

show more ...


Revision tags: llvmorg-19.1.4
# dec6324c 17-Nov-2024 Kazu Hirata <kazu@google.com>

[AST] Remove unused includes (NFC) (#116549)

Identified with misc-include-cleaner.


Revision tags: llvmorg-19.1.3, llvmorg-19.1.2
# 4c9c2d60 07-Oct-2024 Kazu Hirata <kazu@google.com>

[AST] Avoid repeated hash lookups (NFC) (#111327)

Here I'm splitting up the existing "if" statement into two. Mixing
hasDefinition() and insert() in one "if" condition would be extremely
confusin

[AST] Avoid repeated hash lookups (NFC) (#111327)

Here I'm splitting up the existing "if" statement into two. Mixing
hasDefinition() and insert() in one "if" condition would be extremely
confusing as hasDefinition() doesn't change anything while insert()
does.

show more ...


Revision tags: llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4
# 1812e13a 23-Feb-2023 Alexander Kornienko <alexfh@google.com>

Revert "[clang] Add the check of membership for the issue #58674 and improve the lookup process"

The commit causes clang to crash. See https://reviews.llvm.org/D143840#4147234

This reverts commit 8

Revert "[clang] Add the check of membership for the issue #58674 and improve the lookup process"

The commit causes clang to crash. See https://reviews.llvm.org/D143840#4147234

This reverts commit 8498ba6c2860c838183f9951b63df26ab5f02265.

show more ...


Revision tags: llvmorg-16.0.0-rc3
# 8498ba6c 12-Feb-2023 Liming Liu <gangliugangliu.ml@outlook.com>

[clang] Add the check of membership for the issue #58674 and improve the lookup process

This patch includes the commit 01adf96ebc86 and a fix of unhandled declaration
references.

When looking up ba

[clang] Add the check of membership for the issue #58674 and improve the lookup process

This patch includes the commit 01adf96ebc86 and a fix of unhandled declaration
references.

When looking up base classes, Clang first checks whether a base class is a
template and takes the specialized template based on it. However, the base class
might be instantiated, and the above behavior can lose information.

This patch fixes the problem by first checking whether a base class is a record
declaration, so the instantiated one will be taken.

Differential Revision: https://reviews.llvm.org/D143840

show more ...


Revision tags: llvmorg-16.0.0-rc2
# d6d29dc4 29-Jan-2023 Liming Liu <gangliugangliu.ml@outlook.com>

Revert commit 01adf96ebc86 because it caused "Unhandled DeclRefExpr" errors.


Revision tags: llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7
# 01adf96e 10-Jan-2023 Liming Liu <gangliugangliu.ml@outlook.com>

[clang] Add the check of membership in decltype for the issue #58674

D137531 had once fixed the issue. However, it caused a crash during compiling
llvm/unittests/IR/PatternMatch.cpp in stage-2. The

[clang] Add the check of membership in decltype for the issue #58674

D137531 had once fixed the issue. However, it caused a crash during compiling
llvm/unittests/IR/PatternMatch.cpp in stage-2. The reason is the predicator
isDerivedFrom does not consider independent types if the derived type is
dependent.

This patch improves D137531 by adding an option to make isDerivedFrom consider
independent types.

Differential Revision: https://reviews.llvm.org/D142437

show more ...


Revision tags: llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1
# 8009d236 17-Sep-2022 Kazu Hirata <kazu@google.com>

[clang] Don't include SetVector.h (NFC)


Revision tags: llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1
# d245f2e8 17-Oct-2021 Kazu Hirata <kazu@google.com>

[clang] Use llvm::erase_if (NFC)


# 57b40b5f 12-Oct-2021 Kazu Hirata <kazu@google.com>

[AST, CodeGen, Driver] Use llvm::is_contained (NFC)


Revision tags: llvmorg-13.0.0, llvmorg-13.0.0-rc4, llvmorg-13.0.0-rc3, llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init, llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1, llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4
# 0cb7e7ca 17-Mar-2021 Vassil Vassilev <v.g.vassilev@gmail.com>

Make iteration over the DeclContext::lookup_result safe.

The idiom:
```
DeclContext::lookup_result R = DeclContext::lookup(Name);
for (auto *D : R) {...}
```

is not safe when in the loop body we tr

Make iteration over the DeclContext::lookup_result safe.

The idiom:
```
DeclContext::lookup_result R = DeclContext::lookup(Name);
for (auto *D : R) {...}
```

is not safe when in the loop body we trigger deserialization from an AST file.
The deserialization can insert new declarations in the StoredDeclsList whose
underlying type is a vector. When the vector decides to reallocate its storage
the pointer we hold becomes invalid.

This patch replaces a SmallVector with an singly-linked list. The current
approach stores a SmallVector<NamedDecl*, 4> which is around 8 pointers.
The linked list is 3, 5, or 7. We do better in terms of memory usage for small
cases (and worse in terms of locality -- the linked list entries won't be near
each other, but will be near their corresponding declarations, and we were going
to fetch those memory pages anyway). For larger cases: the vector uses a
doubling strategy for reallocation, so will generally be between half-full and
full. Let's say it's 75% full on average, so there's N * 4/3 + 4 pointers' worth
of space allocated currently and will be 2N pointers with the linked list. So we
break even when there are N=6 entries and slightly lose in terms of memory usage
after that. We suspect that's still a win on average.

Thanks to @rsmith!

Differential revision: https://reviews.llvm.org/D91524

show more ...


Revision tags: llvmorg-12.0.0-rc3, llvmorg-12.0.0-rc2, llvmorg-11.1.0, llvmorg-11.1.0-rc3, llvmorg-12.0.0-rc1, llvmorg-13-init, llvmorg-11.1.0-rc2, llvmorg-11.1.0-rc1, llvmorg-11.0.1, llvmorg-11.0.1-rc2
# 1f40d60a 02-Dec-2020 Richard Smith <richard@metafoo.co.uk>

Remove CXXBasePaths::found_decls and simplify and modernize its only
caller.

This function did not satisfy its documented contract: it only
considered the first lookup result on each base path, not

Remove CXXBasePaths::found_decls and simplify and modernize its only
caller.

This function did not satisfy its documented contract: it only
considered the first lookup result on each base path, not all lookup
results. It also performed unnecessary memory allocations.

This change results in a minor change to our representation: we now
include overridden methods that are found by any derived-to-base path
(not involving another override) in the list of overridden methods for a
function, rather than filtering out functions from bases that are both
direct virtual bases and indirect virtual bases for which the indirect
virtual base path contains another override for the function. (That
filtering rule is part of the class-scope name lookup rules, and doesn't
really have much to do with enumerating overridden methods.) The users
of the list of overridden methods do not appear to rely on this
filtering having happened, and it's simpler to not do it.

show more ...


Revision tags: llvmorg-11.0.1-rc1
# 3fb08798 25-Nov-2020 Richard Smith <richard@metafoo.co.uk>

Refactor and simplify class scope name lookup.

This is partly in preparation for an upcoming change that can change the
order in which DeclContext lookup results are presented.

In passing, fix some

Refactor and simplify class scope name lookup.

This is partly in preparation for an upcoming change that can change the
order in which DeclContext lookup results are presented.

In passing, fix some obvious errors where name lookup's notion of a
"static member function" missed static member function templates, and
where its notion of "same set of declarations" was confused by the same
declarations appearing in a different order.

show more ...


Revision tags: llvmorg-11.0.0, llvmorg-11.0.0-rc6, llvmorg-11.0.0-rc5, llvmorg-11.0.0-rc4, llvmorg-11.0.0-rc3, llvmorg-11.0.0-rc2, llvmorg-11.0.0-rc1, llvmorg-12-init, llvmorg-10.0.1, llvmorg-10.0.1-rc4, llvmorg-10.0.1-rc3, llvmorg-10.0.1-rc2, llvmorg-10.0.1-rc1, llvmorg-10.0.0, llvmorg-10.0.0-rc6, llvmorg-10.0.0-rc5, llvmorg-10.0.0-rc4, llvmorg-10.0.0-rc3
# 93184a8e 29-Feb-2020 Aaron Puchert <aaronpuchert@alice-dsl.net>

Remove unused parameter from CXXRecordDecl::forallBases [NFC]

Summary:
Apparently all users of the function were fine with short-circuiting
and none cared to override the default argument.

Reviewer

Remove unused parameter from CXXRecordDecl::forallBases [NFC]

Summary:
Apparently all users of the function were fine with short-circuiting
and none cared to override the default argument.

Reviewers: aaron.ballman, rsmith

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75319

show more ...


Revision tags: llvmorg-10.0.0-rc2
# aade5fbb 01-Feb-2020 Richard Smith <richard@metafoo.co.uk>

Fix wrong devirtualization when the final overrider in one base class
overrides the final overrider in a different base class.


Revision tags: llvmorg-10.0.0-rc1, llvmorg-11-init, llvmorg-9.0.1, llvmorg-9.0.1-rc3, llvmorg-9.0.1-rc2, llvmorg-9.0.1-rc1, llvmorg-9.0.0, llvmorg-9.0.0-rc6, llvmorg-9.0.0-rc5, llvmorg-9.0.0-rc4, llvmorg-9.0.0-rc3
# 2b3d49b6 14-Aug-2019 Jonas Devlieghere <jonas@devlieghere.com>

[Clang] Migrate llvm::make_unique to std::make_unique

Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
o

[Clang] Migrate llvm::make_unique to std::make_unique

Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

Differential revision: https://reviews.llvm.org/D66259

llvm-svn: 368942

show more ...


Revision tags: llvmorg-9.0.0-rc2, llvmorg-9.0.0-rc1, llvmorg-10-init, llvmorg-8.0.1, llvmorg-8.0.1-rc4, llvmorg-8.0.1-rc3, llvmorg-8.0.1-rc2, llvmorg-8.0.1-rc1
# 75e74e07 31-Mar-2019 Fangrui Song <maskray@google.com>

Range-style std::find{,_if} -> llvm::find{,_if}. NFC

llvm-svn: 357359


Revision tags: llvmorg-8.0.0, llvmorg-8.0.0-rc5, llvmorg-8.0.0-rc4, llvmorg-8.0.0-rc3, llvmorg-7.1.0, llvmorg-7.1.0-rc1, llvmorg-8.0.0-rc2
# 251e1488 01-Feb-2019 Michael Kruse <llvm@meinersbur.de>

[OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.

This patch implements parsing and sema for "omp declare mapper"
directive. User defined mapper, i.e., declare mapper directive,

[OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.

This patch implements parsing and sema for "omp declare mapper"
directive. User defined mapper, i.e., declare mapper directive, is a new
feature in OpenMP 5.0. It is introduced to extend existing map clauses
for the purpose of simplifying the copy of complex data structures
between host and device (i.e., deep copy). An example is shown below:

struct S { int len; int *d; };
#pragma omp declare mapper(struct S s) map(s, s.d[0:s.len]) // Memory region that d points to is also mapped using this mapper.

Contributed-by: Lingda Li <lildmh@gmail.com>

Differential Revision: https://reviews.llvm.org/D56326

llvm-svn: 352906

show more ...


Revision tags: llvmorg-8.0.0-rc1
# 2946cd70 19-Jan-2019 Chandler Carruth <chandlerc@gmail.com>

Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the ne

Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636

show more ...


# 21636ab8 21-Dec-2018 Bruno Ricci <riccibrun@gmail.com>

[AST][NFC] Remove stale comment in CXXRecordDecl::is(Virtually)DerivedFrom.

The "this" capture was removed in r291939.

llvm-svn: 349948


Revision tags: llvmorg-7.0.1, llvmorg-7.0.1-rc3, llvmorg-7.0.1-rc2, llvmorg-7.0.1-rc1, llvmorg-7.0.0, llvmorg-7.0.0-rc3, llvmorg-7.0.0-rc2, llvmorg-7.0.0-rc1
# 6907ce2f 30-Jul-2018 Fangrui Song <maskray@google.com>

Remove trailing space

sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}

llvm-svn: 338291


# 1b2bc604 20-Jul-2018 Benjamin Kramer <benny.kra@googlemail.com>

[AST] Various micro-optimizations in CXXInheritance

1. Pack std::pair<bool, unsigned> in CXXBasePaths::ClassSubobjects.
2. Use a SmallPtrSet instead of a SmallDenseSet for CXXBasePaths::VisitedDepen

[AST] Various micro-optimizations in CXXInheritance

1. Pack std::pair<bool, unsigned> in CXXBasePaths::ClassSubobjects.
2. Use a SmallPtrSet instead of a SmallDenseSet for CXXBasePaths::VisitedDependentRecords.
3. Reorder some members of CXXBasePaths to save 8 bytes.
4. Use a SmallSetVector instead of a SetVector in CXXBasePaths::ComputeDeclsFound to avoid some allocations.

This speeds up an -fsyntax-only on all of Boost by approx 0.15%,
mainly by speeding up CXXBasePaths::lookupInBases by
approx 10%. No functional changes.

Patch by Bruno Ricci!

Differential Revision: https://reviews.llvm.org/D49302

llvm-svn: 337607

show more ...


1234