2010-10-09 03:36:36 +08:00
|
|
|
// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/class1.cpp
|
|
|
|
// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/class2.cpp
|
|
|
|
// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
|
2013-07-13 06:30:03 +08:00
|
|
|
// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 -Wno-odr -Werror
|
2010-06-04 03:28:45 +08:00
|
|
|
|
2016-02-19 07:08:36 +08:00
|
|
|
// CHECK: class1.cpp:6:8: warning: type 'B' has incompatible definitions in different translation units
|
|
|
|
// CHECK: class1.cpp:7:9: note: field 'y' has type 'float' here
|
|
|
|
// CHECK: class2.cpp:7:7: note: field 'y' has type 'int' here
|
2010-06-04 03:28:45 +08:00
|
|
|
|
|
|
|
// FIXME: we should also complain about mismatched types on the method
|
2012-12-20 10:22:15 +08:00
|
|
|
|
2016-02-19 07:08:36 +08:00
|
|
|
// CHECK: class1.cpp:18:6: warning: type 'E' has incompatible definitions in different translation units
|
|
|
|
// CHECK: class1.cpp:19:3: note: enumerator 'b' with value 1 here
|
|
|
|
// CHECK: class2.cpp:12:3: note: enumerator 'a' with value 0 here
|
2018-04-26 01:28:03 +08:00
|
|
|
|
2018-06-26 00:25:30 +08:00
|
|
|
// CHECK: class1.cpp:43:8: warning: type 'F3' has incompatible definitions in different translation units
|
|
|
|
// CHECK: class1.cpp:46:3: note: friend declared here
|
|
|
|
// CHECK: class2.cpp:36:8: note: no corresponding friend here
|
|
|
|
|
Re-apply: [ASTImporter] Import the whole redecl chain of functions
Summary:
With this patch when any `FunctionDecl` of a redeclaration chain is imported
then we bring in the whole declaration chain. This involves functions and
function template specializations. Also friend functions are affected. The
chain is imported as it is in the "from" tu, the order of the redeclarations
are kept. I also changed the lookup logic in order to find friends, but first
making them visible in their declaration context. We may have long
redeclaration chains if all TU contains the same prototype, but our
measurements shows no degradation in time of CTU analysis (Tmux, Xerces,
Bitcoin, Protobuf). Also, as further work we could squash redundant
prototypes, but first ensure that functionality is working properly; then
should we optimize.
This may seem like a huge patch, sorry about that. But, most of the changes are
new tests, changes in the production code is not that much. I also tried to
create a smaller patch which does not affect specializations, but that patch
failed to pass some of the `clang-import-test`s because there we import
function specializations. Also very importantly, we can't just change the
import of `FunctionDecl`s without changing the import of function template
specializations because they are handled as `FunctionDecl`s.
Reviewers: a.sidorin, r.stahl, xazax.hun, balazske, a_sidorin
Reviewed By: a_sidorin
Subscribers: labath, aprantl, a_sidorin, rnkovacs, dkrupp, cfe-commits
Differential Revision: https://reviews.llvm.org/D47532
Re-apply commit rC335480
llvm-svn: 335731
2018-06-27 21:32:50 +08:00
|
|
|
// CHECK: class1.cpp:36:8: warning: type 'F2' has incompatible definitions in different translation units
|
|
|
|
// CHECK: class1.cpp:39:3: note: friend declared here
|
|
|
|
// CHECK: class2.cpp:30:8: note: no corresponding friend here
|
|
|
|
|
2018-04-26 01:28:03 +08:00
|
|
|
// CHECK: 4 warnings generated.
|