llvm-project/clang/unittests
Gabor Marton e3e83d708a [ASTImporter] Do not look up lambda classes
Summary:
Consider this code:
```
      void f() {
        auto L0 = [](){};
        auto L1 = [](){};
      }

```
First we import `L0` then `L1`. Currently we end up having only one
CXXRecordDecl for the two different lambdas. And that is a problem if
the body of their op() is different. This happens because when we import
`L1` then lookup finds the existing `L0` and since they are structurally
equivalent we just map the imported L0 to be the counterpart of L1.

We have the same problem in this case:
```
      template <typename F0, typename F1>
      void f(F0 L0 = [](){}, F1 L1 = [](){}) {}

```

In StructuralEquivalenceContext we could distinquish lambdas only by
their source location in these cases. But we the lambdas are actually
structrually equivalent they differn only by the source location.

Thus, the  solution is to disable lookup completely if the decl in
the "from" context is a lambda.
However, that could have other problems: what if the lambda is defined
in a header file and included in several TUs? I think we'd have as many
duplicates as many includes we have. I think we could live with that,
because the lambda classes are TU local anyway, we cannot just access
them from another TU.

Reviewers: a_sidorin, a.sidorin, shafik

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

llvm-svn: 370461
2019-08-30 10:55:41 +00:00
..
AST [ASTImporter] Do not look up lambda classes 2019-08-30 10:55:41 +00:00
ASTMatchers Fix the nullPointerConstant() test to get bots back to green. 2019-08-22 18:56:18 +00:00
Analysis [CFG] Introduce CFGElementRef, a wrapper that knows it's position in a CFGBlock 2019-08-14 17:05:55 +00:00
Basic [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
CodeGen Added 'inline' to functions defined in headers to avoid ODR violations 2019-08-29 16:58:13 +00:00
CrossTU [Tooling] Migrated APIs that take ownership of objects to unique_ptr 2019-08-30 09:29:34 +00:00
DirectoryWatcher Use ASSERT_THAT_ERROR instead of logAllUnhandledErrors/exit 2019-08-09 06:14:54 +00:00
Driver cmake: Add CLANG_LINK_CLANG_DYLIB option 2019-07-03 22:45:55 +00:00
Format clang-format: [JS] handle `as const`. 2019-08-26 15:37:05 +00:00
Frontend [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
Index [Tooling] Migrated APIs that take ownership of objects to unique_ptr 2019-08-30 09:29:34 +00:00
Lex [Clang] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:04:18 +00:00
Rename cmake: Add CLANG_LINK_CLANG_DYLIB option 2019-07-03 22:45:55 +00:00
Rewrite [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug 2019-08-15 21:17:48 +00:00
Sema [Tooling] Migrated APIs that take ownership of objects to unique_ptr 2019-08-30 09:29:34 +00:00
Serialization cmake: Add CLANG_LINK_CLANG_DYLIB option 2019-07-03 22:45:55 +00:00
StaticAnalyzer [Tooling] Migrated APIs that take ownership of objects to unique_ptr 2019-08-30 09:29:34 +00:00
Tooling [Tooling] Migrated APIs that take ownership of objects to unique_ptr 2019-08-30 09:29:34 +00:00
libclang Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt Reland [clang] DirectoryWatcher 2019-07-12 20:34:10 +00:00