
The import and include problem is a long-standing issue with the use of C++20 modules. This patch tried to improve this by skipping parsing class and functions if their declaration is already defined in modules. The scale of the patch itself is small as the patch reuses previous optimization. Maybe we can skip parsing other declarations in the future. But the patch itself should be good.
59 lines
992 B
C++
59 lines
992 B
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
|
|
// RUN: %clang_cc1 -std=c++20 %t/a.cpp -fmodule-file=a=%t/a.pcm -ast-dump | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
|
|
// RUN: %clang_cc1 -std=c++20 %t/a.cpp -fmodule-file=a=%t/a.pcm -ast-dump | FileCheck %s
|
|
|
|
//--- a.h
|
|
namespace a {
|
|
class A {
|
|
public:
|
|
int aaaa;
|
|
|
|
int get() {
|
|
return aaaa;
|
|
}
|
|
};
|
|
|
|
|
|
template <class T>
|
|
class B {
|
|
public:
|
|
B(T t): t(t) {}
|
|
T t;
|
|
};
|
|
|
|
using BI = B<int>;
|
|
|
|
inline int get(A a, BI b) {
|
|
return a.get() + b.t;
|
|
}
|
|
|
|
}
|
|
|
|
//--- a.cppm
|
|
export module a;
|
|
|
|
export extern "C++" {
|
|
#include "a.h"
|
|
}
|
|
|
|
//--- a.cpp
|
|
import a;
|
|
#include "a.h"
|
|
|
|
int test() {
|
|
a::A aa;
|
|
a::BI bb(43);
|
|
return get(aa, bb);
|
|
}
|
|
|
|
// CHECK-NOT: DefinitionData
|
|
// CHECK: FunctionDecl {{.*}} get 'int (A, BI)' {{.*}}
|
|
// CHECK-NOT: CompoundStmt
|
|
// CHECK: FunctionDecl {{.*}} test {{.*}}
|