r339505 - [ASTImporter] Added test case for CXXConversionDecl importing
Author: teemperor Date: Sat Aug 11 16:43:02 2018 New Revision: 339505 URL: http://llvm.org/viewvc/llvm-project?rev=339505&view=rev Log: [ASTImporter] Added test case for CXXConversionDecl importing Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50552 Added: cfe/trunk/test/Import/conversion-decl/ cfe/trunk/test/Import/conversion-decl/Inputs/ cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp cfe/trunk/test/Import/conversion-decl/test.cpp Added: cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp?rev=339505&view=auto == --- cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp Sat Aug 11 16:43:02 2018 @@ -0,0 +1,10 @@ +class Y { + int M; +}; + +class X { + int N, M; + +public: + operator Y(); +}; Added: cfe/trunk/test/Import/conversion-decl/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/conversion-decl/test.cpp?rev=339505&view=auto == --- cfe/trunk/test/Import/conversion-decl/test.cpp (added) +++ cfe/trunk/test/Import/conversion-decl/test.cpp Sat Aug 11 16:43:02 2018 @@ -0,0 +1,5 @@ +// RUN: clang-import-test -import %S/Inputs/F.cpp -expression %s +void expr() { + X X1; + Y Y1 = X1; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339506 - [ASTImporter] Added test case for opaque enums
Author: teemperor Date: Sat Aug 11 16:43:46 2018 New Revision: 339506 URL: http://llvm.org/viewvc/llvm-project?rev=339506&view=rev Log: [ASTImporter] Added test case for opaque enums Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50550 Modified: cfe/trunk/test/Import/enum/Inputs/S.cpp cfe/trunk/test/Import/enum/test.cpp Modified: cfe/trunk/test/Import/enum/Inputs/S.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/enum/Inputs/S.cpp?rev=339506&r1=339505&r2=339506&view=diff == --- cfe/trunk/test/Import/enum/Inputs/S.cpp (original) +++ cfe/trunk/test/Import/enum/Inputs/S.cpp Sat Aug 11 16:43:46 2018 @@ -2,3 +2,5 @@ enum E { a = 1, b = 2 }; + +enum OpaqueWithType : long; Modified: cfe/trunk/test/Import/enum/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/enum/test.cpp?rev=339506&r1=339505&r2=339506&view=diff == --- cfe/trunk/test/Import/enum/test.cpp (original) +++ cfe/trunk/test/Import/enum/test.cpp Sat Aug 11 16:43:46 2018 @@ -1,4 +1,8 @@ -// RUN: clang-import-test -import %S/Inputs/S.cpp -expression %s +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s + +// CHECK: OpaqueWithType 'long' + void expr() { static_assert(E::a + E::b == 3); + static_assert(sizeof(OpaqueWithType) == sizeof(long)); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339827 - [ASTImporter] Add test for IfStmt
Author: teemperor Date: Wed Aug 15 15:36:58 2018 New Revision: 339827 URL: http://llvm.org/viewvc/llvm-project?rev=339827&view=rev Log: [ASTImporter] Add test for IfStmt Reviewers: a.sidorin, hiraditya Reviewed By: hiraditya Subscribers: hiraditya, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50796 Added: cfe/trunk/test/Import/if-stmt/ cfe/trunk/test/Import/if-stmt/Inputs/ cfe/trunk/test/Import/if-stmt/Inputs/F.cpp cfe/trunk/test/Import/if-stmt/test.cpp Added: cfe/trunk/test/Import/if-stmt/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/if-stmt/Inputs/F.cpp?rev=339827&view=auto == --- cfe/trunk/test/Import/if-stmt/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/if-stmt/Inputs/F.cpp Wed Aug 15 15:36:58 2018 @@ -0,0 +1,21 @@ +void f() { + if (true) +return; + + if (int j = 3) +return; + + if (int j; true) +return; + + if (true) +return; + else +return; + + if (true) { +return; + } else { +return; + } +} Added: cfe/trunk/test/Import/if-stmt/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/if-stmt/test.cpp?rev=339827&view=auto == --- cfe/trunk/test/Import/if-stmt/test.cpp (added) +++ cfe/trunk/test/Import/if-stmt/test.cpp Wed Aug 15 15:36:58 2018 @@ -0,0 +1,47 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: IfStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: <> + +// CHECK: IfStmt +// CHECK-NEXT: <> +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: <> + +// CHECK: IfStmt +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: <> + +// CHECK: IfStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: ReturnStmt + +// CHECK: IfStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ReturnStmt + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339830 - [ASTImporter] Add test for ExprWithCleanups
Author: teemperor Date: Wed Aug 15 15:51:37 2018 New Revision: 339830 URL: http://llvm.org/viewvc/llvm-project?rev=339830&view=rev Log: [ASTImporter] Add test for ExprWithCleanups Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50731 Added: cfe/trunk/test/Import/expr-with-cleanups/ cfe/trunk/test/Import/expr-with-cleanups/Inputs/ cfe/trunk/test/Import/expr-with-cleanups/Inputs/S.cpp cfe/trunk/test/Import/expr-with-cleanups/test.cpp Added: cfe/trunk/test/Import/expr-with-cleanups/Inputs/S.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/expr-with-cleanups/Inputs/S.cpp?rev=339830&view=auto == --- cfe/trunk/test/Import/expr-with-cleanups/Inputs/S.cpp (added) +++ cfe/trunk/test/Import/expr-with-cleanups/Inputs/S.cpp Wed Aug 15 15:51:37 2018 @@ -0,0 +1,8 @@ +struct RAII { + int i = 0; + RAII() { i++; } + ~RAII() { i--; } +}; +void f() { + RAII(); +} Added: cfe/trunk/test/Import/expr-with-cleanups/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/expr-with-cleanups/test.cpp?rev=339830&view=auto == --- cfe/trunk/test/Import/expr-with-cleanups/test.cpp (added) +++ cfe/trunk/test/Import/expr-with-cleanups/test.cpp Wed Aug 15 15:51:37 2018 @@ -0,0 +1,8 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s +// CHECK: ExprWithCleanups +// CHECK-SAME: 'RAII' +// CHECK-NEXT: CXXBindTemporaryExpr + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339831 - [ASTImporter] Add test for ArrayInitLoopExpr
Author: teemperor Date: Wed Aug 15 15:52:21 2018 New Revision: 339831 URL: http://llvm.org/viewvc/llvm-project?rev=339831&view=rev Log: [ASTImporter] Add test for ArrayInitLoopExpr Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50733 Added: cfe/trunk/test/Import/array-init-loop-expr/ cfe/trunk/test/Import/array-init-loop-expr/Inputs/ cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp cfe/trunk/test/Import/array-init-loop-expr/test.cpp Added: cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp?rev=339831&view=auto == --- cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp (added) +++ cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp Wed Aug 15 15:52:21 2018 @@ -0,0 +1,3 @@ +class S { + int a[10]; +}; Added: cfe/trunk/test/Import/array-init-loop-expr/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/array-init-loop-expr/test.cpp?rev=339831&view=auto == --- cfe/trunk/test/Import/array-init-loop-expr/test.cpp (added) +++ cfe/trunk/test/Import/array-init-loop-expr/test.cpp Wed Aug 15 15:52:21 2018 @@ -0,0 +1,11 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s +// CHECK: CXXCtorInitializer +// CHECK-NEXT: ArrayInitLoopExpr +// CHECK-SAME: 'int [10]' + +// CHECK: ArrayInitIndexExpr + +void expr() { + S s; + S copy = s; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339837 - [ASTImporter] Add test for ForStmt and ContinueStmt
Author: teemperor Date: Wed Aug 15 18:35:47 2018 New Revision: 339837 URL: http://llvm.org/viewvc/llvm-project?rev=339837&view=rev Log: [ASTImporter] Add test for ForStmt and ContinueStmt Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50812 Added: cfe/trunk/test/Import/for-stmt/ cfe/trunk/test/Import/for-stmt/Inputs/ cfe/trunk/test/Import/for-stmt/Inputs/F.cpp cfe/trunk/test/Import/for-stmt/test.cpp Added: cfe/trunk/test/Import/for-stmt/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/for-stmt/Inputs/F.cpp?rev=339837&view=auto == --- cfe/trunk/test/Import/for-stmt/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/for-stmt/Inputs/F.cpp Wed Aug 15 18:35:47 2018 @@ -0,0 +1,9 @@ +void f() { + for (;;) +; + for (int i = 0;;) +continue; + for (int i = 0; i != 0; ++i) { +i++; + } +} Added: cfe/trunk/test/Import/for-stmt/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/for-stmt/test.cpp?rev=339837&view=auto == --- cfe/trunk/test/Import/for-stmt/test.cpp (added) +++ cfe/trunk/test/Import/for-stmt/test.cpp Wed Aug 15 18:35:47 2018 @@ -0,0 +1,38 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: ForStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: NullStmt + +// CHECK: ForStmt +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: ContinueStmt + +// CHECK: ForStmt +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: <> + +// CHECK-NEXT: BinaryOperator +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-NEXT: IntegerLiteral + +// CHECK-NEXT: UnaryOperator +// CHECK-SAME: '++' +// CHECK-NEXT: DeclRefExpr + +// CHECK-NEXT: CompoundStmt + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339838 - [ASTImporter] Add test for CXXScalarValueInit
Author: teemperor Date: Wed Aug 15 18:36:37 2018 New Revision: 339838 URL: http://llvm.org/viewvc/llvm-project?rev=339838&view=rev Log: [ASTImporter] Add test for CXXScalarValueInit Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50735 Added: cfe/trunk/test/Import/cxx-scalar-value-init/ cfe/trunk/test/Import/cxx-scalar-value-init/Inputs/ cfe/trunk/test/Import/cxx-scalar-value-init/Inputs/S.cpp cfe/trunk/test/Import/cxx-scalar-value-init/test.cpp Added: cfe/trunk/test/Import/cxx-scalar-value-init/Inputs/S.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-scalar-value-init/Inputs/S.cpp?rev=339838&view=auto == --- cfe/trunk/test/Import/cxx-scalar-value-init/Inputs/S.cpp (added) +++ cfe/trunk/test/Import/cxx-scalar-value-init/Inputs/S.cpp Wed Aug 15 18:36:37 2018 @@ -0,0 +1,2 @@ +int si() { return int(); } +float sf() { return float(); } Added: cfe/trunk/test/Import/cxx-scalar-value-init/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-scalar-value-init/test.cpp?rev=339838&view=auto == --- cfe/trunk/test/Import/cxx-scalar-value-init/test.cpp (added) +++ cfe/trunk/test/Import/cxx-scalar-value-init/test.cpp Wed Aug 15 18:36:37 2018 @@ -0,0 +1,11 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s +// CHECK: CXXScalarValueInitExpr +// CHECK-SAME: 'int' + +// CHECK: CXXScalarValueInitExpr +// CHECK-SAME: 'float' + +void expr() { + int i = si(); + float f = sf(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339839 - [ASTImporter] Add test for CXXDefaultInitExpr
Author: teemperor Date: Wed Aug 15 18:37:43 2018 New Revision: 339839 URL: http://llvm.org/viewvc/llvm-project?rev=339839&view=rev Log: [ASTImporter] Add test for CXXDefaultInitExpr Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50732 Added: cfe/trunk/test/Import/cxx-default-init-expr/ cfe/trunk/test/Import/cxx-default-init-expr/Inputs/ cfe/trunk/test/Import/cxx-default-init-expr/Inputs/S.cpp cfe/trunk/test/Import/cxx-default-init-expr/test.cpp Added: cfe/trunk/test/Import/cxx-default-init-expr/Inputs/S.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-default-init-expr/Inputs/S.cpp?rev=339839&view=auto == --- cfe/trunk/test/Import/cxx-default-init-expr/Inputs/S.cpp (added) +++ cfe/trunk/test/Import/cxx-default-init-expr/Inputs/S.cpp Wed Aug 15 18:37:43 2018 @@ -0,0 +1,9 @@ +struct Foo { + int i; +}; + +struct S { + int int_member = 3; + float float_member = 3.0f; + Foo class_member = Foo(); +}; Added: cfe/trunk/test/Import/cxx-default-init-expr/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-default-init-expr/test.cpp?rev=339839&view=auto == --- cfe/trunk/test/Import/cxx-default-init-expr/test.cpp (added) +++ cfe/trunk/test/Import/cxx-default-init-expr/test.cpp Wed Aug 15 18:37:43 2018 @@ -0,0 +1,22 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s +// CHECK: CXXCtorInitializer +// CHECK-SAME: 'int_member' +// CHECK-SAME: 'int' +// CHECK-NEXT: CXXDefaultInitExpr +// CHECK-SAME: 'int' + +// CHECK-NEXT: CXXCtorInitializer +// CHECK-SAME: 'float_member' +// CHECK-SAME: 'float' +// CHECK-NEXT: CXXDefaultInitExpr +// CHECK-SAME: 'float' + +// CHECK-NEXT: CXXCtorInitializer +// CHECK-SAME: 'class_member' +// CHECK-SAME: 'Foo' +// CHECK-NEXT: CXXDefaultInitExpr +// CHECK-SAME: 'Foo' + +void expr() { + struct S s; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339915 - [ASTImporter] Add test for IndirectGotoStmt
Author: teemperor Date: Thu Aug 16 11:19:21 2018 New Revision: 339915 URL: http://llvm.org/viewvc/llvm-project?rev=339915&view=rev Log: [ASTImporter] Add test for IndirectGotoStmt Reviewers: a.sidorin, martong Reviewed By: martong Subscribers: rnkovacs, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50813 Added: cfe/trunk/test/Import/indirect-goto/ cfe/trunk/test/Import/indirect-goto/Inputs/ cfe/trunk/test/Import/indirect-goto/Inputs/F.cpp cfe/trunk/test/Import/indirect-goto/test.cpp Added: cfe/trunk/test/Import/indirect-goto/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/indirect-goto/Inputs/F.cpp?rev=339915&view=auto == --- cfe/trunk/test/Import/indirect-goto/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/indirect-goto/Inputs/F.cpp Thu Aug 16 11:19:21 2018 @@ -0,0 +1,6 @@ +void f() { + void const *l1_ptr = &&l1; + goto *l1_ptr; +l1: + return; +} Added: cfe/trunk/test/Import/indirect-goto/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/indirect-goto/test.cpp?rev=339915&view=auto == --- cfe/trunk/test/Import/indirect-goto/test.cpp (added) +++ cfe/trunk/test/Import/indirect-goto/test.cpp Thu Aug 16 11:19:21 2018 @@ -0,0 +1,10 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: IndirectGotoStmt +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: 'l1_ptr' + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339916 - [ASTImporter] Add test for WhileStmt
Author: teemperor Date: Thu Aug 16 11:20:05 2018 New Revision: 339916 URL: http://llvm.org/viewvc/llvm-project?rev=339916&view=rev Log: [ASTImporter] Add test for WhileStmt Reviewers: a.sidorin, martong Reviewed By: martong Subscribers: rnkovacs, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50811 Added: cfe/trunk/test/Import/while-stmt/ cfe/trunk/test/Import/while-stmt/Inputs/ cfe/trunk/test/Import/while-stmt/Inputs/F.cpp cfe/trunk/test/Import/while-stmt/test.cpp Added: cfe/trunk/test/Import/while-stmt/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/while-stmt/Inputs/F.cpp?rev=339916&view=auto == --- cfe/trunk/test/Import/while-stmt/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/while-stmt/Inputs/F.cpp Thu Aug 16 11:20:05 2018 @@ -0,0 +1,8 @@ +void f() { + while (false) +; + while (false) { + } + while (bool ini = true) +; +} Added: cfe/trunk/test/Import/while-stmt/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/while-stmt/test.cpp?rev=339916&view=auto == --- cfe/trunk/test/Import/while-stmt/test.cpp (added) +++ cfe/trunk/test/Import/while-stmt/test.cpp Thu Aug 16 11:20:05 2018 @@ -0,0 +1,23 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: WhileStmt +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: NullStmt + +// CHECK: WhileStmt +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: CompoundStmt + +// CHECK: WhileStmt +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-NEXT: NullStmt + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339917 - [ASTImporter] Add test for DoStmt
Author: teemperor Date: Thu Aug 16 11:20:52 2018 New Revision: 339917 URL: http://llvm.org/viewvc/llvm-project?rev=339917&view=rev Log: [ASTImporter] Add test for DoStmt Reviewers: a.sidorin, martong Reviewed By: martong Subscribers: rnkovacs, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50810 Added: cfe/trunk/test/Import/do-stmt/ cfe/trunk/test/Import/do-stmt/Inputs/ cfe/trunk/test/Import/do-stmt/Inputs/F.cpp cfe/trunk/test/Import/do-stmt/test.cpp Added: cfe/trunk/test/Import/do-stmt/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/do-stmt/Inputs/F.cpp?rev=339917&view=auto == --- cfe/trunk/test/Import/do-stmt/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/do-stmt/Inputs/F.cpp Thu Aug 16 11:20:52 2018 @@ -0,0 +1,7 @@ +void f() { + do +; + while (true); + do { + } while (false); +} Added: cfe/trunk/test/Import/do-stmt/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/do-stmt/test.cpp?rev=339917&view=auto == --- cfe/trunk/test/Import/do-stmt/test.cpp (added) +++ cfe/trunk/test/Import/do-stmt/test.cpp Thu Aug 16 11:20:52 2018 @@ -0,0 +1,15 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: DoStmt +// CHECK-NEXT: NullStmt +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-SAME: true + +// CHECK: DoStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-SAME: false + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339918 - [ASTImporter] Add test for importing CompoundAssignOperators
Author: teemperor Date: Thu Aug 16 11:21:33 2018 New Revision: 339918 URL: http://llvm.org/viewvc/llvm-project?rev=339918&view=rev Log: [ASTImporter] Add test for importing CompoundAssignOperators Reviewers: a.sidorin, martong Reviewed By: martong Subscribers: rnkovacs, cfe-commits, martong Differential Revision: https://reviews.llvm.org/D50793 Added: cfe/trunk/test/Import/compound-assign-op/ cfe/trunk/test/Import/compound-assign-op/Inputs/ cfe/trunk/test/Import/compound-assign-op/Inputs/F.cpp cfe/trunk/test/Import/compound-assign-op/test.cpp Added: cfe/trunk/test/Import/compound-assign-op/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/compound-assign-op/Inputs/F.cpp?rev=339918&view=auto == --- cfe/trunk/test/Import/compound-assign-op/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/compound-assign-op/Inputs/F.cpp Thu Aug 16 11:21:33 2018 @@ -0,0 +1,18 @@ +void f() { + unsigned iadd_eq = 0U; + iadd_eq += 1U; + unsigned isub_eq = 0U; + isub_eq -= 1U; + unsigned imul_eq = 0U; + imul_eq *= 1U; + unsigned idiv_eq = 0U; + idiv_eq /= 1U; + unsigned iand_eq = 0U; + iand_eq &= 1U; + unsigned ixor_eq = 0U; + ixor_eq ^= 1U; + unsigned ilsh_eq = 0U; + ilsh_eq <<= 1U; + unsigned irsh_eq = 0U; + irsh_eq >>= 1U; +} Added: cfe/trunk/test/Import/compound-assign-op/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/compound-assign-op/test.cpp?rev=339918&view=auto == --- cfe/trunk/test/Import/compound-assign-op/test.cpp (added) +++ cfe/trunk/test/Import/compound-assign-op/test.cpp Thu Aug 16 11:21:33 2018 @@ -0,0 +1,45 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: VarDecl +// CHECK-NEXT: Integer +// CHECK-NEXT: CompoundAssignOperator +// CHECK-SAME: '+=' + +// CHECK: VarDecl +// CHECK-NEXT: Integer +// CHECK-NEXT: CompoundAssignOperator +// CHECK-SAME: '-=' + +// CHECK: VarDecl +// CHECK-NEXT: Integer +// CHECK-NEXT: CompoundAssignOperator +// CHECK-SAME: '*=' + +// CHECK: VarDecl +// CHECK-NEXT: Integer +// CHECK-NEXT: CompoundAssignOperator +// CHECK-SAME: '/=' + +// CHECK: VarDecl +// CHECK-NEXT: Integer +// CHECK-NEXT: CompoundAssignOperator +// CHECK-SAME: '&=' + +// CHECK: VarDecl +// CHECK-NEXT: Integer +// CHECK-NEXT: CompoundAssignOperator +// CHECK-SAME: '^=' + +// CHECK: VarDecl +// CHECK-NEXT: Integer +// CHECK-NEXT: CompoundAssignOperator +// CHECK-SAME: '<<=' + +// CHECK: VarDecl +// CHECK-NEXT: Integer +// CHECK-NEXT: CompoundAssignOperator +// CHECK-SAME: '>>=' + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339919 - [ASTImporter] Add test for member pointer types.
Author: teemperor Date: Thu Aug 16 11:22:21 2018 New Revision: 339919 URL: http://llvm.org/viewvc/llvm-project?rev=339919&view=rev Log: [ASTImporter] Add test for member pointer types. Reviewers: a.sidorin, martong Reviewed By: martong Subscribers: rnkovacs, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50792 Added: cfe/trunk/test/Import/cxx-member-pointers/ cfe/trunk/test/Import/cxx-member-pointers/Inputs/ cfe/trunk/test/Import/cxx-member-pointers/Inputs/S.cpp cfe/trunk/test/Import/cxx-member-pointers/test.cpp Added: cfe/trunk/test/Import/cxx-member-pointers/Inputs/S.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-member-pointers/Inputs/S.cpp?rev=339919&view=auto == --- cfe/trunk/test/Import/cxx-member-pointers/Inputs/S.cpp (added) +++ cfe/trunk/test/Import/cxx-member-pointers/Inputs/S.cpp Thu Aug 16 11:22:21 2018 @@ -0,0 +1,7 @@ +struct S { + int i; +}; + +int S::*iptr() { + return &S::i; +} Added: cfe/trunk/test/Import/cxx-member-pointers/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-member-pointers/test.cpp?rev=339919&view=auto == --- cfe/trunk/test/Import/cxx-member-pointers/test.cpp (added) +++ cfe/trunk/test/Import/cxx-member-pointers/test.cpp Thu Aug 16 11:22:21 2018 @@ -0,0 +1,16 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s + +// CHECK: VarDecl +// CHECK-SAME: int S::* +// CHECK-NEXT: CallExpr +// CHECK-NEXT: ImplicitCastExpr +// CHECK-SAME: int S::*(*)() +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: int S::*() + +void expr() { + int S::*p = iptr(); + S s; + s.i = 3; + int i = s.*p; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340180 - [ASTImporter] Test for importing condition variable from a ForStmt
Author: teemperor Date: Mon Aug 20 08:51:41 2018 New Revision: 340180 URL: http://llvm.org/viewvc/llvm-project?rev=340180&view=rev Log: [ASTImporter] Test for importing condition variable from a ForStmt Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: cfe-commits, martong Differential Revision: https://reviews.llvm.org/D50928 Modified: cfe/trunk/test/Import/for-stmt/Inputs/F.cpp cfe/trunk/test/Import/for-stmt/test.cpp Modified: cfe/trunk/test/Import/for-stmt/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/for-stmt/Inputs/F.cpp?rev=340180&r1=340179&r2=340180&view=diff == --- cfe/trunk/test/Import/for-stmt/Inputs/F.cpp (original) +++ cfe/trunk/test/Import/for-stmt/Inputs/F.cpp Mon Aug 20 08:51:41 2018 @@ -3,6 +3,8 @@ void f() { ; for (int i = 0;;) continue; + for (; bool j = false;) +continue; for (int i = 0; i != 0; ++i) { i++; } Modified: cfe/trunk/test/Import/for-stmt/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/for-stmt/test.cpp?rev=340180&r1=340179&r2=340180&view=diff == --- cfe/trunk/test/Import/for-stmt/test.cpp (original) +++ cfe/trunk/test/Import/for-stmt/test.cpp Mon Aug 20 08:51:41 2018 @@ -17,6 +17,18 @@ // CHECK-NEXT: ContinueStmt // CHECK: ForStmt +// CHECK-NEXT: <> +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: 'j' +// CHECK-SAME: 'bool' +// CHECK-NEXT: <> +// CHECK-NEXT: ContinueStmt + +// CHECK: ForStmt // CHECK-NEXT: DeclStmt // CHECK-NEXT: VarDecl // CHECK-NEXT: IntegerLiteral ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340182 - [ASTImporter] Add test for C++ casts and fix broken const_cast importing.
Author: teemperor Date: Mon Aug 20 09:20:01 2018 New Revision: 340182 URL: http://llvm.org/viewvc/llvm-project?rev=340182&view=rev Log: [ASTImporter] Add test for C++ casts and fix broken const_cast importing. Summary: The ASTImporter does currently not handle const_casts. This patch adds the missing const_cast importer code and the test case that discovered this. Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50932 Added: cfe/trunk/test/Import/cxx-casts/ cfe/trunk/test/Import/cxx-casts/Inputs/ cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp cfe/trunk/test/Import/cxx-casts/test.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/tools/clang-import-test/clang-import-test.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=340182&r1=340181&r2=340182&view=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Aug 20 09:20:01 2018 @@ -6897,6 +6897,10 @@ Expr *ASTNodeImporter::VisitCXXNamedCast return CXXReinterpretCastExpr::Create( Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath, ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets); + } else if (isa(E)) { +return CXXConstCastExpr::Create(Importer.getToContext(), ToType, VK, ToOp, +ToWritten, ToOperatorLoc, ToRParenLoc, +ToAngleBrackets); } else { return nullptr; } Added: cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp?rev=340182&view=auto == --- cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp Mon Aug 20 09:20:01 2018 @@ -0,0 +1,12 @@ +struct A { + virtual ~A() {} +}; +struct B : public A {}; + +void f() { + const A *b = new B(); + const B *c1 = dynamic_cast(b); + const B *c2 = static_cast(b); + const B *c3 = reinterpret_cast(b); + A *c4 = const_cast(b); +} Added: cfe/trunk/test/Import/cxx-casts/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-casts/test.cpp?rev=340182&view=auto == --- cfe/trunk/test/Import/cxx-casts/test.cpp (added) +++ cfe/trunk/test/Import/cxx-casts/test.cpp Mon Aug 20 09:20:01 2018 @@ -0,0 +1,21 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: CXXDynamicCastExpr +// CHECK-SAME: dynamic_cast +// CHECK-SAME: + +// CHECK: CXXStaticCastExpr +// CHECK-SAME: static_cast +// CHECK-SAME: + +// CHECK: CXXReinterpretCastExpr +// CHECK-SAME: reinterpret_cast +// CHECK-SAME: + +// CHECK: CXXConstCastExpr +// CHECK-SAME: const_cast +// CHECK-SAME: + +void expr() { + f(); +} Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=340182&r1=340181&r2=340182&view=diff == --- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original) +++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Mon Aug 20 09:20:01 2018 @@ -194,6 +194,8 @@ std::unique_ptr BuildC Inv->getLangOpts()->ThreadsafeStatics = false; Inv->getLangOpts()->AccessControl = false; Inv->getLangOpts()->DollarIdents = true; + // Needed for testing dynamic_cast. + Inv->getLangOpts()->RTTI = true; Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo); Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340220 - [ASTImporter] Add test for C++'s try/catch statements.
Author: teemperor Date: Mon Aug 20 15:13:24 2018 New Revision: 340220 URL: http://llvm.org/viewvc/llvm-project?rev=340220&view=rev Log: [ASTImporter] Add test for C++'s try/catch statements. Summary: Also enable exceptions in clang-import-test so that we can parse the test files. Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50978 Added: cfe/trunk/test/Import/cxx-try-catch/ cfe/trunk/test/Import/cxx-try-catch/Inputs/ cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp cfe/trunk/test/Import/cxx-try-catch/test.cpp Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp Added: cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp?rev=340220&view=auto == --- cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp Mon Aug 20 15:13:24 2018 @@ -0,0 +1,18 @@ +void f() { + try { + } catch (...) { + } + + try { + } catch (int) { + } + + try { + } catch (int varname) { + } + + try { + } catch (int varname1) { + } catch (long varname2) { + } +} Added: cfe/trunk/test/Import/cxx-try-catch/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-try-catch/test.cpp?rev=340220&view=auto == --- cfe/trunk/test/Import/cxx-try-catch/test.cpp (added) +++ cfe/trunk/test/Import/cxx-try-catch/test.cpp Mon Aug 20 15:13:24 2018 @@ -0,0 +1,39 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: CXXTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CXXCatchStmt +// CHECK-NEXT: <> +// CHECK-NEXT: CompoundStmt + +// CHECK: CXXTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CXXCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: 'int' +// CHECK-NEXT: CompoundStmt + +// CHECK: CXXTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CXXCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname +// CHECK-SAME: 'int' +// CHECK-NEXT: CompoundStmt + +// CHECK: CXXTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CXXCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname1 +// CHECK-SAME: 'int' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CXXCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname2 +// CHECK-SAME: 'long' +// CHECK-NEXT: CompoundStmt + +void expr() { + f(); +} Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=340220&r1=340219&r2=340220&view=diff == --- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original) +++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Mon Aug 20 15:13:24 2018 @@ -194,6 +194,8 @@ std::unique_ptr BuildC Inv->getLangOpts()->ThreadsafeStatics = false; Inv->getLangOpts()->AccessControl = false; Inv->getLangOpts()->DollarIdents = true; + Inv->getLangOpts()->Exceptions = true; + Inv->getLangOpts()->CXXExceptions = true; // Needed for testing dynamic_cast. Inv->getLangOpts()->RTTI = true; Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340297 - [ASTImporter] Add test for CXXForRangeStmt
Author: teemperor Date: Tue Aug 21 09:36:49 2018 New Revision: 340297 URL: http://llvm.org/viewvc/llvm-project?rev=340297&view=rev Log: [ASTImporter] Add test for CXXForRangeStmt Reviewers: a.sidorin, martong Reviewed By: martong Subscribers: rnkovacs, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51001 Added: cfe/trunk/test/Import/cxx-for-range/ cfe/trunk/test/Import/cxx-for-range/Inputs/ cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp cfe/trunk/test/Import/cxx-for-range/test.cpp Added: cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp?rev=340297&view=auto == --- cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp Tue Aug 21 09:36:49 2018 @@ -0,0 +1,11 @@ +struct Container { + int *begin(); + int *end(); +}; + +void f() { + Container c; + for (int varname : c) { +return; + } +} Added: cfe/trunk/test/Import/cxx-for-range/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-for-range/test.cpp?rev=340297&view=auto == --- cfe/trunk/test/Import/cxx-for-range/test.cpp (added) +++ cfe/trunk/test/Import/cxx-for-range/test.cpp Tue Aug 21 09:36:49 2018 @@ -0,0 +1,53 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: CXXForRangeStmt + +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: 'c' +// CHECK-SAME: Container + +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: CXXMemberCallExpr +// CHECK-SAME: 'int *' +// CHECK-NEXT: MemberExpr +// CHECK-SAME: .begin +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: '__range1' +// CHECK-SAME: Container + +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: CXXMemberCallExpr +// CHECK-SAME: 'int *' +// CHECK-NEXT: MemberExpr +// CHECK-SAME: .end +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: '__range1' +// CHECK-SAME: Container + +// CHECK-NEXT: BinaryOperator +// CHECK-SAME: '!=' +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: '__begin1' +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: '__end1' + +// CHECK-NEXT: UnaryOperator +// CHECK-SAME: '++' +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: '__begin1' + +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname + +// CHECK: ReturnStmt + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340304 - [ASTImporter] Add test for CXXNoexceptExpr
Author: teemperor Date: Tue Aug 21 10:15:57 2018 New Revision: 340304 URL: http://llvm.org/viewvc/llvm-project?rev=340304&view=rev Log: [ASTImporter] Add test for CXXNoexceptExpr Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, hiraditya, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50737 Added: cfe/trunk/test/Import/cxx-noexcept-expr/ cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/ cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp Added: cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp?rev=340304&view=auto == --- cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp Tue Aug 21 10:15:57 2018 @@ -0,0 +1 @@ +bool f() { return noexcept(1); } Added: cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp?rev=340304&view=auto == --- cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp (added) +++ cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp Tue Aug 21 10:15:57 2018 @@ -0,0 +1,8 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: CXXNoexceptExpr +// CHECK-NEXT: IntegerLiteral + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340463 - [ASTImporter] Add test for ObjCAutoreleasePoolStmt
Author: teemperor Date: Wed Aug 22 15:45:04 2018 New Revision: 340463 URL: http://llvm.org/viewvc/llvm-project?rev=340463&view=rev Log: [ASTImporter] Add test for ObjCAutoreleasePoolStmt Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51123 Added: cfe/trunk/test/Import/objc-autoreleasepool/ cfe/trunk/test/Import/objc-autoreleasepool/Inputs/ cfe/trunk/test/Import/objc-autoreleasepool/Inputs/F.m cfe/trunk/test/Import/objc-autoreleasepool/test.m Added: cfe/trunk/test/Import/objc-autoreleasepool/Inputs/F.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-autoreleasepool/Inputs/F.m?rev=340463&view=auto == --- cfe/trunk/test/Import/objc-autoreleasepool/Inputs/F.m (added) +++ cfe/trunk/test/Import/objc-autoreleasepool/Inputs/F.m Wed Aug 22 15:45:04 2018 @@ -0,0 +1,5 @@ +void f() { + @autoreleasepool { +return; + } +} Added: cfe/trunk/test/Import/objc-autoreleasepool/test.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-autoreleasepool/test.m?rev=340463&view=auto == --- cfe/trunk/test/Import/objc-autoreleasepool/test.m (added) +++ cfe/trunk/test/Import/objc-autoreleasepool/test.m Wed Aug 22 15:45:04 2018 @@ -0,0 +1,9 @@ +// RUN: clang-import-test -dump-ast -x objective-c++ -import %S/Inputs/F.m -expression %s | FileCheck %s + +// CHECK: ObjCAutoreleasePoolStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ReturnStmt + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340464 - [ASTImporter] Add test for SwitchStmt
Author: teemperor Date: Wed Aug 22 15:47:10 2018 New Revision: 340464 URL: http://llvm.org/viewvc/llvm-project?rev=340464&view=rev Log: [ASTImporter] Add test for SwitchStmt Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51056 Added: cfe/trunk/test/Import/switch-stmt/ cfe/trunk/test/Import/switch-stmt/Inputs/ cfe/trunk/test/Import/switch-stmt/Inputs/F.cpp cfe/trunk/test/Import/switch-stmt/test.cpp Added: cfe/trunk/test/Import/switch-stmt/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/switch-stmt/Inputs/F.cpp?rev=340464&view=auto == --- cfe/trunk/test/Import/switch-stmt/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/switch-stmt/Inputs/F.cpp Wed Aug 22 15:47:10 2018 @@ -0,0 +1,18 @@ +void f() { + switch (1) { + case 1: + case 2: +break; + } + switch (int varname; 1) { + case 1: +break; + case 2: +break; + } + switch (1) + default: +break; + switch (0) +; +} Added: cfe/trunk/test/Import/switch-stmt/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/switch-stmt/test.cpp?rev=340464&view=auto == --- cfe/trunk/test/Import/switch-stmt/test.cpp (added) +++ cfe/trunk/test/Import/switch-stmt/test.cpp Wed Aug 22 15:47:10 2018 @@ -0,0 +1,47 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: SwitchStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CaseStmt +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: <> +// CHECK-NEXT: CaseStmt +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: <> +// CHECK-NEXT: BreakStmt + +// CHECK: SwitchStmt +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname +// CHECK-NEXT: <> +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CaseStmt +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: <> +// CHECK-NEXT: BreakStmt +// CHECK-NEXT: CaseStmt +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: <> +// CHECK-NEXT: BreakStmt + +// CHECK: SwitchStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: DefaultStmt +// CHECK-NEXT: BreakStmt + +// CHECK: SwitchStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: NullStmt + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340465 - [ASTImporter] Add test for ObjCTypeParamDecl
Author: teemperor Date: Wed Aug 22 15:48:40 2018 New Revision: 340465 URL: http://llvm.org/viewvc/llvm-project?rev=340465&view=rev Log: [ASTImporter] Add test for ObjCTypeParamDecl Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51059 Added: cfe/trunk/test/Import/objc-param-decl/ cfe/trunk/test/Import/objc-param-decl/Inputs/ cfe/trunk/test/Import/objc-param-decl/Inputs/S.m cfe/trunk/test/Import/objc-param-decl/test.m Added: cfe/trunk/test/Import/objc-param-decl/Inputs/S.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-param-decl/Inputs/S.m?rev=340465&view=auto == --- cfe/trunk/test/Import/objc-param-decl/Inputs/S.m (added) +++ cfe/trunk/test/Import/objc-param-decl/Inputs/S.m Wed Aug 22 15:48:40 2018 @@ -0,0 +1,5 @@ +@protocol NSString +@end + +@interface Dictionary , NSString> +@end Added: cfe/trunk/test/Import/objc-param-decl/test.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-param-decl/test.m?rev=340465&view=auto == --- cfe/trunk/test/Import/objc-param-decl/test.m (added) +++ cfe/trunk/test/Import/objc-param-decl/test.m Wed Aug 22 15:48:40 2018 @@ -0,0 +1,11 @@ +// RUN: clang-import-test -dump-ast -x objective-c++ -import %S/Inputs/S.m -expression %s | FileCheck %s + +// CHECK: ObjCTypeParamDecl +// CHECK-SAME: FirstParam +// CHECK-SAME: 'id' +// CHECK-NEXT: ObjCTypeParamDecl +// CHECK-SAME: 'id':'id' + +void expr() { + Dictionary *d; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340466 - [ASTImporter] Remove duplicated and dead CXXNamedCastExpr handling code.
Author: teemperor Date: Wed Aug 22 15:49:32 2018 New Revision: 340466 URL: http://llvm.org/viewvc/llvm-project?rev=340466&view=rev Log: [ASTImporter] Remove duplicated and dead CXXNamedCastExpr handling code. Summary: `CXXNamedCastExpr` importing is already handled in the respective `VisitCXXNamedCastExpr` method. So this code here can never be reached under normal circumstances and we might as well remove it. This patch shouldn't change any observable behavior of the ASTImporter. Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51110 Modified: cfe/trunk/lib/AST/ASTImporter.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=340466&r1=340465&r2=340466&view=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Aug 22 15:49:32 2018 @@ -6088,38 +6088,6 @@ Expr *ASTNodeImporter::VisitExplicitCast TInfo, SubExpr); } default: -break; // just fall through - } - - auto *Named = cast(E); - SourceLocation ExprLoc = Importer.Import(Named->getOperatorLoc()), - RParenLoc = Importer.Import(Named->getRParenLoc()); - SourceRange Brackets = Importer.Import(Named->getAngleBrackets()); - - switch (E->getStmtClass()) { - case Stmt::CXXStaticCastExprClass: -return CXXStaticCastExpr::Create(Importer.getToContext(), T, - E->getValueKind(), E->getCastKind(), - SubExpr, &BasePath, TInfo, - ExprLoc, RParenLoc, Brackets); - - case Stmt::CXXDynamicCastExprClass: -return CXXDynamicCastExpr::Create(Importer.getToContext(), T, - E->getValueKind(), E->getCastKind(), - SubExpr, &BasePath, TInfo, - ExprLoc, RParenLoc, Brackets); - - case Stmt::CXXReinterpretCastExprClass: -return CXXReinterpretCastExpr::Create(Importer.getToContext(), T, - E->getValueKind(), E->getCastKind(), - SubExpr, &BasePath, TInfo, - ExprLoc, RParenLoc, Brackets); - - case Stmt::CXXConstCastExprClass: -return CXXConstCastExpr::Create(Importer.getToContext(), T, -E->getValueKind(), SubExpr, TInfo, ExprLoc, -RParenLoc, Brackets); - default: llvm_unreachable("Cast expression of unsupported type!"); return nullptr; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340467 - [ASTImporter] Actually test ArrayInitLoopExpr in the array-init-loop-expr test.
Author: teemperor Date: Wed Aug 22 15:50:45 2018 New Revision: 340467 URL: http://llvm.org/viewvc/llvm-project?rev=340467&view=rev Log: [ASTImporter] Actually test ArrayInitLoopExpr in the array-init-loop-expr test. Summary: The `array-init-loop-expr` test is currently not testing the importing of ArrayInitLoopExprs. This is because we import the `S` struct into the `test.cpp` context and only do a copy-assignment in `test.cpp`, so the actual ArrayInitLoopExpr we wanted to import is generated by clang directly in the target context. This means we actually never test the importing of ArrayInitLoopExpr with this test, which becomes obvious when looking at the missing test coverage for the respective VisitArrayInitLoopExpr method. This patch moves the copy-assignment of our struct to the `S.cpp` context, which means that `test.cpp` now actually has to import the ArrayInitLoopExpr. Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51115 Modified: cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp cfe/trunk/test/Import/array-init-loop-expr/test.cpp Modified: cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp?rev=340467&r1=340466&r2=340467&view=diff == --- cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp (original) +++ cfe/trunk/test/Import/array-init-loop-expr/Inputs/S.cpp Wed Aug 22 15:50:45 2018 @@ -1,3 +1,8 @@ class S { int a[10]; }; + +void f() { + S s; + S copy = s; +} Modified: cfe/trunk/test/Import/array-init-loop-expr/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/array-init-loop-expr/test.cpp?rev=340467&r1=340466&r2=340467&view=diff == --- cfe/trunk/test/Import/array-init-loop-expr/test.cpp (original) +++ cfe/trunk/test/Import/array-init-loop-expr/test.cpp Wed Aug 22 15:50:45 2018 @@ -6,6 +6,5 @@ // CHECK: ArrayInitIndexExpr void expr() { - S s; - S copy = s; + f(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340468 - [ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt
Author: teemperor Date: Wed Aug 22 15:51:37 2018 New Revision: 340468 URL: http://llvm.org/viewvc/llvm-project?rev=340468&view=rev Log: [ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51121 Added: cfe/trunk/test/Import/objc-try-catch/ cfe/trunk/test/Import/objc-try-catch/Inputs/ cfe/trunk/test/Import/objc-try-catch/Inputs/F.m cfe/trunk/test/Import/objc-try-catch/test.m Added: cfe/trunk/test/Import/objc-try-catch/Inputs/F.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-try-catch/Inputs/F.m?rev=340468&view=auto == --- cfe/trunk/test/Import/objc-try-catch/Inputs/F.m (added) +++ cfe/trunk/test/Import/objc-try-catch/Inputs/F.m Wed Aug 22 15:51:37 2018 @@ -0,0 +1,28 @@ +@interface Exception +@end +@interface OtherException +@end + +void f() { + @try { +Exception *e; +@throw e; + } + @catch (Exception *varname) { + } + @finally { + } + + @try { + } + @catch (Exception *varname1) { +@throw; + } + @catch (OtherException *varname2) { + } + + @try { + } + @finally { + } +} Added: cfe/trunk/test/Import/objc-try-catch/test.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-try-catch/test.m?rev=340468&view=auto == --- cfe/trunk/test/Import/objc-try-catch/test.m (added) +++ cfe/trunk/test/Import/objc-try-catch/test.m Wed Aug 22 15:51:37 2018 @@ -0,0 +1,40 @@ +// RUN: clang-import-test -x objective-c++ -Xcc -fobjc-exceptions -dump-ast -import %S/Inputs/F.m -expression %s | FileCheck %s + +// CHECK: ObjCAtTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: ObjCAtThrowStmt +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-NEXT: ObjCAtCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname +// CHECK-SAME: 'Exception *' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ObjCAtFinallyStmt +// CHECK-NEXT: CompoundStmt + +// CHECK-NEXT: ObjCAtTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ObjCAtCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname1 +// CHECK-SAME: 'Exception *' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ObjCAtThrowStmt +// CHECK-NEXT: <> +// CHECK-NEXT: ObjCAtCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname2 +// CHECK-SAME: 'OtherException *' +// CHECK-NEXT: CompoundStmt + +// CHECK-NEXT: ObjCAtTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ObjCAtFinallyStmt +// CHECK-NEXT: CompoundStmt + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340483 - Revert "[ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt"
Author: teemperor Date: Wed Aug 22 16:50:30 2018 New Revision: 340483 URL: http://llvm.org/viewvc/llvm-project?rev=340483&view=rev Log: Revert "[ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt" This test breaks llvm-clang-x86_64-expensive-checks-win. Removed: cfe/trunk/test/Import/objc-try-catch/Inputs/F.m cfe/trunk/test/Import/objc-try-catch/test.m Removed: cfe/trunk/test/Import/objc-try-catch/Inputs/F.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-try-catch/Inputs/F.m?rev=340482&view=auto == --- cfe/trunk/test/Import/objc-try-catch/Inputs/F.m (original) +++ cfe/trunk/test/Import/objc-try-catch/Inputs/F.m (removed) @@ -1,28 +0,0 @@ -@interface Exception -@end -@interface OtherException -@end - -void f() { - @try { -Exception *e; -@throw e; - } - @catch (Exception *varname) { - } - @finally { - } - - @try { - } - @catch (Exception *varname1) { -@throw; - } - @catch (OtherException *varname2) { - } - - @try { - } - @finally { - } -} Removed: cfe/trunk/test/Import/objc-try-catch/test.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-try-catch/test.m?rev=340482&view=auto == --- cfe/trunk/test/Import/objc-try-catch/test.m (original) +++ cfe/trunk/test/Import/objc-try-catch/test.m (removed) @@ -1,40 +0,0 @@ -// RUN: clang-import-test -x objective-c++ -Xcc -fobjc-exceptions -dump-ast -import %S/Inputs/F.m -expression %s | FileCheck %s - -// CHECK: ObjCAtTryStmt -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: DeclStmt -// CHECK-NEXT: VarDecl -// CHECK-NEXT: ObjCAtThrowStmt -// CHECK-NEXT: ImplicitCastExpr -// CHECK-NEXT: DeclRefExpr -// CHECK-NEXT: ObjCAtCatchStmt -// CHECK-NEXT: VarDecl -// CHECK-SAME: varname -// CHECK-SAME: 'Exception *' -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: ObjCAtFinallyStmt -// CHECK-NEXT: CompoundStmt - -// CHECK-NEXT: ObjCAtTryStmt -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: ObjCAtCatchStmt -// CHECK-NEXT: VarDecl -// CHECK-SAME: varname1 -// CHECK-SAME: 'Exception *' -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: ObjCAtThrowStmt -// CHECK-NEXT: <> -// CHECK-NEXT: ObjCAtCatchStmt -// CHECK-NEXT: VarDecl -// CHECK-SAME: varname2 -// CHECK-SAME: 'OtherException *' -// CHECK-NEXT: CompoundStmt - -// CHECK-NEXT: ObjCAtTryStmt -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: ObjCAtFinallyStmt -// CHECK-NEXT: CompoundStmt - -void expr() { - f(); -} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r332913 - Add missing include for cstdint to Visibility.h
Author: teemperor Date: Mon May 21 15:27:22 2018 New Revision: 332913 URL: http://llvm.org/viewvc/llvm-project?rev=332913&view=rev Log: Add missing include for cstdint to Visibility.h Summary: We use uint8_t in this header, so we need to include cstdint. Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47164 Modified: cfe/trunk/include/clang/Basic/Visibility.h Modified: cfe/trunk/include/clang/Basic/Visibility.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Visibility.h?rev=332913&r1=332912&r2=332913&view=diff == --- cfe/trunk/include/clang/Basic/Visibility.h (original) +++ cfe/trunk/include/clang/Basic/Visibility.h Mon May 21 15:27:22 2018 @@ -17,6 +17,7 @@ #include "clang/Basic/Linkage.h" #include +#include namespace clang { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333069 - Fix unaligned memory access when reading INPUT_FILE_OFFSETS data
Author: teemperor Date: Wed May 23 02:02:40 2018 New Revision: 333069 URL: http://llvm.org/viewvc/llvm-project?rev=333069&view=rev Log: Fix unaligned memory access when reading INPUT_FILE_OFFSETS data Summary: The blob data is unaligned, so we also should read it as such. Should fix the random failures with the sanitizer builds. Reviewers: rsmith, v.g.vassilev Reviewed By: v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47247 Modified: cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=333069&r1=333068&r2=333069&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed May 23 02:02:40 2018 @@ -4811,7 +4811,8 @@ bool ASTReader::readASTFileControlBlock( unsigned NumInputFiles = Record[0]; unsigned NumUserFiles = Record[1]; - const uint64_t *InputFileOffs = (const uint64_t *)Blob.data(); + const llvm::support::unaligned_uint64_t *InputFileOffs = + (const llvm::support::unaligned_uint64_t *)Blob.data(); for (unsigned I = 0; I != NumInputFiles; ++I) { // Go find this input file. bool isSystemFile = I >= NumUserFiles; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333123 - [modules] Mark __wmmintrin_pclmul.h/__wmmintrin_aes.h as textual
Author: teemperor Date: Wed May 23 13:59:46 2018 New Revision: 333123 URL: http://llvm.org/viewvc/llvm-project?rev=333123&view=rev Log: [modules] Mark __wmmintrin_pclmul.h/__wmmintrin_aes.h as textual Summary: Since clang r332929 these two headers throw errors when included from somewhere else than their wrapper header. It seems marking them as textual is the best way to fix the builds. Fixes this new module build error: While building module '_Builtin_intrinsics' imported from ...: In file included from :2: In file included from lib/clang/7.0.0/include/immintrin.h:54: In file included from lib/clang/7.0.0/include/wmmintrin.h:29: lib/clang/7.0.0/include/__wmmintrin_aes.h:25:2: error: "Never use <__wmmintrin_aes.h> directly; include instead." #error "Never use <__wmmintrin_aes.h> directly; include instead." Reviewers: rsmith, v.g.vassilev, craig.topper Reviewed By: craig.topper Subscribers: craig.topper, cfe-commits Differential Revision: https://reviews.llvm.org/D47277 Modified: cfe/trunk/lib/Headers/module.modulemap Modified: cfe/trunk/lib/Headers/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=333123&r1=333122&r2=333123&view=diff == --- cfe/trunk/lib/Headers/module.modulemap (original) +++ cfe/trunk/lib/Headers/module.modulemap Wed May 23 13:59:46 2018 @@ -71,6 +71,9 @@ module _Builtin_intrinsics [system] [ext textual header "sgxintrin.h" textual header "ptwriteintrin.h" +textual header "__wmmintrin_aes.h" +textual header "__wmmintrin_pclmul.h" + explicit module mm_malloc { requires !freestanding header "mm_malloc.h" @@ -136,14 +139,6 @@ module _Builtin_intrinsics [system] [ext export aes export pclmul } - -explicit module aes { - header "__wmmintrin_aes.h" -} - -explicit module pclmul { - header "__wmmintrin_pclmul.h" -} } explicit module systemz { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340541 - Re-land [ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt
Author: teemperor Date: Thu Aug 23 09:06:30 2018 New Revision: 340541 URL: http://llvm.org/viewvc/llvm-project?rev=340541&view=rev Log: Re-land [ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt Lands r340468 again, but this time we mark the test as unsupported on Windows because it seems that try/catch crashes CodeGen at the moment. Added: cfe/trunk/test/Import/objc-try-catch/Inputs/F.m cfe/trunk/test/Import/objc-try-catch/test.m Added: cfe/trunk/test/Import/objc-try-catch/Inputs/F.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-try-catch/Inputs/F.m?rev=340541&view=auto == --- cfe/trunk/test/Import/objc-try-catch/Inputs/F.m (added) +++ cfe/trunk/test/Import/objc-try-catch/Inputs/F.m Thu Aug 23 09:06:30 2018 @@ -0,0 +1,28 @@ +@interface Exception +@end +@interface OtherException +@end + +void f() { + @try { +Exception *e; +@throw e; + } + @catch (Exception *varname) { + } + @finally { + } + + @try { + } + @catch (Exception *varname1) { +@throw; + } + @catch (OtherException *varname2) { + } + + @try { + } + @finally { + } +} Added: cfe/trunk/test/Import/objc-try-catch/test.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-try-catch/test.m?rev=340541&view=auto == --- cfe/trunk/test/Import/objc-try-catch/test.m (added) +++ cfe/trunk/test/Import/objc-try-catch/test.m Thu Aug 23 09:06:30 2018 @@ -0,0 +1,43 @@ +// RUN: clang-import-test -x objective-c++ -Xcc -fobjc-exceptions -dump-ast -import %S/Inputs/F.m -expression %s | FileCheck %s + +// FIXME: Seems that Objective-C try/catch crash codegen on Windows. Reenable once this is fixed. +// UNSUPPORTED: system-windows + +// CHECK: ObjCAtTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: ObjCAtThrowStmt +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-NEXT: ObjCAtCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname +// CHECK-SAME: 'Exception *' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ObjCAtFinallyStmt +// CHECK-NEXT: CompoundStmt + +// CHECK-NEXT: ObjCAtTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ObjCAtCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname1 +// CHECK-SAME: 'Exception *' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ObjCAtThrowStmt +// CHECK-NEXT: <> +// CHECK-NEXT: ObjCAtCatchStmt +// CHECK-NEXT: VarDecl +// CHECK-SAME: varname2 +// CHECK-SAME: 'OtherException *' +// CHECK-NEXT: CompoundStmt + +// CHECK-NEXT: ObjCAtTryStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ObjCAtFinallyStmt +// CHECK-NEXT: CompoundStmt + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r340483 - Revert "[ASTImporter] Add test for ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt"
Thanks! Looking at the list of failing bots that seems indeed to be the most likely explanation. - Raphael Am Mi., 22. Aug. 2018 um 16:59 Uhr schrieb Shoaib Meenai : > > Might be because the constructed AST for a @finally on Windows will contain a > CapturedStmt: https://reviews.llvm.org/D47564. You probably want to > explicitly specify a non windows-msvc triple in the test. > > > > From: cfe-commits on behalf of Raphael > Isemann via cfe-commits > Reply-To: Raphael Isemann > Date: Wednesday, August 22, 2018 at 4:51 PM > To: "cfe-commits@lists.llvm.org" > Subject: r340483 - Revert "[ASTImporter] Add test for > ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt" > > > > Author: teemperor > > Date: Wed Aug 22 16:50:30 2018 > > New Revision: 340483 > > > > URL: > https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D340483-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SoW99711ISLe9RQ23xIpwyvcxXTd-Rxawo9VIXlpjuo&s=nc9gqViWXTB0N3ed5Zzdk_7AzYUFDgZpoxqOgBLI4nU&e= > > Log: > > Revert "[ASTImporter] Add test for > ObjCAtTryStmt/ObjCAtCatchStmt/ObjCAtThrowStmt" > > > > This test breaks llvm-clang-x86_64-expensive-checks-win. > > > > Removed: > > cfe/trunk/test/Import/objc-try-catch/Inputs/F.m > > cfe/trunk/test/Import/objc-try-catch/test.m > > > > Removed: cfe/trunk/test/Import/objc-try-catch/Inputs/F.m > > URL: > https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_Import_objc-2Dtry-2Dcatch_Inputs_F.m-3Frev-3D340482-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SoW99711ISLe9RQ23xIpwyvcxXTd-Rxawo9VIXlpjuo&s=kFKOp3N2QmGe252ijaqC1sM6nD0j9xQCdVvuBjevcko&e= > > == > > --- cfe/trunk/test/Import/objc-try-catch/Inputs/F.m (original) > > +++ cfe/trunk/test/Import/objc-try-catch/Inputs/F.m (removed) > > @@ -1,28 +0,0 @@ > > -@interface Exception > > -@end > > -@interface OtherException > > -@end > > - > > -void f() { > > - @try { > > -Exception *e; > > -@throw e; > > - } > > - @catch (Exception *varname) { > > - } > > - @finally { > > - } > > - > > - @try { > > - } > > - @catch (Exception *varname1) { > > -@throw; > > - } > > - @catch (OtherException *varname2) { > > - } > > - > > - @try { > > - } > > - @finally { > > - } > > -} > > > > Removed: cfe/trunk/test/Import/objc-try-catch/test.m > > URL: > https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_Import_objc-2Dtry-2Dcatch_test.m-3Frev-3D340482-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SoW99711ISLe9RQ23xIpwyvcxXTd-Rxawo9VIXlpjuo&s=q6vS8avd9ajINxEtZW7uL9FWfjCwl4TGy4e6NfUNkZI&e= > > == > > --- cfe/trunk/test/Import/objc-try-catch/test.m (original) > > +++ cfe/trunk/test/Import/objc-try-catch/test.m (removed) > > @@ -1,40 +0,0 @@ > > -// RUN: clang-import-test -x objective-c++ -Xcc -fobjc-exceptions -dump-ast > -import %S/Inputs/F.m -expression %s | FileCheck %s > > - > > -// CHECK: ObjCAtTryStmt > > -// CHECK-NEXT: CompoundStmt > > -// CHECK-NEXT: DeclStmt > > -// CHECK-NEXT: VarDecl > > -// CHECK-NEXT: ObjCAtThrowStmt > > -// CHECK-NEXT: ImplicitCastExpr > > -// CHECK-NEXT: DeclRefExpr > > -// CHECK-NEXT: ObjCAtCatchStmt > > -// CHECK-NEXT: VarDecl > > -// CHECK-SAME: varname > > -// CHECK-SAME: 'Exception *' > > -// CHECK-NEXT: CompoundStmt > > -// CHECK-NEXT: ObjCAtFinallyStmt > > -// CHECK-NEXT: CompoundStmt > > - > > -// CHECK-NEXT: ObjCAtTryStmt > > -// CHECK-NEXT: CompoundStmt > > -// CHECK-NEXT: ObjCAtCatchStmt > > -// CHECK-NEXT: VarDecl > > -// CHECK-SAME: varname1 > > -// CHECK-SAME: 'Exception *' > > -// CHECK-NEXT: CompoundStmt > > -// CHECK-NEXT: ObjCAtThrowStmt > > -// CHECK-NEXT: <> > > -// CHECK-NEXT: ObjCAtCatchStmt > > -// CHECK-NEXT: VarDecl > > -// CHECK-SAME: varname2 > > -// CHECK-SAME: 'OtherException *' > > -// CHECK-NEXT: CompoundStmt > > - > > -// CHECK-NEXT: ObjCAtTryStmt > > -// CHECK-NEXT: CompoundStmt > > -// CHECK-NEXT: ObjCAtFinallyStmt > > -// CHECK-NEXT: CompoundStmt > > - > > -void expr() { > > - f(); > > -} > > > > > > ___ > > cfe-commits mailing list > > cfe-commits@lists.llvm.org > > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SoW99711ISLe9RQ23xIpwyvcxXTd-Rxawo9VIXlpjuo&s=7OwU_LMC-xQGUKoTBrJZVj4QNfVYAIM5ZZDXF_RS9oc&e= > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340627 - [ASTImporter] Add test for PackExpansionExpr
Author: teemperor Date: Fri Aug 24 11:01:56 2018 New Revision: 340627 URL: http://llvm.org/viewvc/llvm-project?rev=340627&view=rev Log: [ASTImporter] Add test for PackExpansionExpr Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51142 Added: cfe/trunk/test/Import/pack-expansion-expr/ cfe/trunk/test/Import/pack-expansion-expr/Inputs/ cfe/trunk/test/Import/pack-expansion-expr/Inputs/F.cpp cfe/trunk/test/Import/pack-expansion-expr/test.cpp Added: cfe/trunk/test/Import/pack-expansion-expr/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/pack-expansion-expr/Inputs/F.cpp?rev=340627&view=auto == --- cfe/trunk/test/Import/pack-expansion-expr/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/pack-expansion-expr/Inputs/F.cpp Fri Aug 24 11:01:56 2018 @@ -0,0 +1,11 @@ +template +void sink(T... a); + +template +void packfuncT(T... a) { + sink(a...); +} + +void f() { + packfuncT(1, 2, 3); +} Added: cfe/trunk/test/Import/pack-expansion-expr/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/pack-expansion-expr/test.cpp?rev=340627&view=auto == --- cfe/trunk/test/Import/pack-expansion-expr/test.cpp (added) +++ cfe/trunk/test/Import/pack-expansion-expr/test.cpp Fri Aug 24 11:01:56 2018 @@ -0,0 +1,12 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: PackExpansionExpr +// CHECK-SAME: '' +// CHECK-NEXT: DeclRefExpr +// CHECK-SAME: 'T...' +// CHECK-SAME: ParmVar +// CHECK-SAME: 'a' + +void expr() { + f(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305878 - Changed wording in comment
Author: teemperor Date: Wed Jun 21 00:41:39 2017 New Revision: 305878 URL: http://llvm.org/viewvc/llvm-project?rev=305878&view=rev Log: Changed wording in comment Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=305878&r1=305877&r2=305878&view=diff == --- cfe/trunk/lib/Analysis/CloneDetection.cpp (original) +++ cfe/trunk/lib/Analysis/CloneDetection.cpp Wed Jun 21 00:41:39 2017 @@ -635,8 +635,7 @@ void CloneConstraint::splitCloneGroups( if (Indexes[j]) continue; -// If a following StmtSequence belongs to our CloneGroup, we add it to -// it. +// If a following StmtSequence belongs to our CloneGroup, we add it. const StmtSequence &Candidate = HashGroup[j]; if (!Compare(Prototype, Candidate)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D34439: Add GCC's noexcept-type alias for c++1z-compat-mangling
I couldn't find a case where both gcc and clang agreed at the same time that they should emit this warning, but I think that's just bugs in the way we detect these cases. From the near-identical warning message I would say they both should emit warnings for the same cases (and probably will in the future). 2017-06-21 19:41 GMT+02:00 Richard Smith : > Does the GCC warning warn on the same cases? > > On 21 Jun 2017 10:24 am, "Akira Hatanaka via Phabricator" > wrote: >> >> ahatanak added a comment. >> >> I didn't know gcc had its own option. This change seems reasonable to me. >> >> Since c++1z-compat-mangling was added just a few days ago, should we just >> rename it instead of adding an alias? >> >> >> https://reviews.llvm.org/D34439 >> >> >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334471 - Fix that AlignedAllocation.h doesn't compile because of VersionTuple
Author: teemperor Date: Mon Jun 11 20:43:21 2018 New Revision: 334471 URL: http://llvm.org/viewvc/llvm-project?rev=334471&view=rev Log: Fix that AlignedAllocation.h doesn't compile because of VersionTuple Summary: rL334399 put VersionTuple in the llvm namespace, but this header still assumes it's in the clang namespace. This leads to compilation failures with enabled modules when building Clang. Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48062 Modified: cfe/trunk/include/clang/Basic/AlignedAllocation.h Modified: cfe/trunk/include/clang/Basic/AlignedAllocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AlignedAllocation.h?rev=334471&r1=334470&r2=334471&view=diff == --- cfe/trunk/include/clang/Basic/AlignedAllocation.h (original) +++ cfe/trunk/include/clang/Basic/AlignedAllocation.h Mon Jun 11 20:43:21 2018 @@ -22,18 +22,18 @@ namespace clang { -inline VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { +inline llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { switch (OS) { default: break; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: // Earliest supporting version is 10.13. -return VersionTuple(10U, 13U); +return llvm::VersionTuple(10U, 13U); case llvm::Triple::IOS: case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0. -return VersionTuple(11U); +return llvm::VersionTuple(11U); case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0. -return VersionTuple(4U); +return llvm::VersionTuple(4U); } llvm_unreachable("Unexpected OS"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r351739 - [ASTImporter] Add test for importing anonymous namespaces.
Author: teemperor Date: Mon Jan 21 02:14:31 2019 New Revision: 351739 URL: http://llvm.org/viewvc/llvm-project?rev=351739&view=rev Log: [ASTImporter] Add test for importing anonymous namespaces. Reviewers: a.sidorin, a_sidorin Reviewed By: a_sidorin Subscribers: a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D51178 Added: cfe/trunk/test/Import/cxx-anon-namespace/ cfe/trunk/test/Import/cxx-anon-namespace/Inputs/ cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp cfe/trunk/test/Import/cxx-anon-namespace/test.cpp Added: cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp?rev=351739&view=auto == --- cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp Mon Jan 21 02:14:31 2019 @@ -0,0 +1,25 @@ +namespace { +void func1() { +} +} // namespace + +namespace test_namespace1 { +namespace { +void func2() {} +} // namespace +} // namespace test_namespace1 + +namespace test_namespace2 { +namespace { +namespace test_namespace3 { +void func3() {} +} // namespace test_namespace3 +} // namespace +} // namespace test_namespace2 + +namespace { +namespace { +void func4() { +} +} // namespace +} // namespace Added: cfe/trunk/test/Import/cxx-anon-namespace/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-anon-namespace/test.cpp?rev=351739&view=auto == --- cfe/trunk/test/Import/cxx-anon-namespace/test.cpp (added) +++ cfe/trunk/test/Import/cxx-anon-namespace/test.cpp Mon Jan 21 02:14:31 2019 @@ -0,0 +1,45 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// The implicit UsingDirectiveDecls for the anonymous namespaces are created by the Sema. + +// CHECK: NamespaceDecl +// The nested anonymous namespace. +// CHECK-NEXT: NamespaceDecl +// CHECK: FunctionDecl +// CHECK-SAME: func4 +// CHECK-NEXT: CompoundStmt +// This is for the nested anonymous namespace. +// CHECK-NEXT: UsingDirectiveDecl +// CHECK-SAME: '' +// CHECK: FunctionDecl +// CHECK-SAME: func1 +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: UsingDirectiveDecl +// CHECK-SAME: '' + +// CHECK: NamespaceDecl +// CHECK-SAME: test_namespace1 +// CHECK-NEXT: NamespaceDecl +// CHECK: FunctionDecl +// CHECK-SAME: func2 +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: UsingDirectiveDecl +// CHECK-SAME: '' + +// CHECK-NEXT: NamespaceDecl +// CHECK-SAME: test_namespace2 +// CHECK-NEXT: NamespaceDecl +// CHECK-NEXT: NamespaceDecl +// CHECK-SAME: test_namespace3 +// CHECK: FunctionDecl +// CHECK-SAME: func3 +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: UsingDirectiveDecl +// CHECK-SAME: '' + +void expr() { + func1(); + test_namespace1::func2(); + test_namespace2::test_namespace3::func3(); + func4(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r351849 - [ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl
Author: teemperor Date: Tue Jan 22 09:59:45 2019 New Revision: 351849 URL: http://llvm.org/viewvc/llvm-project?rev=351849&view=rev Log: [ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl Summary: Shafik found out that importing a CXXConstructorDecl will create a translation unit that causes Clang's CodeGen to crash. The reason for that is that we don't copy the OperatorDelete from the CXXConstructorDecl when importing. This patch fixes it and adds a test case for that. Reviewers: shafik, martong, a_sidorin, a.sidorin Reviewed By: martong, a_sidorin Subscribers: rnkovacs, cfe-commits Differential Revision: https://reviews.llvm.org/D56651 Added: cfe/trunk/test/Import/destructor/ cfe/trunk/test/Import/destructor/Inputs/ cfe/trunk/test/Import/destructor/Inputs/F.cpp cfe/trunk/test/Import/destructor/test.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=351849&r1=351848&r2=351849&view=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Jan 22 09:59:45 2019 @@ -3091,12 +3091,28 @@ ExpectedDecl ASTNodeImporter::VisitFunct FromConstructor->isExplicit(), D->isInlineSpecified(), D->isImplicit(), D->isConstexpr())) return ToFunction; - } else if (isa(D)) { + } else if (CXXDestructorDecl *FromDtor = dyn_cast(D)) { + +auto Imp = +importSeq(const_cast(FromDtor->getOperatorDelete()), + FromDtor->getOperatorDeleteThisArg()); + +if (!Imp) + return Imp.takeError(); + +FunctionDecl *ToOperatorDelete; +Expr *ToThisArg; +std::tie(ToOperatorDelete, ToThisArg) = *Imp; + if (GetImportedOrCreateDecl( ToFunction, D, Importer.getToContext(), cast(DC), ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(), D->isImplicit())) return ToFunction; + +CXXDestructorDecl *ToDtor = cast(ToFunction); + +ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg); } else if (CXXConversionDecl *FromConversion = dyn_cast(D)) { if (GetImportedOrCreateDecl( Added: cfe/trunk/test/Import/destructor/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/destructor/Inputs/F.cpp?rev=351849&view=auto == --- cfe/trunk/test/Import/destructor/Inputs/F.cpp (added) +++ cfe/trunk/test/Import/destructor/Inputs/F.cpp Tue Jan 22 09:59:45 2019 @@ -0,0 +1,3 @@ +struct B { + virtual ~B() {} +}; Added: cfe/trunk/test/Import/destructor/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/destructor/test.cpp?rev=351849&view=auto == --- cfe/trunk/test/Import/destructor/test.cpp (added) +++ cfe/trunk/test/Import/destructor/test.cpp Tue Jan 22 09:59:45 2019 @@ -0,0 +1,10 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s + +// Triggers the deserialization of B's destructor. +B b1; + +// CHECK: CXXDestructorDecl + +// CHECK-NEXT: ~B 'void () noexcept' virtual +// CHECK-SAME: 'void () noexcept' +// CHECK-SAME: virtual ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r347863 - Set MustBuildLookupTable on PrimaryContext in ExternalASTMerger
Author: teemperor Date: Thu Nov 29 05:50:30 2018 New Revision: 347863 URL: http://llvm.org/viewvc/llvm-project?rev=347863&view=rev Log: Set MustBuildLookupTable on PrimaryContext in ExternalASTMerger Summary: `MustBuildLookupTable` must always be called on a primary context as we otherwise trigger an assert, but we don't ensure that this will always happen in our code right now. This patch explicitly requests the primary context when doing this call as this shouldn't break anything (as calling `getPrimaryContext` on a context which is its own primary context is a no-op) but will catch these rare cases where we somehow operate on a declaration context that is not its own primary context. See also D54863. Reviewers: martong, a.sidorin, shafik Reviewed By: martong Subscribers: davide, rnkovacs, cfe-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D54898 Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=347863&r1=347862&r2=347863&view=diff == --- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original) +++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Thu Nov 29 05:50:30 2018 @@ -144,14 +144,14 @@ public: } if (auto *ToTag = dyn_cast(To)) { ToTag->setHasExternalLexicalStorage(); - ToTag->setMustBuildLookupTable(); + ToTag->getPrimaryContext()->setMustBuildLookupTable(); assert(Parent.CanComplete(ToTag)); } else if (auto *ToNamespace = dyn_cast(To)) { ToNamespace->setHasExternalVisibleStorage(); assert(Parent.CanComplete(ToNamespace)); } else if (auto *ToContainer = dyn_cast(To)) { ToContainer->setHasExternalLexicalStorage(); - ToContainer->setMustBuildLookupTable(); + ToContainer->getPrimaryContext()->setMustBuildLookupTable(); assert(Parent.CanComplete(ToContainer)); } return To; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r348755 - Misc typos fixes in ./lib folder
Author: teemperor Date: Mon Dec 10 04:37:46 2018 New Revision: 348755 URL: http://llvm.org/viewvc/llvm-project?rev=348755&view=rev Log: Misc typos fixes in ./lib folder Summary: Found via `codespell -q 3 -I ../clang-whitelist.txt -L uint,importd,crasher,gonna,cant,ue,ons,orign,ned` Reviewers: teemperor Reviewed By: teemperor Subscribers: teemperor, jholewinski, jvesely, nhaehnle, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D55475 Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ODRHash.cpp cfe/trunk/lib/AST/RawCommentList.cpp cfe/trunk/lib/Analysis/CloneDetection.cpp cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp cfe/trunk/lib/Driver/ToolChains/Darwin.cpp cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Lex/Lexer.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/lib/Parse/Parser.cpp cfe/trunk/lib/Rewrite/RewriteRope.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/SemaLookup.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp cfe/trunk/lib/StaticAnalyzer/Core/WorkList.cpp cfe/trunk/lib/StaticAnalyzer/README.txt Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=348755&r1=348754&r2=348755&view=diff == --- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original) +++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Mon Dec 10 04:37:46 2018 @@ -226,7 +226,7 @@ void FileRemapper::remap(const FileEntry const FileEntry *FileRemapper::getOriginalFile(StringRef filePath) { const FileEntry *file = FileMgr->getFile(filePath); - // If we are updating a file that overriden an original file, + // If we are updating a file that overridden an original file, // actually update the original file. llvm::DenseMap::iterator I = ToFromMappings.find(file); Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=348755&r1=348754&r2=348755&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Dec 10 04:37:46 2018 @@ -8129,7 +8129,7 @@ void getIntersectionOfProtocols(ASTConte // Also add the protocols associated with the LHS interface. Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet); - // Add all of the protocls for the RHS. + // Add all of the protocols for the RHS. llvm::SmallPtrSet RHSProtocolSet; // Start with the protocol qualifiers. Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=348755&r1=348754&r2=348755&view=diff == --- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original) +++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Mon
r356592 - Remove the unused return value in ASTImporter::Imported [NFC]
Author: teemperor Date: Wed Mar 20 12:00:25 2019 New Revision: 356592 URL: http://llvm.org/viewvc/llvm-project?rev=356592&view=rev Log: Remove the unused return value in ASTImporter::Imported [NFC] Summary: `ASTImporter::Imported` currently returns a Decl, but that return value is not used by the ASTImporter (or anywhere else) nor is it documented. Reviewers: balazske, martong, a.sidorin, shafik Reviewed By: balazske, martong Subscribers: rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59595 Modified: cfe/trunk/include/clang/AST/ASTImporter.h cfe/trunk/lib/AST/ExternalASTMerger.cpp Modified: cfe/trunk/include/clang/AST/ASTImporter.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=356592&r1=356591&r2=356592&view=diff == --- cfe/trunk/include/clang/AST/ASTImporter.h (original) +++ cfe/trunk/include/clang/AST/ASTImporter.h Wed Mar 20 12:00:25 2019 @@ -425,7 +425,7 @@ class TypeSourceInfo; /// Subclasses can override this function to observe all of the \c From -> /// \c To declaration mappings as they are imported. -virtual Decl *Imported(Decl *From, Decl *To) { return To; } +virtual void Imported(Decl *From, Decl *To) {} /// Store and assign the imported declaration to its counterpart. Decl *MapImported(Decl *From, Decl *To); Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=356592&r1=356591&r2=356592&view=diff == --- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original) +++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Wed Mar 20 12:00:25 2019 @@ -110,7 +110,7 @@ public: /// Whenever a DeclContext is imported, ensure that ExternalASTSource's origin /// map is kept up to date. Also set the appropriate flags. - Decl *Imported(Decl *From, Decl *To) override { + void Imported(Decl *From, Decl *To) override { if (auto *ToDC = dyn_cast(To)) { const bool LoggingEnabled = Parent.LoggingEnabled(); if (LoggingEnabled) @@ -153,7 +153,6 @@ public: ToContainer->getPrimaryContext()->setMustBuildLookupTable(); assert(Parent.CanComplete(ToContainer)); } -return To; } ASTImporter &GetReverse() { return Reverse; } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r358006 - Fixed comment as pointed out by post-commit review of D59845
Author: teemperor Date: Tue Apr 9 07:18:23 2019 New Revision: 358006 URL: http://llvm.org/viewvc/llvm-project?rev=358006&view=rev Log: Fixed comment as pointed out by post-commit review of D59845 Modified: cfe/trunk/lib/AST/ASTImporter.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=358006&r1=358005&r2=358006&view=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Apr 9 07:18:23 2019 @@ -1947,7 +1947,7 @@ bool ASTNodeImporter::IsStructuralMatch( bool ASTNodeImporter::IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToEnum) { // Eliminate a potential failure point where we attempt to re-import - // something we're trying to import while completin ToEnum + // something we're trying to import while completing ToEnum. if (Decl *ToOrigin = Importer.GetOriginalDecl(ToEnum)) if (auto *ToOriginEnum = dyn_cast(ToOrigin)) ToEnum = ToOriginEnum; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r359502 - [ASTImporter] Add an ImportImpl method to allow customizing Import behavior.
Author: teemperor Date: Mon Apr 29 14:02:35 2019 New Revision: 359502 URL: http://llvm.org/viewvc/llvm-project?rev=359502&view=rev Log: [ASTImporter] Add an ImportImpl method to allow customizing Import behavior. Summary: We are currently implementing support in LLDB that reconstructs the STL templates from the target program in the expression evaluator. This reconstruction happens during the import process from our debug info AST into the expression evaluation AST, which means we need a way to intercept the ASTImporter import process. This patch adds an protected ImportImpl method that we can overwrite in LLDB to implement our special importing logic (which is essentially just looking into a C++ module that is attached to the target context). Because ImportImpl has to call MapImported/AddToLookup for the decls it creates, this patch also exposes those via a new unified method and checks that we call it when importing decls. Reviewers: martong, balazske, a.sidorin, shafik, a_sidorin Reviewed By: martong, a_sidorin Subscribers: rnkovacs, cfe-commits, lldb-commits, aprantl Tags: #clang Differential Revision: https://reviews.llvm.org/D59485 Modified: cfe/trunk/include/clang/AST/ASTImporter.h cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/unittests/AST/ASTImporterTest.cpp Modified: cfe/trunk/include/clang/AST/ASTImporter.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=359502&r1=359501&r2=359502&view=diff == --- cfe/trunk/include/clang/AST/ASTImporter.h (original) +++ cfe/trunk/include/clang/AST/ASTImporter.h Mon Apr 29 14:02:35 2019 @@ -142,6 +142,12 @@ class TypeSourceInfo; void AddToLookupTable(Decl *ToD); + protected: +/// Can be overwritten by subclasses to implement their own import logic. +/// The overwritten method should call this method if it didn't import the +/// decl on its own. +virtual Expected ImportImpl(Decl *From); + public: /// \param ToContext The context we'll be importing into. @@ -427,6 +433,8 @@ class TypeSourceInfo; /// \c To declaration mappings as they are imported. virtual void Imported(Decl *From, Decl *To) {} +void RegisterImportedDecl(Decl *FromD, Decl *ToD); + /// Store and assign the imported declaration to its counterpart. Decl *MapImported(Decl *From, Decl *To); Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=359502&r1=359501&r2=359502&view=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Apr 29 14:02:35 2019 @@ -255,8 +255,7 @@ namespace clang { return true; // Already imported. ToD = CreateFun(std::forward(args)...); // Keep track of imported Decls. - Importer.MapImported(FromD, ToD); - Importer.AddToLookupTable(ToD); + Importer.RegisterImportedDecl(FromD, ToD); InitializeImportedDecl(FromD, ToD); return false; // A new Decl is created. } @@ -7656,6 +7655,17 @@ void ASTImporter::AddToLookupTable(Decl LookupTable->add(ToND); } +Expected ASTImporter::ImportImpl(Decl *FromD) { + // Import the decl using ASTNodeImporter. + ASTNodeImporter Importer(*this); + return Importer.Visit(FromD); +} + +void ASTImporter::RegisterImportedDecl(Decl *FromD, Decl *ToD) { + MapImported(FromD, ToD); + AddToLookupTable(ToD); +} + Expected ASTImporter::Import_New(QualType FromT) { if (FromT.isNull()) return QualType{}; @@ -7749,7 +7759,6 @@ Expected ASTImporter::Import_New if (!FromD) return nullptr; - ASTNodeImporter Importer(*this); // Check whether we've already imported this declaration. Decl *ToD = GetAlreadyImportedOrNull(FromD); @@ -7760,7 +7769,7 @@ Expected ASTImporter::Import_New } // Import the declaration. - ExpectedDecl ToDOrErr = Importer.Visit(FromD); + ExpectedDecl ToDOrErr = ImportImpl(FromD); if (!ToDOrErr) return ToDOrErr; ToD = *ToDOrErr; @@ -7771,6 +7780,9 @@ Expected ASTImporter::Import_New return nullptr; } + // Make sure that ImportImpl registered the imported decl. + assert(ImportedDecls.count(FromD) != 0 && "Missing call to MapImported?"); + // Once the decl is connected to the existing declarations, i.e. when the // redecl chain is properly set then we populate the lookup again. // This way the primary context will be able to find all decls. Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=359502&r1=359501&r2=359502&view=diff == --- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original) +++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon Apr 29 14:02:35 2019 @
r311991 - [modules] Add test for using declaration in classes.
Author: teemperor Date: Tue Aug 29 02:27:41 2017 New Revision: 311991 URL: http://llvm.org/viewvc/llvm-project?rev=311991&view=rev Log: [modules] Add test for using declaration in classes. Summary: This adds a test that checks if the using declaration in classes still works as intended with modules. The motivation for this is that we tried to add a shortcut to `removeDecl` that would skip the removal of declarations from the lookup table if they are hidden. This optimization passed the clang test suite but actually broke the using declaration in combination with -fmodules-local-submodule-visibility. In this mode we hide all decls from other modules such as by chance the parent method, in which case don't remove the parent method from the lookup table and get ambiguous lookup errors. After this patch we now correctly see if this behavior is broken by a patch like this in the test suite. Reviewers: v.g.vassilev Reviewed By: v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D37180 Added: cfe/trunk/test/Modules/using-decl-inheritance.cpp Added: cfe/trunk/test/Modules/using-decl-inheritance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/using-decl-inheritance.cpp?rev=311991&view=auto == --- cfe/trunk/test/Modules/using-decl-inheritance.cpp (added) +++ cfe/trunk/test/Modules/using-decl-inheritance.cpp Tue Aug 29 02:27:41 2017 @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -x c++ -fmodules -fmodules-local-submodule-visibility -fmodules-cache-path=%t %s -verify +// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t %s -verify + +// expected-no-diagnostics + +#pragma clang module build A + module A { } +#pragma clang module contents +#pragma clang module begin A +struct A { + virtual void Foo(double x) const; +}; +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module build B + module B { } +#pragma clang module contents +#pragma clang module begin B +#pragma clang module import A +struct B : A { + using A::Foo; + virtual void Foo(double x) const; +}; +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module import B + +int main() { + B b; + b.Foo(1.0); +} + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312222 - [analyzer] Performance optimizations for the CloneChecker
Author: teemperor Date: Thu Aug 31 00:10:46 2017 New Revision: 31 URL: http://llvm.org/viewvc/llvm-project?rev=31&view=rev Log: [analyzer] Performance optimizations for the CloneChecker Summary: This patch aims at optimizing the CloneChecker for larger programs. Before this patch we took around 102 seconds to analyze sqlite3 with a complexity value of 50. After this patch we now take 2.1 seconds to analyze sqlite3. The biggest performance optimization is that we now put the constraint for group size before the constraint for the complexity. The group size constraint is much faster in comparison to the complexity constraint as it only does a simple integer comparison. The complexity constraint on the other hand actually traverses each Stmt and even checks the macro stack, so it is obviously not able to handle larger amounts of incoming clones. The new order filters out all the single-clone groups that the type II constraint generates in a faster way before passing the fewer remaining clones to the complexity constraint. This reduced runtime by around 95%. The other change is that we also delay the verification part of the type II clones back in the chain of constraints. This required to split up the constraint into two parts - a verification and a hash constraint (which is also making it more similar to the original design of the clone detection algorithm). The reasoning for this is the same as before: The verification constraint has to traverse many statements and shouldn't be at the start of the constraint chain. However, as the type II hashing has to be the first step in our algorithm, we have no other choice but split this constrain into two different ones. Now our group size and complexity constrains filter out a chunk of the clones before they reach the slow verification step, which reduces the runtime by around 8%. I also kept the full type II constraint around - that now just calls it's two sub-constraints - in case someone doesn't care about the performance benefits of doing this. Reviewers: NoQ Reviewed By: NoQ Subscribers: klimek, v.g.vassilev, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D34182 Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h cfe/trunk/lib/Analysis/CloneDetection.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp cfe/trunk/unittests/Analysis/CloneDetectionTest.cpp Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=31&r1=312221&r2=31&view=diff == --- cfe/trunk/include/clang/Analysis/CloneDetection.h (original) +++ cfe/trunk/include/clang/Analysis/CloneDetection.h Thu Aug 31 00:10:46 2017 @@ -252,22 +252,25 @@ public: std::function Compare); }; -/// Searches all children of the given clones for type II clones (i.e. they are -/// identical in every aspect beside the used variable names). -class RecursiveCloneTypeIIConstraint { - - /// Generates and saves a hash code for the given Stmt. - /// \param S The given Stmt. - /// \param D The Decl containing S. - /// \param StmtsByHash Output parameter that will contain the hash codes for - ///each StmtSequence in the given Stmt. - /// \return The hash code of the given Stmt. - /// - /// If the given Stmt is a CompoundStmt, this method will also generate - /// hashes for all possible StmtSequences in the children of this Stmt. - size_t saveHash(const Stmt *S, const Decl *D, - std::vector> &StmtsByHash); +/// This constraint moves clones into clone groups of type II via hashing. +/// +/// Clones with different hash values are moved into separate clone groups. +/// Collisions are possible, and this constraint does nothing to address this +/// them. Add the slower RecursiveCloneTypeIIVerifyConstraint later in the +/// constraint chain, not necessarily immediately, to eliminate hash collisions +/// through a more detailed analysis. +class RecursiveCloneTypeIIHashConstraint { +public: + void constrain(std::vector &Sequences); +}; +/// This constraint moves clones into clone groups of type II by comparing them. +/// +/// Clones that aren't type II clones are moved into separate clone groups. +/// In contrast to the RecursiveCloneTypeIIHashConstraint, all clones in a clone +/// group are guaranteed to be be type II clones of each other, but it is too +/// slow to efficiently handle large amounts of clones. +class RecursiveCloneTypeIIVerifyConstraint { public: void constrain(std::vector &Sequences); }; Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=31&r1=312221&r2=31&view=diff == --- cfe/trunk/lib/Analysis/CloneDetection.cpp (original) +++ cf
r312440 - [analyzer] MinComplexityConstraint now early exits and only does one macro stack lookup
Author: teemperor Date: Sun Sep 3 06:45:33 2017 New Revision: 312440 URL: http://llvm.org/viewvc/llvm-project?rev=312440&view=rev Log: [analyzer] MinComplexityConstraint now early exits and only does one macro stack lookup Summary: This patch contains performance improvements for the `MinComplexityConstraint`. It reduces the constraint time when running on the SQLite codebase by around 43% (from 0.085s down to 0.049s). The patch is essentially doing two things: * It introduces a possibility for the complexity value to early exit when reaching the limit we were checking for. This means that once we noticed that the current clone is larger than the limit the user has set, we instantly exit and no longer traverse the tree or do further expensive lookups in the macro stack. * It also removes half of the macro stack lookups we do so far. Previously we always checked the start and the end location of a Stmt for macros, which was only a middle way between checking all locations of the Stmt and just checking one location. In practice I rarely found cases where it really matters if we check start/end or just the start of a statement as code with lots of macros that somehow just produce half a statement are very rare. Reviewers: NoQ Subscribers: cfe-commits, xazax.hun, v.g.vassilev Differential Revision: https://reviews.llvm.org/D34361 Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h cfe/trunk/lib/Analysis/CloneDetection.cpp Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=312440&r1=312439&r2=312440&view=diff == --- cfe/trunk/include/clang/Analysis/CloneDetection.h (original) +++ cfe/trunk/include/clang/Analysis/CloneDetection.h Sun Sep 3 06:45:33 2017 @@ -288,14 +288,19 @@ public: MinComplexityConstraint(unsigned MinComplexity) : MinComplexity(MinComplexity) {} - size_t calculateStmtComplexity(const StmtSequence &Seq, + /// Calculates the complexity of the given StmtSequence. + /// \param Limit The limit of complexity we probe for. After reaching + /// this limit during calculation, this method is exiting + /// early to improve performance and returns this limit. + size_t calculateStmtComplexity(const StmtSequence &Seq, std::size_t Limit, const std::string &ParentMacroStack = ""); void constrain(std::vector &CloneGroups) { CloneConstraint::filterGroups( CloneGroups, [this](const CloneDetector::CloneGroup &A) { if (!A.empty()) -return calculateStmtComplexity(A.front()) < MinComplexity; +return calculateStmtComplexity(A.front(), MinComplexity) < + MinComplexity; else return false; }); Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=312440&r1=312439&r2=312440&view=diff == --- cfe/trunk/lib/Analysis/CloneDetection.cpp (original) +++ cfe/trunk/lib/Analysis/CloneDetection.cpp Sun Sep 3 06:45:33 2017 @@ -422,7 +422,8 @@ void RecursiveCloneTypeIIVerifyConstrain } size_t MinComplexityConstraint::calculateStmtComplexity( -const StmtSequence &Seq, const std::string &ParentMacroStack) { +const StmtSequence &Seq, std::size_t Limit, +const std::string &ParentMacroStack) { if (Seq.empty()) return 0; @@ -431,10 +432,8 @@ size_t MinComplexityConstraint::calculat ASTContext &Context = Seq.getASTContext(); // Look up what macros expanded into the current statement. - std::string StartMacroStack = + std::string MacroStack = data_collection::getMacroStack(Seq.getStartLoc(), Context); - std::string EndMacroStack = - data_collection::getMacroStack(Seq.getEndLoc(), Context); // First, check if ParentMacroStack is not empty which means we are currently // dealing with a parent statement which was expanded from a macro. @@ -444,8 +443,7 @@ size_t MinComplexityConstraint::calculat // macro expansion will only increase the total complexity by one. // Note: This is not the final complexity of this statement as we still // add the complexity of the child statements to the complexity value. - if (!ParentMacroStack.empty() && (StartMacroStack == ParentMacroStack && -EndMacroStack == ParentMacroStack)) { + if (!ParentMacroStack.empty() && MacroStack == ParentMacroStack) { Complexity = 0; } @@ -454,12 +452,16 @@ size_t MinComplexityConstraint::calculat if (Seq.holdsSequence()) { for (const Stmt *S : Seq) { Complexity += calculateStmtComplexity( - StmtSequence(S, Seq.getContainingDecl()), StartMacroStack); + StmtSequence(S, Seq.getContai
r312468 - [analyzer] Increase minimum complexity filter of the CloneChecker.
Author: teemperor Date: Sun Sep 3 22:56:36 2017 New Revision: 312468 URL: http://llvm.org/viewvc/llvm-project?rev=312468&view=rev Log: [analyzer] Increase minimum complexity filter of the CloneChecker. Summary: So far we used a value of 10 which was useful for testing but produces many false-positives in real programs. The usual suspicious clones we find seem to be at around a complexity value of 70 and for normal clone-reporting everything above 50 seems to be a valid normal clone for users, so let's just go with 50 for now and set this as the new default value. This patch also explicitly sets the complexity value for the regression tests as they serve more of a regression testing/debugging purpose and shouldn't really be reported by default in real programs. I'll add more tests that reflect actual found bugs that then need to pass with the default setting in the future. Reviewers: NoQ Subscribers: cfe-commits, javed.absar, xazax.hun, v.g.vassilev Differential Revision: https://reviews.llvm.org/D34178 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp cfe/trunk/test/Analysis/copypaste/asm.cpp cfe/trunk/test/Analysis/copypaste/attributes.cpp cfe/trunk/test/Analysis/copypaste/autogenerated_automoc.cpp cfe/trunk/test/Analysis/copypaste/blocks.cpp cfe/trunk/test/Analysis/copypaste/call.cpp cfe/trunk/test/Analysis/copypaste/catch.cpp cfe/trunk/test/Analysis/copypaste/delete.cpp cfe/trunk/test/Analysis/copypaste/dependent-exist.cpp cfe/trunk/test/Analysis/copypaste/expr-types.cpp cfe/trunk/test/Analysis/copypaste/fold.cpp cfe/trunk/test/Analysis/copypaste/function-try-block.cpp cfe/trunk/test/Analysis/copypaste/functions.cpp cfe/trunk/test/Analysis/copypaste/generic.c cfe/trunk/test/Analysis/copypaste/labels.cpp cfe/trunk/test/Analysis/copypaste/lambda.cpp cfe/trunk/test/Analysis/copypaste/macros.cpp cfe/trunk/test/Analysis/copypaste/not-autogenerated.cpp cfe/trunk/test/Analysis/copypaste/objc-methods.m cfe/trunk/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp cfe/trunk/test/Analysis/copypaste/plist-diagnostics.cpp cfe/trunk/test/Analysis/copypaste/sub-sequences.cpp cfe/trunk/test/Analysis/copypaste/suspicious-clones.cpp cfe/trunk/test/Analysis/copypaste/text-diagnostics.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp?rev=312468&r1=312467&r2=312468&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp Sun Sep 3 22:56:36 2017 @@ -64,7 +64,7 @@ void CloneChecker::checkEndOfTranslation // the CloneDetector. The only thing left to do is to report the found clones. int MinComplexity = Mgr.getAnalyzerOptions().getOptionAsInteger( - "MinimumCloneComplexity", 10, this); + "MinimumCloneComplexity", 50, this); assert(MinComplexity >= 0); bool ReportSuspiciousClones = Mgr.getAnalyzerOptions().getBooleanOption( Modified: cfe/trunk/test/Analysis/copypaste/asm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/copypaste/asm.cpp?rev=312468&r1=312467&r2=312468&view=diff == --- cfe/trunk/test/Analysis/copypaste/asm.cpp (original) +++ cfe/trunk/test/Analysis/copypaste/asm.cpp Sun Sep 3 22:56:36 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s // expected-no-diagnostics Modified: cfe/trunk/test/Analysis/copypaste/attributes.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/copypaste/attributes.cpp?rev=312468&r1=312467&r2=312468&view=diff == --- cfe/trunk/test/Analysis/copypaste/attributes.cpp (original) +++ cfe/trunk/test/Analysis/copypaste/attributes.cpp Sun Sep 3 22:56:36 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_analyze_cc1 -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s // expected-no-diagnostics Modified: cfe/trunk/test/Analysis/copypaste/autogenerated_automoc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/copypaste/autogenerated_automoc.cpp?rev=312468&r1=312467&r2=312468&view=diff == --- cfe/trunk/test/Analysis/copypaste/autogenerated_automoc.cpp (o
r312533 - [Bash-autocomplete] Fix crash when invoking --autocomplete without value.
Author: teemperor Date: Tue Sep 5 05:41:00 2017 New Revision: 312533 URL: http://llvm.org/viewvc/llvm-project?rev=312533&view=rev Log: [Bash-autocomplete] Fix crash when invoking --autocomplete without value. Summary: Currently clang segfaults when invoked with `clang --autocomplete=`. This patch adds the necessary boundary checks and some tests for corner cases like this. Reviewers: yamaguchi Reviewed By: yamaguchi Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D37465 Modified: cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=312533&r1=312532&r2=312533&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep 5 05:41:00 2017 @@ -1165,12 +1165,10 @@ void Driver::handleAutocompletions(Strin unsigned short DisableFlags = options::NoDriverOption | options::Unsupported | options::Ignored; // We want to show cc1-only options only when clang is invoked as "clang - // -cc1". - // When clang is invoked as "clang -cc1", we add "#" to the beginning of an - // --autocomplete - // option so that the clang driver can distinguish whether it is requested to - // show cc1-only options or not. - if (PassedFlags[0] == '#') { + // -cc1". When clang is invoked as "clang -cc1", we add "#" to the beginning + // of an --autocomplete option so that the clang driver can distinguish + // whether it is requested to show cc1-only options or not. + if (PassedFlags.size() > 0 && PassedFlags[0] == '#') { DisableFlags &= ~options::NoDriverOption; PassedFlags = PassedFlags.substr(1); } Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=312533&r1=312532&r2=312533&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Tue Sep 5 05:41:00 2017 @@ -2,6 +2,19 @@ // autocompletion. You may have to update tests in this file when you // add/modify flags, change HelpTexts or the values of some flags. +// Some corner cases. +// RUN: %clang --autocomplete= | FileCheck %s -check-prefix=ALL_FLAGS +// RUN: %clang --autocomplete=# | FileCheck %s -check-prefix=ALL_FLAGS +// Let's pick some example flags that are hopefully unlikely to change. +// ALL_FLAGS: -fast +// ALL_FLAGS: -fastcp +// ALL_FLAGS: -fastf +// Just test that this doesn't crash: +// RUN: %clang --autocomplete=, +// RUN: %clang --autocomplete== +// RUN: %clang --autocomplete=,, +// RUN: %clang --autocomplete=- + // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN // FSYN: -fsyntax-only // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313049 - Use the VFS from the CompilerInvocation by default
Author: teemperor Date: Tue Sep 12 09:54:53 2017 New Revision: 313049 URL: http://llvm.org/viewvc/llvm-project?rev=313049&view=rev Log: Use the VFS from the CompilerInvocation by default Summary: The CompilerInstance should create its default VFS from its CompilerInvocation. Right now the user has to manually create the VFS before creating the FileManager even though `-ivfsoverlay file.yaml` was passed via the CompilerInvocation (which is exactly how we worked around this issue in `FrontendAction.cpp` so far). This patch uses the invocation's VFS by default and also tests this behavior now from the point of view of a program that uses the clang API. Reviewers: benlangmuir, v.g.vassilev Reviewed By: v.g.vassilev Subscribers: mgorny, cfe-commits, v.g.vassilev Differential Revision: https://reviews.llvm.org/D37416 Added: cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Frontend/FrontendAction.cpp cfe/trunk/unittests/Frontend/CMakeLists.txt Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=313049&r1=313048&r2=313049&view=diff == --- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original) +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Tue Sep 12 09:54:53 2017 @@ -640,7 +640,9 @@ public: const CodeGenOptions *CodeGenOpts = nullptr); /// Create the file manager and replace any existing one with it. - void createFileManager(); + /// + /// \return The new file manager on success, or null on failure. + FileManager *createFileManager(); /// Create the source manager and replace any existing one with it. void createSourceManager(FileManager &FileMgr); Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=313049&r1=313048&r2=313049&view=diff == --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Sep 12 09:54:53 2017 @@ -300,12 +300,16 @@ CompilerInstance::createDiagnostics(Diag // File Manager -void CompilerInstance::createFileManager() { +FileManager *CompilerInstance::createFileManager() { if (!hasVirtualFileSystem()) { -// TODO: choose the virtual file system based on the CompilerInvocation. -setVirtualFileSystem(vfs::getRealFileSystem()); +if (IntrusiveRefCntPtr VFS = +createVFSFromCompilerInvocation(getInvocation(), getDiagnostics())) + setVirtualFileSystem(VFS); +else + return nullptr; } FileMgr = new FileManager(getFileSystemOpts(), VirtualFileSystem); + return FileMgr.get(); } // Source Manager Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=313049&r1=313048&r2=313049&view=diff == --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Tue Sep 12 09:54:53 2017 @@ -633,18 +633,12 @@ bool FrontendAction::BeginSourceFile(Com return true; } - if (!CI.hasVirtualFileSystem()) { -if (IntrusiveRefCntPtr VFS = - createVFSFromCompilerInvocation(CI.getInvocation(), - CI.getDiagnostics())) - CI.setVirtualFileSystem(VFS); -else + // Set up the file and source managers, if needed. + if (!CI.hasFileManager()) { +if (!CI.createFileManager()) { goto failure; +} } - - // Set up the file and source managers, if needed. - if (!CI.hasFileManager()) -CI.createFileManager(); if (!CI.hasSourceManager()) CI.createSourceManager(CI.getFileManager()); Modified: cfe/trunk/unittests/Frontend/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/CMakeLists.txt?rev=313049&r1=313048&r2=313049&view=diff == --- cfe/trunk/unittests/Frontend/CMakeLists.txt (original) +++ cfe/trunk/unittests/Frontend/CMakeLists.txt Tue Sep 12 09:54:53 2017 @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS add_clang_unittest(FrontendTests ASTUnitTest.cpp + CompilerInstanceTest.cpp FrontendActionTest.cpp CodeGenActionTest.cpp PCHPreambleTest.cpp Added: cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp?rev=313049&view=auto == --- cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp (added) +++
r367840 - [clang][NFC] Remove unused private variable 'CI' in CrossTranslationUnit.h
Author: teemperor Date: Mon Aug 5 05:23:39 2019 New Revision: 367840 URL: http://llvm.org/viewvc/llvm-project?rev=367840&view=rev Log: [clang][NFC] Remove unused private variable 'CI' in CrossTranslationUnit.h It seems because of the recent refactorings this variable has become unused and now we get this warning in the build logs: In file included from llvm/clang/lib/CrossTU/CrossTranslationUnit.cpp:12: llvm/clang/include/clang/CrossTU/CrossTranslationUnit.h:200:21: warning: private field 'CI' is not used [-Wunused-private-field] CompilerInstance &CI; ^ I'll remove them for now to get the builds back to green. Modified: cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Modified: cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h?rev=367840&r1=367839&r2=367840&view=diff == --- cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h (original) +++ cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h Mon Aug 5 05:23:39 2019 @@ -197,7 +197,6 @@ private: ImporterMapTy ASTUnitImporterMap; - CompilerInstance &CI; ASTContext &Context; std::shared_ptr ImporterSharedSt; /// Map of imported FileID's (in "To" context) to FileID in "From" context Modified: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp?rev=367840&r1=367839&r2=367840&view=diff == --- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp (original) +++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Mon Aug 5 05:23:39 2019 @@ -188,7 +188,7 @@ template static bool hasBod } CrossTranslationUnitContext::CrossTranslationUnitContext(CompilerInstance &CI) -: CI(CI), Context(CI.getASTContext()), ASTStorage(CI), +: Context(CI.getASTContext()), ASTStorage(CI), CTULoadThreshold(CI.getAnalyzerOpts()->CTUImportThreshold) {} CrossTranslationUnitContext::~CrossTranslationUnitContext() {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r368510 - [clang] Fixed x86 cpuid NSC signature
Author: teemperor Date: Sat Aug 10 03:14:01 2019 New Revision: 368510 URL: http://llvm.org/viewvc/llvm-project?rev=368510&view=rev Log: [clang] Fixed x86 cpuid NSC signature Summary: The signature "Geode by NSC" for NSC vendor is wrong. In lib/Headers/cpuid.h, signature_NSC_edx and signature_NSC_ecx constants are inverted (cpuid signature order is ebx # edx # ecx). Reviewers: teemperor, rsmith, craig.topper Reviewed By: teemperor, craig.topper Subscribers: craig.topper, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65978 Modified: cfe/trunk/lib/Headers/cpuid.h Modified: cfe/trunk/lib/Headers/cpuid.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/cpuid.h?rev=368510&r1=368509&r2=368510&view=diff == --- cfe/trunk/lib/Headers/cpuid.h (original) +++ cfe/trunk/lib/Headers/cpuid.h Sat Aug 10 03:14:01 2019 @@ -38,8 +38,8 @@ #define signature_TM2_ecx 0x3638784d /* NSC: "Geode by NSC" */ #define signature_NSC_ebx 0x646f6547 -#define signature_NSC_edx 0x43534e20 -#define signature_NSC_ecx 0x79622065 +#define signature_NSC_edx 0x79622065 +#define signature_NSC_ecx 0x43534e20 /* NEXGEN: "NexGenDriven" */ #define signature_NEXGEN_ebx 0x4778654e #define signature_NEXGEN_edx 0x72446e65 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r372203 - [lldb] Print better diagnostics for user expressions and modules
Author: teemperor Date: Wed Sep 18 01:53:35 2019 New Revision: 372203 URL: http://llvm.org/viewvc/llvm-project?rev=372203&view=rev Log: [lldb] Print better diagnostics for user expressions and modules Summary: Currently our expression evaluators only prints very basic errors that are not very useful when writing complex expressions. For example, in the expression below the user made a type error, but it's not clear from the diagnostic what went wrong: ``` (lldb) expr printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3) error: invalid operands to binary expression ('int' and 'double') ``` This patch enables full Clang diagnostics in our expression evaluator. After this patch the diagnostics for the expression look like this: ``` (lldb) expr printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3) error: :1:54: invalid operands to binary expression ('int' and 'float') printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3) ~~^~~~ ``` To make this possible, we now emulate a user expression file within our diagnostics. This prevents that the user is exposed to our internal wrapper code we inject. Note that the diagnostics that refer to declarations from the debug information (e.g. 'note' diagnostics pointing to a called function) will not be improved by this as they don't have any source locations associated with them, so caret or line printing isn't possible. We instead just suppress these diagnostics as we already do with warnings as they would otherwise just be a context message without any context (and the original diagnostic in the user expression should be enough to explain the issue). Fixes rdar://24306342 Reviewers: JDevlieghere, aprantl, shafik, #lldb Reviewed By: JDevlieghere, #lldb Subscribers: usaxena95, davide, jingham, aprantl, arphaman, kadircet, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D65646 Modified: cfe/trunk/include/clang/Basic/DiagnosticOptions.def cfe/trunk/lib/Frontend/TextDiagnostic.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticOptions.def?rev=372203&r1=372202&r2=372203&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticOptions.def (original) +++ cfe/trunk/include/clang/Basic/DiagnosticOptions.def Wed Sep 18 01:53:35 2019 @@ -49,6 +49,7 @@ DIAGOPT(Pedantic, 1, 0) /// -ped DIAGOPT(PedanticErrors, 1, 0) /// -pedantic-errors DIAGOPT(ShowColumn, 1, 1) /// Show column number on diagnostics. DIAGOPT(ShowLocation, 1, 1) /// Show source location information. +DIAGOPT(ShowLevel, 1, 1)/// Show diagnostic level. DIAGOPT(AbsolutePath, 1, 0) /// Use absolute paths. DIAGOPT(ShowCarets, 1, 1) /// Show carets in diagnostics. DIAGOPT(ShowFixits, 1, 1) /// Show fixit information. Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=372203&r1=372202&r2=372203&view=diff == --- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original) +++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Wed Sep 18 01:53:35 2019 @@ -683,8 +683,9 @@ void TextDiagnostic::emitDiagnosticMessa if (DiagOpts->ShowColors) OS.resetColor(); - printDiagnosticLevel(OS, Level, DiagOpts->ShowColors, - DiagOpts->CLFallbackMode); + if (DiagOpts->ShowLevel) +printDiagnosticLevel(OS, Level, DiagOpts->ShowColors, + DiagOpts->CLFallbackMode); printDiagnosticMessage(OS, /*IsSupplemental*/ Level == DiagnosticsEngine::Note, Message, OS.tell() - StartOfLocationInfo, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r373193 - [lldb][clang][modern-type-lookup] Use ASTImporterSharedState in ExternalASTMerger
Author: teemperor Date: Mon Sep 30 01:52:16 2019 New Revision: 373193 URL: http://llvm.org/viewvc/llvm-project?rev=373193&view=rev Log: [lldb][clang][modern-type-lookup] Use ASTImporterSharedState in ExternalASTMerger Summary: The ExternalASTMerger should use the ASTImporterSharedState. This allows it to handle std::pair in LLDB (but the rest of libc++ is still work in progress). Reviewers: martong, shafik, a.sidorin Subscribers: rnkovacs, christof, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68140 Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h cfe/trunk/lib/AST/ExternalASTMerger.cpp Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=373193&r1=373192&r2=373193&view=diff == --- cfe/trunk/include/clang/AST/ExternalASTMerger.h (original) +++ cfe/trunk/include/clang/AST/ExternalASTMerger.h Mon Sep 30 01:52:16 2019 @@ -14,6 +14,7 @@ #define LLVM_CLANG_AST_EXTERNALASTMERGER_H #include "clang/AST/ASTImporter.h" +#include "clang/AST/ASTImporterSharedState.h" #include "clang/AST/ExternalASTSource.h" #include "llvm/Support/raw_ostream.h" @@ -88,6 +89,11 @@ public: private: /// The target for this ExtenralASTMerger. ImporterTarget Target; + /// ExternalASTMerger has multiple ASTImporters that import into the same + /// TU. This is the shared state for all ASTImporters of this + /// ExternalASTMerger. + /// See also the CrossTranslationUnitContext that has a similar setup. + std::shared_ptr SharedState; public: ExternalASTMerger(const ImporterTarget &Target, Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=373193&r1=373192&r2=373193&view=diff == --- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original) +++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Mon Sep 30 01:52:16 2019 @@ -107,11 +107,13 @@ public: LazyASTImporter(ExternalASTMerger &_Parent, ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, - const ExternalASTMerger::OriginMap &_FromOrigins) + const ExternalASTMerger::OriginMap &_FromOrigins, + std::shared_ptr SharedState) : ASTImporter(ToContext, ToFileManager, FromContext, FromFileManager, -/*MinimalImport=*/true), +/*MinimalImport=*/true, SharedState), Parent(_Parent), Reverse(FromContext, FromFileManager, ToContext, - ToFileManager, /*MinimalImport=*/true), FromOrigins(_FromOrigins) {} + ToFileManager, /*MinimalImport=*/true), +FromOrigins(_FromOrigins) {} /// Whenever a DeclContext is imported, ensure that ExternalASTSource's origin /// map is kept up to date. Also set the appropriate flags. @@ -314,6 +316,8 @@ void ExternalASTMerger::RecordOriginImpl ExternalASTMerger::ExternalASTMerger(const ImporterTarget &Target, llvm::ArrayRef Sources) : LogStream(&llvm::nulls()), Target(Target) { + SharedState = std::make_shared( + *Target.AST.getTranslationUnitDecl()); AddSources(Sources); } @@ -321,7 +325,7 @@ void ExternalASTMerger::AddSources(llvm: for (const ImporterSource &S : Sources) { assert(&S.AST != &Target.AST); Importers.push_back(std::make_unique( -*this, Target.AST, Target.FM, S.AST, S.FM, S.OM)); +*this, Target.AST, Target.FM, S.AST, S.FM, S.OM, SharedState)); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r373312 - [clang][lldb][NFC] Encapsulate ExternalASTMerger::ImporterSource
Author: teemperor Date: Tue Oct 1 02:02:05 2019 New Revision: 373312 URL: http://llvm.org/viewvc/llvm-project?rev=373312&view=rev Log: [clang][lldb][NFC] Encapsulate ExternalASTMerger::ImporterSource NFC preparation work for upcoming ExternalASTMerger patches. Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h cfe/trunk/lib/AST/ExternalASTMerger.cpp cfe/trunk/tools/clang-import-test/clang-import-test.cpp Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=373312&r1=373311&r2=373312&view=diff == --- cfe/trunk/include/clang/AST/ExternalASTMerger.h (original) +++ cfe/trunk/include/clang/AST/ExternalASTMerger.h Tue Oct 1 02:02:05 2019 @@ -80,10 +80,17 @@ public: /// import SourceLocations properly. Additionally, when import occurs for /// a DeclContext whose origin has been overridden, then this /// ExternalASTMerger must be able to determine that. - struct ImporterSource { + class ImporterSource { ASTContext &AST; FileManager &FM; const OriginMap &OM; + + public: +ImporterSource(ASTContext &_AST, FileManager &_FM, const OriginMap &_OM) +: AST(_AST), FM(_FM), OM(_OM) {} +ASTContext &getASTContext() const { return AST; } +FileManager &getFileManager() const { return FM; } +const OriginMap &getOriginMap() const { return OM; } }; private: Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=373312&r1=373311&r2=373312&view=diff == --- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original) +++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Tue Oct 1 02:02:05 2019 @@ -105,15 +105,16 @@ private: llvm::raw_ostream &logs() { return Parent.logs(); } public: LazyASTImporter(ExternalASTMerger &_Parent, ASTContext &ToContext, - FileManager &ToFileManager, ASTContext &FromContext, - FileManager &FromFileManager, - const ExternalASTMerger::OriginMap &_FromOrigins, + FileManager &ToFileManager, + const ExternalASTMerger::ImporterSource &_Source, std::shared_ptr SharedState) - : ASTImporter(ToContext, ToFileManager, FromContext, FromFileManager, + : ASTImporter(ToContext, ToFileManager, _Source.getASTContext(), +_Source.getFileManager(), /*MinimalImport=*/true, SharedState), -Parent(_Parent), Reverse(FromContext, FromFileManager, ToContext, - ToFileManager, /*MinimalImport=*/true), -FromOrigins(_FromOrigins) {} +Parent(_Parent), +Reverse(_Source.getASTContext(), _Source.getFileManager(), ToContext, +ToFileManager, /*MinimalImport=*/true), +FromOrigins(_Source.getOriginMap()) {} /// Whenever a DeclContext is imported, ensure that ExternalASTSource's origin /// map is kept up to date. Also set the appropriate flags. @@ -323,23 +324,23 @@ ExternalASTMerger::ExternalASTMerger(con void ExternalASTMerger::AddSources(llvm::ArrayRef Sources) { for (const ImporterSource &S : Sources) { -assert(&S.AST != &Target.AST); +assert(&S.getASTContext() != &Target.AST); Importers.push_back(std::make_unique( -*this, Target.AST, Target.FM, S.AST, S.FM, S.OM, SharedState)); +*this, Target.AST, Target.FM, S, SharedState)); } } void ExternalASTMerger::RemoveSources(llvm::ArrayRef Sources) { if (LoggingEnabled()) for (const ImporterSource &S : Sources) - logs() << "(ExternalASTMerger*)" << (void*)this - << " removing source (ASTContext*)" << (void*)&S.AST + logs() << "(ExternalASTMerger*)" << (void *)this + << " removing source (ASTContext*)" << (void *)&S.getASTContext() << "\n"; Importers.erase( std::remove_if(Importers.begin(), Importers.end(), [&Sources](std::unique_ptr &Importer) -> bool { for (const ImporterSource &S : Sources) { - if (&Importer->getFromContext() == &S.AST) + if (&Importer->getFromContext() == &S.getASTContext()) return true; } return false; @@ -349,7 +350,7 @@ void ExternalASTMerger::RemoveSources(ll std::pair Origin = *OI; bool Erase = false; for (const ImporterSource &S : Sources) { - if (&S.AST == Origin.second.AST) { + if (&S.getASTContext() == Origin.second.AST) { Erase = true; break; } Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test
r373327 - [clang] Ignore builtin namespaces in test/Import/cxx-anon-namespace
Author: teemperor Date: Tue Oct 1 04:53:20 2019 New Revision: 373327 URL: http://llvm.org/viewvc/llvm-project?rev=373327&view=rev Log: [clang] Ignore builtin namespaces in test/Import/cxx-anon-namespace Some platforms (e.g. AArch64) put __va_list in the 'std' namespace which might end up being the first namespace we match in this test. Instead let the first namespace match via file name/line so that we skip the builtin namespaces. Modified: cfe/trunk/test/Import/cxx-anon-namespace/test.cpp Modified: cfe/trunk/test/Import/cxx-anon-namespace/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-anon-namespace/test.cpp?rev=373327&r1=373326&r2=373327&view=diff == --- cfe/trunk/test/Import/cxx-anon-namespace/test.cpp (original) +++ cfe/trunk/test/Import/cxx-anon-namespace/test.cpp Tue Oct 1 04:53:20 2019 @@ -2,9 +2,13 @@ // The implicit UsingDirectiveDecls for the anonymous namespaces are created by the Sema. -// CHECK: NamespaceDecl +// There might be another builtin namespace before our first namespace, so we can't +// just look for NamespaceDecl. Instead look for the first line of F.cpp (which only +// contains the namespace we are looking for but no other decl). +// CHECK: F.cpp:1:1 // The nested anonymous namespace. // CHECK-NEXT: NamespaceDecl +// CHECK-SAME: // CHECK: FunctionDecl // CHECK-SAME: func4 // CHECK-NEXT: CompoundStmt ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r373577 - [clang][NFC] Fix misspellings in ExternalASTMerger.h
Author: teemperor Date: Thu Oct 3 02:55:13 2019 New Revision: 373577 URL: http://llvm.org/viewvc/llvm-project?rev=373577&view=rev Log: [clang][NFC] Fix misspellings in ExternalASTMerger.h Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=373577&r1=373576&r2=373577&view=diff == --- cfe/trunk/include/clang/AST/ExternalASTMerger.h (original) +++ cfe/trunk/include/clang/AST/ExternalASTMerger.h Thu Oct 3 02:55:13 2019 @@ -23,7 +23,7 @@ namespace clang { /// ExternalASTSource implementation that merges information from several /// ASTContexts. /// -/// ExtermalASTMerger maintains a vector of ASTImporters that it uses to import +/// ExternalASTMerger maintains a vector of ASTImporters that it uses to import /// (potentially incomplete) Decls and DeclContexts from the source ASTContexts /// in response to ExternalASTSource API calls. /// @@ -37,7 +37,7 @@ namespace clang { /// lookup. In this case, Origins contains an entry overriding lookup and /// specifying the correct pair of DeclContext/ASTContext. /// -/// - The DeclContext of origin was determined by another ExterenalASTMerger. +/// - The DeclContext of origin was determined by another ExternalASTMerger. /// (This is possible when the source ASTContext for one of the Importers has /// its own ExternalASTMerger). The origin must be properly forwarded in this /// case. @@ -94,7 +94,7 @@ public: }; private: - /// The target for this ExtenralASTMerger. + /// The target for this ExternalASTMerger. ImporterTarget Target; /// ExternalASTMerger has multiple ASTImporters that import into the same /// TU. This is the shared state for all ASTImporters of this @@ -158,7 +158,7 @@ public: /// OriginContext. bool HasImporterForOrigin(ASTContext &OriginContext); - /// Returns a reference to the ASTRImporter from Importers whose origin + /// Returns a reference to the ASTImporter from Importers whose origin /// is OriginContext. This allows manual import of ASTs while preserving the /// OriginMap correctly. ASTImporter &ImporterForOrigin(ASTContext &OriginContext); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r373711 - [lldb][modern-type-lookup] No longer import temporary declarations into the persistent AST
Author: teemperor Date: Fri Oct 4 01:26:17 2019 New Revision: 373711 URL: http://llvm.org/viewvc/llvm-project?rev=373711&view=rev Log: [lldb][modern-type-lookup] No longer import temporary declarations into the persistent AST Summary: As we figured out in D67803, importing declarations from a temporary ASTContext that were originally from a persistent ASTContext causes a bunch of duplicated declarations where we end up having declarations in the target AST that have no associated ASTImporter that can complete them. I haven't figured out how/if we can solve this in the current way we do things in LLDB, but in the modern-type-lookup this is solvable as we have a saner architecture with the ExternalASTMerger. As we can (hopefully) make modern-type-lookup the default mode in the future, I would say we try fixing this issue here. As we don't use the hack that was reinstated in D67803 during modern-type-lookup, the test case for this is essentially just printing any kind of container in `std::` as we would otherwise run into the issue that required a hack like D67803. What this patch is doing in essence is that instead of importing a declaration from a temporary ASTContext, we instead check if the declaration originally came from a persistent ASTContext (e.g. the debug information) and we directly import from there. The ExternalASTMerger is already connected with ASTImporters to these different sources, so this patch is essentially just two parts: 1. Mark our temporary ASTContext/ImporterSource as temporary when we import from the expression AST. 2. If the ExternalASTMerger sees we import from the expression AST, instead of trying to import these temporary declarations, check if we can instead import from the persistent ASTContext that is already connected. This ensures that all records from the persistent source actually come from the persistent source and are minimally imported in a way that allows them to be completed later on in the target AST. The next step is to run the ASTImporter for these temporary expressions with the MinimalImport mode disabled, but that's a follow up patch. This patch fixes most test failures with modern-type-lookup enabled by default (down to 73 failing tests, which includes the 22 import-std-module tests which need special treatment). Reviewers: shafik, martong Reviewed By: martong Subscribers: aprantl, rnkovacs, christof, abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68326 Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h cfe/trunk/lib/AST/ExternalASTMerger.cpp Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=373711&r1=373710&r2=373711&view=diff == --- cfe/trunk/include/clang/AST/ExternalASTMerger.h (original) +++ cfe/trunk/include/clang/AST/ExternalASTMerger.h Fri Oct 4 01:26:17 2019 @@ -84,13 +84,22 @@ public: ASTContext &AST; FileManager &FM; const OriginMap &OM; +/// True iff the source only exists temporary, i.e., it will be removed from +/// the ExternalASTMerger during the life time of the ExternalASTMerger. +bool Temporary; +/// If the ASTContext of this source has an ExternalASTMerger that imports +/// into this source, then this will point to that other ExternalASTMerger. +ExternalASTMerger *Merger; public: -ImporterSource(ASTContext &_AST, FileManager &_FM, const OriginMap &_OM) -: AST(_AST), FM(_FM), OM(_OM) {} +ImporterSource(ASTContext &AST, FileManager &FM, const OriginMap &OM, + bool Temporary = false, ExternalASTMerger *Merger = nullptr) +: AST(AST), FM(FM), OM(OM), Temporary(Temporary), Merger(Merger) {} ASTContext &getASTContext() const { return AST; } FileManager &getFileManager() const { return FM; } const OriginMap &getOriginMap() const { return OM; } +bool isTemporary() const { return Temporary; } +ExternalASTMerger *getMerger() const { return Merger; } }; private: @@ -106,6 +115,12 @@ public: ExternalASTMerger(const ImporterTarget &Target, llvm::ArrayRef Sources); + /// Asks all connected ASTImporters if any of them imported the given + /// declaration. If any ASTImporter did import the given declaration, + /// then this function returns the declaration that D was imported from. + /// Returns nullptr if no ASTImporter did import import D. + Decl *FindOriginalDecl(Decl *D); + /// Add a set of ASTContexts as possible origins. /// /// Usually the set will be initialized in the constructor, but long-lived Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=373711&r1=373710&r2=373711&view=diff ===
r331021 - Make MultiplexASTDeserializationListener part of the API [NFC]
Author: teemperor Date: Fri Apr 27 00:05:40 2018 New Revision: 331021 URL: http://llvm.org/viewvc/llvm-project?rev=331021&view=rev Log: Make MultiplexASTDeserializationListener part of the API [NFC] Summary: This patch moves the MultiplexASTDeserializationListener declaration into a public header. We're currently using this multiplexer in the cling interpreter to attach another ASTDeserializationListener during the execution (so, after the MultiplexConsumer is already attached which prevents us from attaching more). So far we're doing this by patching clang and making this class public, but it makes things easier if we make this instead just public in upstream. Reviewers: thakis, v.g.vassilev, rsmith, bruno Reviewed By: bruno Subscribers: llvm-commits, cfe-commits, v.g.vassilev Differential Revision: https://reviews.llvm.org/D37475 Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h cfe/trunk/lib/Frontend/MultiplexConsumer.cpp Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/MultiplexConsumer.h?rev=331021&r1=331020&r2=331021&view=diff == --- cfe/trunk/include/clang/Frontend/MultiplexConsumer.h (original) +++ cfe/trunk/include/clang/Frontend/MultiplexConsumer.h Fri Apr 27 00:05:40 2018 @@ -17,13 +17,34 @@ #include "clang/Basic/LLVM.h" #include "clang/Sema/SemaConsumer.h" +#include "clang/Serialization/ASTDeserializationListener.h" #include #include namespace clang { class MultiplexASTMutationListener; -class MultiplexASTDeserializationListener; + +// This ASTDeserializationListener forwards its notifications to a set of +// child listeners. +class MultiplexASTDeserializationListener : public ASTDeserializationListener { +public: + // Does NOT take ownership of the elements in L. + MultiplexASTDeserializationListener( + const std::vector &L); + void ReaderInitialized(ASTReader *Reader) override; + void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override; + void MacroRead(serialization::MacroID ID, MacroInfo *MI) override; + void TypeRead(serialization::TypeIdx Idx, QualType T) override; + void DeclRead(serialization::DeclID ID, const Decl *D) override; + void SelectorRead(serialization::SelectorID iD, Selector Sel) override; + void MacroDefinitionRead(serialization::PreprocessedEntityID, + MacroDefinitionRecord *MD) override; + void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override; + +private: + std::vector Listeners; +}; // Has a list of ASTConsumers and calls each of them. Owns its children. class MultiplexConsumer : public SemaConsumer { Modified: cfe/trunk/lib/Frontend/MultiplexConsumer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/MultiplexConsumer.cpp?rev=331021&r1=331020&r2=331021&view=diff == --- cfe/trunk/lib/Frontend/MultiplexConsumer.cpp (original) +++ cfe/trunk/lib/Frontend/MultiplexConsumer.cpp Fri Apr 27 00:05:40 2018 @@ -16,35 +16,11 @@ #include "clang/Frontend/MultiplexConsumer.h" #include "clang/AST/ASTMutationListener.h" #include "clang/AST/DeclGroup.h" -#include "clang/Serialization/ASTDeserializationListener.h" using namespace clang; namespace clang { -// This ASTDeserializationListener forwards its notifications to a set of -// child listeners. -class MultiplexASTDeserializationListener -: public ASTDeserializationListener { -public: - // Does NOT take ownership of the elements in L. - MultiplexASTDeserializationListener( - const std::vector& L); - void ReaderInitialized(ASTReader *Reader) override; - void IdentifierRead(serialization::IdentID ID, - IdentifierInfo *II) override; - void MacroRead(serialization::MacroID ID, MacroInfo *MI) override; - void TypeRead(serialization::TypeIdx Idx, QualType T) override; - void DeclRead(serialization::DeclID ID, const Decl *D) override; - void SelectorRead(serialization::SelectorID iD, Selector Sel) override; - void MacroDefinitionRead(serialization::PreprocessedEntityID, - MacroDefinitionRecord *MD) override; - void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override; - -private: - std::vector Listeners; -}; - MultiplexASTDeserializationListener::MultiplexASTDeserializationListener( const std::vector& L) : Listeners(L) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ad7211d - [clang] fix undefined behaviour in RawComment::getFormattedText()
Author: Oliver Bruns Date: 2020-04-06T10:48:25+02:00 New Revision: ad7211df6f257e39da2e5a11b2456b4488f32a1e URL: https://github.com/llvm/llvm-project/commit/ad7211df6f257e39da2e5a11b2456b4488f32a1e DIFF: https://github.com/llvm/llvm-project/commit/ad7211df6f257e39da2e5a11b2456b4488f32a1e.diff LOG: [clang] fix undefined behaviour in RawComment::getFormattedText() Summary: Calling `back()` and `pop_back()` on the empty string is undefined behavior [1,2]. The issue manifested itself as an uncaught `std::out_of_range` exception when running `clangd` compiled on RHEL7 using devtoolset-9. [1] https://en.cppreference.com/w/cpp/string/basic_string/back [2] https://en.cppreference.com/w/cpp/string/basic_string/pop_back Fixes: 1ff7c32fc91c607b690d4bb9cf42f406be8dde68 Reviewers: teemperor, ioeric, cfe-commits Reviewed By: teemperor Subscribers: ilya-biryukov, kadircet, usaxena95 Tags: #clang Differential Revision: https://reviews.llvm.org/D77468 Added: Modified: clang/lib/AST/RawCommentList.cpp Removed: diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp index 8552b4fcd2b3..a8d15036cab9 100644 --- a/clang/lib/AST/RawCommentList.cpp +++ b/clang/lib/AST/RawCommentList.cpp @@ -431,7 +431,7 @@ std::string RawComment::getFormattedText(const SourceManager &SourceMgr, }; auto DropTrailingNewLines = [](std::string &Str) { -while (Str.back() == '\n') +while (!Str.empty() && Str.back() == '\n') Str.pop_back(); }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7308e14 - [clang] Fix modules build after D82585
Author: Raphael Isemann Date: 2020-07-06T17:51:53+02:00 New Revision: 7308e1432624f02d4e652ffa70e40d0eaa89fdb3 URL: https://github.com/llvm/llvm-project/commit/7308e1432624f02d4e652ffa70e40d0eaa89fdb3 DIFF: https://github.com/llvm/llvm-project/commit/7308e1432624f02d4e652ffa70e40d0eaa89fdb3.diff LOG: [clang] Fix modules build after D82585 Just getting the bots running again. See the D82585 for more info. Added: Modified: clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp Removed: diff --git a/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h b/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h index e7a7671a7576..43248d8e6bb8 100644 --- a/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h +++ b/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h @@ -76,7 +76,7 @@ struct CmdLineOption { "Invalid development status!"); } - LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void dump() const; LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const; }; @@ -135,7 +135,7 @@ struct CheckerInfo { // Used for lower_bound. explicit CheckerInfo(StringRef FullName) : FullName(FullName) {} - LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void dump() const; LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const; }; @@ -155,7 +155,7 @@ struct PackageInfo { explicit PackageInfo(StringRef FullName) : FullName(FullName) {} - LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void dump() const; LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const; }; diff --git a/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp b/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp index 7d5bfb2f9cdb..1b3e8b11549d 100644 --- a/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp +++ b/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp @@ -18,6 +18,10 @@ using namespace ento; // Methods of CmdLineOption, PackageInfo and CheckerInfo. //===--===// +LLVM_DUMP_METHOD void CmdLineOption::dump() const { + dumpToStream(llvm::errs()); +} + LLVM_DUMP_METHOD void CmdLineOption::dumpToStream(llvm::raw_ostream &Out) const { // The description can be just checked in Checkers.inc, the point here is to @@ -39,6 +43,8 @@ static StringRef toString(StateFromCmdLine Kind) { llvm_unreachable("Unhandled StateFromCmdLine enum"); } +LLVM_DUMP_METHOD void CheckerInfo::dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const { // The description can be just checked in Checkers.inc, the point here is to // debug whether we succeeded in parsing it. Same with documentation uri. @@ -60,6 +66,8 @@ LLVM_DUMP_METHOD void CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const { } } +LLVM_DUMP_METHOD void PackageInfo::dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void PackageInfo::dumpToStream(llvm::raw_ostream &Out) const { Out << FullName << "\n"; Out << " Options:\n"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 9f1e81f - [ASTImporter] Also import overwritten file buffers
Author: Raphael Isemann Date: 2020-04-27T13:16:08+02:00 New Revision: 9f1e81f1c0ac40f81e2f398148f09d1852226240 URL: https://github.com/llvm/llvm-project/commit/9f1e81f1c0ac40f81e2f398148f09d1852226240 DIFF: https://github.com/llvm/llvm-project/commit/9f1e81f1c0ac40f81e2f398148f09d1852226240.diff LOG: [ASTImporter] Also import overwritten file buffers Summary: Overwritten file buffers are at the moment ignored when importing and instead only the underlying file buffer is imported. This patch fixes this by not going to the underlying file entry if the file has an overwritten buffer. Reviewers: martong, a.sidorin, shafik Reviewed By: martong, shafik Subscribers: rnkovacs Differential Revision: https://reviews.llvm.org/D78086 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index ecb5ce85c204..477c035d8a59 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -8560,7 +8560,7 @@ Expected ASTImporter::Import(FileID FromID, bool IsBuiltin) { } else { const SrcMgr::ContentCache *Cache = FromSLoc.getFile().getContentCache(); -if (!IsBuiltin) { +if (!IsBuiltin && !Cache->BufferOverridden) { // Include location of this file. ExpectedSLoc ToIncludeLoc = Import(FromSLoc.getFile().getIncludeLoc()); if (!ToIncludeLoc) diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 8ed6c487cb53..a390b49d1641 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -12,6 +12,7 @@ #include "clang/ASTMatchers/ASTMatchers.h" #include "llvm/ADT/StringMap.h" +#include "llvm/Support/SmallVectorMemoryBuffer.h" #include "clang/AST/DeclContextInternals.h" #include "gtest/gtest.h" @@ -5896,6 +5897,61 @@ TEST_P(ImportSourceLocations, PreserveFileIDTreeStructure) { EXPECT_FALSE(ToSM.isBeforeInTranslationUnit(Location2, Location1)); } +TEST_P(ImportSourceLocations, NormalFileBuffer) { + // Test importing normal file buffers. + + std::string Path = "input0.c"; + std::string Source = "int X;"; + TranslationUnitDecl *FromTU = getTuDecl(Source, Lang_C, Path); + + SourceLocation ImportedLoc; + { +// Import the VarDecl to trigger the importing of the FileID. +auto Pattern = varDecl(hasName("X")); +VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern); +ImportedLoc = Import(FromD, Lang_C)->getLocation(); + } + + // Make sure the imported buffer has the original contents. + SourceManager &ToSM = ToAST->getSourceManager(); + FileID ImportedID = ToSM.getFileID(ImportedLoc); + EXPECT_EQ(Source, ToSM.getBuffer(ImportedID, SourceLocation())->getBuffer()); +} + +TEST_P(ImportSourceLocations, OverwrittenFileBuffer) { + // Test importing overwritten file buffers. + + std::string Path = "input0.c"; + TranslationUnitDecl *FromTU = getTuDecl("int X;", Lang_C, Path); + + // Overwrite the file buffer for our input file with new content. + const std::string Contents = "overwritten contents"; + SourceLocation ImportedLoc; + { +SourceManager &FromSM = FromTU->getASTContext().getSourceManager(); +clang::FileManager &FM = FromSM.getFileManager(); +const clang::FileEntry &FE = +*FM.getVirtualFile(Path, static_cast(Contents.size()), 0); + +llvm::SmallVector Buffer; +Buffer.append(Contents.begin(), Contents.end()); +auto FileContents = +std::make_unique(std::move(Buffer), Path); +FromSM.overrideFileContents(&FE, std::move(FileContents)); + +// Import the VarDecl to trigger the importing of the FileID. +auto Pattern = varDecl(hasName("X")); +VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern); +ImportedLoc = Import(FromD, Lang_C)->getLocation(); + } + + // Make sure the imported buffer has the overwritten contents. + SourceManager &ToSM = ToAST->getSourceManager(); + FileID ImportedID = ToSM.getFileID(ImportedLoc); + EXPECT_EQ(Contents, +ToSM.getBuffer(ImportedID, SourceLocation())->getBuffer()); +} + TEST_P(ASTImporterOptionSpecificTestBase, ImportExprOfAlignmentAttr) { // Test if import of these packed and aligned attributes does not trigger an // error situation where source location from 'From' context is referenced in ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f181f1b - [clang] Remove NFC overload in ASTImporterTest
Author: Raphael Isemann Date: 2020-04-27T14:10:43+02:00 New Revision: f181f1b7f73e643fb5d10a6d07832c1a2fb34c0b URL: https://github.com/llvm/llvm-project/commit/f181f1b7f73e643fb5d10a6d07832c1a2fb34c0b DIFF: https://github.com/llvm/llvm-project/commit/f181f1b7f73e643fb5d10a6d07832c1a2fb34c0b.diff LOG: [clang] Remove NFC overload in ASTImporterTest This overload is just an artifact from the original version of the patch, but doesn't have any functional purpose. Added: Modified: clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index a390b49d1641..36003957d2e1 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -6023,10 +6023,6 @@ struct SourceWithCompletedTagList : clang::ExternalASTSource { Record->completeDefinition(); CompletedTags.push_back(Tag); } - void - FindExternalLexicalDecls(const DeclContext *DC, - llvm::function_ref IsKindWeWant, - SmallVectorImpl &Result) override {} }; TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 442a802 - [clang] Don't make synthesized accessor stub functions visible twice
Author: Raphael Isemann Date: 2020-08-11T16:23:51+02:00 New Revision: 442a80292d50d895396eb14418bd471e7da68fd0 URL: https://github.com/llvm/llvm-project/commit/442a80292d50d895396eb14418bd471e7da68fd0 DIFF: https://github.com/llvm/llvm-project/commit/442a80292d50d895396eb14418bd471e7da68fd0.diff LOG: [clang] Don't make synthesized accessor stub functions visible twice `addDecl` is making the Decl visible, so there is no need to make it explicitly visible again. Making it visible twice will also make the lookup storage less efficient and potentially lead to crashes, see D84827 for that. Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D84828 Added: Modified: clang/lib/Sema/SemaDeclObjC.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index d376880a40e8..89815b838500 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -3922,15 +3922,11 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef allMethods, if (auto *OID = dyn_cast(CurContext)) { for (auto PropImpl : OID->property_impls()) { if (auto *Getter = PropImpl->getGetterMethodDecl()) -if (Getter->isSynthesizedAccessorStub()) { - OID->makeDeclVisibleInContext(Getter); +if (Getter->isSynthesizedAccessorStub()) OID->addDecl(Getter); -} if (auto *Setter = PropImpl->getSetterMethodDecl()) -if (Setter->isSynthesizedAccessorStub()) { - OID->makeDeclVisibleInContext(Setter); +if (Setter->isSynthesizedAccessorStub()) OID->addDecl(Setter); -} } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 02899d7 - [clang] Don't make ObjCIvarDecl visible twice when adding them to an implicit ObjCInterfaceDecl
Author: Raphael Isemann Date: 2020-08-11T16:24:32+02:00 New Revision: 02899d7f1b9ae7f6da30bd020a714c7b3eb2c59f URL: https://github.com/llvm/llvm-project/commit/02899d7f1b9ae7f6da30bd020a714c7b3eb2c59f DIFF: https://github.com/llvm/llvm-project/commit/02899d7f1b9ae7f6da30bd020a714c7b3eb2c59f.diff LOG: [clang] Don't make ObjCIvarDecl visible twice when adding them to an implicit ObjCInterfaceDecl `addDecl` is making the ivar visible in its primary context. The primary context of the ivar here is in a 'fragile' ABI the ObjCInterfaceDecl and in a 'non-fragile' ABI the current ObjCImplementationDecl. The additional call to `makeDeclVisibleInContext` to make the ivar visible in the ObjCInterfaceDecl is only necessary in the 'non-fragile' case (as in the 'fragile' case the Decl becomes automatically visible in the ObjCInterfaceDecl with the `addDecl` call as thats its primary context). See `Sema::ActOnIvar` for where the ivar is put into a different context depending on the ABI. To put this into an example: ``` lang=c++ @implementation SomeClass { id ivar1; } @end fragile case: implicit ObjCInterfaceDecl 'SomeClass' `- ivar1 (in primary context and will be automatically made visible) ObjCImplementationDecl 'SomeClass' non-fragile case: implicit ObjCInterfaceDecl 'SomeClass' `-<<>> ObjCImplementationDecl 'SomeClass' `- ivar1 (in its primary context and will be automatically made visible here) ``` Making a Decl visible multiple times in the same context is inefficient and potentially can lead to crashes. See D84827 for more info and what this is breaking. Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D84829 Added: Modified: clang/lib/Sema/SemaDeclObjC.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 89815b838500..6ef6fd1d8c1c 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -2122,7 +2122,12 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, // Add ivar's to class's DeclContext. for (unsigned i = 0, e = numIvars; i != e; ++i) { ivars[i]->setLexicalDeclContext(ImpDecl); - IDecl->makeDeclVisibleInContext(ivars[i]); + // In a 'fragile' runtime the ivar was added to the implicit + // ObjCInterfaceDecl while in a 'non-fragile' runtime the ivar is + // only in the ObjCImplementationDecl. In the non-fragile case the ivar + // therefore also needs to be propagated to the ObjCInterfaceDecl. + if (!LangOpts.ObjCRuntime.isFragile()) +IDecl->makeDeclVisibleInContext(ivars[i]); ImpDecl->addDecl(ivars[i]); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c0bcd11 - [ASTImporter] Add basic support for comparing Stmts and compare function bodies
Author: Raphael Isemann Date: 2020-09-13T18:25:04+02:00 New Revision: c0bcd11068fc13e45b253c6c315882097f94c121 URL: https://github.com/llvm/llvm-project/commit/c0bcd11068fc13e45b253c6c315882097f94c121 DIFF: https://github.com/llvm/llvm-project/commit/c0bcd11068fc13e45b253c6c315882097f94c121.diff LOG: [ASTImporter] Add basic support for comparing Stmts and compare function bodies Right now the ASTImporter assumes for most Expr nodes that they are always equal which leads to non-compatible declarations ending up being merged. This patch adds the basic framework for comparing Stmts (and with that also Exprs) and implements the custom checks for a few Stmt subclasses. I'll implement the remaining subclasses in follow up patches (mostly because there are a lot of subclasses and some of them require further changes like having GNU language in the testing framework) The motivation for this is that in LLDB we try to import libc++ source code and some of the types we are importing there contain expressions (e.g. because they use `enable_if`), so those declarations are currently merged even if they are completely different (e.g. `enable_if ...` and `enable_if ...` are currently considered equal which is clearly not true). Reviewed By: martong, balazske Differential Revision: https://reviews.llvm.org/D87444 Added: Modified: clang/include/clang/AST/ASTStructuralEquivalence.h clang/lib/AST/ASTStructuralEquivalence.cpp clang/unittests/AST/StructuralEquivalenceTest.cpp Removed: diff --git a/clang/include/clang/AST/ASTStructuralEquivalence.h b/clang/include/clang/AST/ASTStructuralEquivalence.h index 36a42070fd28..c958a16aba21 100644 --- a/clang/include/clang/AST/ASTStructuralEquivalence.h +++ b/clang/include/clang/AST/ASTStructuralEquivalence.h @@ -97,6 +97,13 @@ struct StructuralEquivalenceContext { /// \c VisitedDecls members) and can cause faulty equivalent results. bool IsEquivalent(QualType T1, QualType T2); + /// Determine whether the two statements are structurally equivalent. + /// Implementation functions (all static functions in + /// ASTStructuralEquivalence.cpp) must never call this function because that + /// will wreak havoc the internal state (\c DeclsToCheck and + /// \c VisitedDecls members) and can cause faulty equivalent results. + bool IsEquivalent(Stmt *S1, Stmt *S2); + /// Find the index of the given anonymous struct/union within its /// context. /// diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp index 8b5b2444f1e2..fafcfce269d7 100644 --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/clang/lib/AST/ASTStructuralEquivalence.cpp @@ -68,7 +68,12 @@ #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/ExprConcepts.h" +#include "clang/AST/ExprObjC.h" +#include "clang/AST/ExprOpenMP.h" #include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/StmtObjC.h" +#include "clang/AST/StmtOpenMP.h" #include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" @@ -149,32 +154,230 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return true; } -/// Determine structural equivalence of two expressions. -static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, - const Expr *E1, const Expr *E2) { - if (!E1 || !E2) -return E1 == E2; +namespace { +/// Encapsulates Stmt comparison logic. +class StmtComparer { + StructuralEquivalenceContext &Context; + + // IsStmtEquivalent overloads. Each overload compares a specific statement + // and only has to compare the data that is specific to the specific statement + // class. Should only be called from TraverseStmt. + + bool IsStmtEquivalent(const AddrLabelExpr *E1, const AddrLabelExpr *E2) { +return IsStructurallyEquivalent(Context, E1->getLabel(), E2->getLabel()); + } + + bool IsStmtEquivalent(const AtomicExpr *E1, const AtomicExpr *E2) { +return E1->getOp() == E2->getOp(); + } + + bool IsStmtEquivalent(const BinaryOperator *E1, const BinaryOperator *E2) { +return E1->getOpcode() == E2->getOpcode(); + } - if (auto *DE1 = dyn_cast(E1)) { -auto *DE2 = dyn_cast(E2); -if (!DE2) + bool IsStmtEquivalent(const CallExpr *E1, const CallExpr *E2) { +// FIXME: IsStructurallyEquivalent requires non-const Decls. +Decl *Callee1 = const_cast(E1->getCalleeDecl()); +Decl *Callee2 = const_cast(E2->getCalleeDecl()); + +// Compare whether both calls know their callee. +if (static_cast(Callee1) != static_cast(Callee2)) return false; + +// Both calls have no callee, so nothing to do. +if (!static_cast(Callee1)) + return true; + +assert(Callee2); +return IsStructurallyEquivalent(Context, Callee1, Callee2);
[clang] 7c4575e - [ASTImporter] Refactor IsStructurallyEquivalent's Decl overloads to be more consistent
Author: Raphael Isemann Date: 2020-09-21T16:41:00+02:00 New Revision: 7c4575e15f065312ad40ebe0d1ec1e1ffa4c6628 URL: https://github.com/llvm/llvm-project/commit/7c4575e15f065312ad40ebe0d1ec1e1ffa4c6628 DIFF: https://github.com/llvm/llvm-project/commit/7c4575e15f065312ad40ebe0d1ec1e1ffa4c6628.diff LOG: [ASTImporter] Refactor IsStructurallyEquivalent's Decl overloads to be more consistent There are several `::IsStructurallyEquivalent` overloads for Decl subclasses that are used for comparing declarations. There is also one overload that takes just two Decl pointers which ends up queuing the passed Decls to be later compared in `CheckKindSpecificEquivalence`. `CheckKindSpecificEquivalence` implements the dispatch logic for the different Decl subclasses. It is supposed to hand over the queued Decls to the subclass-specific `::IsStructurallyEquivalent` overload that will actually compare the Decl instance. It also seems to implement a few pieces of actual node comparison logic inbetween the dispatch code. This implementation causes that the different overloads of `::IsStructurallyEquivalent` do different (and sometimes no) comparisons depending on which overload of `::IsStructurallyEquivalent` ends up being called. For example, if I want to compare two FieldDecl instances, then I could either call the `::IsStructurallyEquivalent` with `Decl *` or with `FieldDecl *` parameters. The overload that takes FieldDecls is doing a correct comparison. However, the `Decl *` overload just queues the Decl pair. `CheckKindSpecificEquivalence` has no dispatch logic for `FieldDecl`, so it always returns true and never does any actual comparison. On the other hand, if I try to compare two FunctionDecl instances the two possible overloads of `::IsStructurallyEquivalent` have the opposite behaviour: The overload that takes `FunctionDecl` pointers isn't comparing the names of the FunctionDecls while the overload taking a plain `Decl` ends up comparing the function names (as the comparison logic for that is implemented in `CheckKindSpecificEquivalence`). This patch tries to make this set of functions more consistent by making `CheckKindSpecificEquivalence` a pure dispatch function without any subclass-specific comparison logic. Also the dispatch logic is now autogenerated so it can no longer miss certain subclasses. The comparison code from `CheckKindSpecificEquivalence` is moved to the respective `::IsStructurallyEquivalent` overload so that the comparison result no longer depends if one calls the `Decl *` overload or the overload for the specific subclass. The only difference is now that the `Decl *` overload is queuing the parameter while the subclass-specific overload is directly doing the comparison. `::IsStructurallyEquivalent` is an implementation detail and I don't think the behaviour causes any bugs in the current implementation (as carefully calling the right overload for the different classes works around the issue), so the test for this change is that I added some new code for comparing `MemberExpr`. The new comparison code always calls the dispatching overload and it previously failed as the dispatch didn't support FieldDecls. Reviewed By: martong, a_sidorin Differential Revision: https://reviews.llvm.org/D87619 Added: Modified: clang/lib/AST/ASTStructuralEquivalence.cpp clang/unittests/AST/StructuralEquivalenceTest.cpp Removed: diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp index fafcfce269d7..98e1b7eeb8c4 100644 --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/clang/lib/AST/ASTStructuralEquivalence.cpp @@ -66,6 +66,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/DeclOpenMP.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprConcepts.h" @@ -242,6 +243,11 @@ class StmtComparer { return E1->getValue() == E2->getValue(); } + bool IsStmtEquivalent(const MemberExpr *E1, const MemberExpr *E2) { +return IsStructurallyEquivalent(Context, E1->getFoundDecl(), +E2->getFoundDecl()); + } + bool IsStmtEquivalent(const ObjCStringLiteral *E1, const ObjCStringLiteral *E2) { // Just wraps a StringLiteral child. @@ -1364,6 +1370,17 @@ IsStructurallyEquivalentLambdas(StructuralEquivalenceContext &Context, /// Determine structural equivalence of two records. static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, RecordDecl *D1, RecordDecl *D2) { + + // Check for equivalent structure names. + IdentifierInfo *Name1 = D1->getIdentifier(); + if (!Name1 && D1->getTypedefNameForAnonDecl()) +Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier(); + IdentifierInfo *Name2 = D2->getIdentifier(
[clang] adf0b8c - Revert "[compiler-rt] Compile assembly files as ASM not C"
Author: Raphael Isemann Date: 2020-08-20T15:25:22+02:00 New Revision: adf0b8cc70325f027d202139e3ff984c41896b57 URL: https://github.com/llvm/llvm-project/commit/adf0b8cc70325f027d202139e3ff984c41896b57 DIFF: https://github.com/llvm/llvm-project/commit/adf0b8cc70325f027d202139e3ff984c41896b57.diff LOG: Revert "[compiler-rt] Compile assembly files as ASM not C" This reverts commit d58fd4e52197d55bf42ca446c8b0ed31b5c2ec1f. This broke compiler-rt compilation on macOS: codesign --sign - /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lib/clang/12.0.99/lib/darwin/libclang_rt.tsan_ios_dynamic.dylib ld: warning: ignoring file projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan_ios_dynamic.dir/rtl/tsan_rtl_amd64.S.o, building for iOS-arm64 but attempting to link with file built for iOS Simulator-x86_64 ld: warning: ignoring file projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan_ios_dynamic.dir/rtl/tsan_rtl_aarch64.S.o, building for iOS-arm64 but attempting to link with file built for iOS Simulator-x86_64 Undefined symbols for architecture arm64: "_wrap__setjmp", referenced from: substitution__setjmp in tsan_interceptors_posix.cpp.o "_wrap_setjmp", referenced from: substitution_setjmp in tsan_interceptors_posix.cpp.o "_wrap_sigsetjmp", referenced from: substitution_sigsetjmp in tsan_interceptors_posix.cpp.o ld: symbol(s) not found for architecture arm64 Added: Modified: clang/runtime/CMakeLists.txt compiler-rt/cmake/Modules/AddCompilerRT.cmake Removed: diff --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt index 61bbbf8faedd..e20cc26f60af 100644 --- a/clang/runtime/CMakeLists.txt +++ b/clang/runtime/CMakeLists.txt @@ -75,7 +75,6 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/) CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS} -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++ - -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index 7063cf89d7ab..efb660818270 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -109,11 +109,13 @@ endfunction() function(add_asm_sources output) set(${output} ${ARGN} PARENT_SCOPE) - # Make sure ASM language is available. - # We explicitly mark the source files as ASM, so they don't get passed to the - # C/CXX compiler and hopes that it recognizes them as assembly. - enable_language(ASM) - set_source_files_properties(${ARGN} PROPERTIES LANGUAGE ASM) + # Xcode will try to compile asm files as C ('clang -x c'), and that will fail. + if (${CMAKE_GENERATOR} STREQUAL "Xcode") +enable_language(ASM) + else() +# Pass ASM file directly to the C++ compiler. +set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C) + endif() endfunction() macro(set_output_name output name arch) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a4c3ed4 - Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)
Author: Raphael Isemann Date: 2020-08-21T15:05:02+02:00 New Revision: a4c3ed42ba5625af54254584d762ebf96cc06942 URL: https://github.com/llvm/llvm-project/commit/a4c3ed42ba5625af54254584d762ebf96cc06942 DIFF: https://github.com/llvm/llvm-project/commit/a4c3ed42ba5625af54254584d762ebf96cc06942.diff LOG: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347) D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5 uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations that creates the dwoID in the module from the ASTFileSignature (`Buffer->Signature` being the array subclass that is now `std::array` instead of `std::array`). ``` uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] ``` This code works with the old ASTFileSignature (where two uint32_t are enough to fill the uint64_t), but after the patch this only took two bytes from the ASTFileSignature and only partly filled the Signature uint64_t. This caused that the dwoID in the module ref and the dwoID in the actual module no longer match (which in turns causes that LLDB keeps warning about the dwoID's not matching when debugging -gmodules-compiled binaries). This patch just unifies the logic for turning the ASTFileSignature into an uint64_t which makes the dwoID match again (and should prevent issues like that in the future). Reviewed By: aprantl, dang Differential Revision: https://reviews.llvm.org/D84013 Added: clang/test/Modules/Inputs/DebugDwoId.h clang/test/Modules/ModuleDebugInfoDwoId.cpp Modified: clang/include/clang/Basic/Module.h clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp clang/test/Modules/Inputs/module.map Removed: diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index 94dd21537966..ac33c7573f35 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -62,6 +62,15 @@ struct ASTFileSignature : std::array { explicit operator bool() const { return *this != BaseT({{0}}); } + /// Returns the value truncated to the size of an uint64_t. + uint64_t truncatedValue() const { +uint64_t Value = 0; +static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate."); +for (unsigned I = 0; I < sizeof(uint64_t); ++I) + Value |= static_cast((*this)[I]) << (I * 8); +return Value; + } + static ASTFileSignature create(StringRef Bytes) { return create(Bytes.bytes_begin(), Bytes.bytes_end()); } diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 2faf944d07d1..e3442ecd4bd5 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2545,12 +2545,11 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod, // We use the lower 64 bits for debug info. uint64_t Signature = 0; -if (const auto &ModSig = Mod.getSignature()) { - for (unsigned I = 0; I != sizeof(Signature); ++I) -Signature |= (uint64_t)ModSig[I] << (I * 8); -} else { +if (const auto &ModSig = Mod.getSignature()) + Signature = ModSig.truncatedValue(); +else Signature = ~1ULL; -} + llvm::DIBuilder DIB(CGM.getModule()); SmallString<0> PCM; if (!llvm::sys::path::is_absolute(Mod.getASTFile())) diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 0c7e5f4598f8..04bd6680e31c 100644 --- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer { // PCH files don't have a signature field in the control block, // but LLVM detects DWO CUs by looking for a non-zero DWO id. // We use the lower 64 bits for debug info. + uint64_t Signature = -Buffer->Signature -? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] -: ~1ULL; +Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL; + Builder->getModuleDebugInfo()->setDwoId(Signature); // Finalize the Builder. diff --git a/clang/test/Modules/Inputs/DebugDwoId.h b/clang/test/Modules/Inputs/DebugDwoId.h new file mode 100644 index ..242e4c7f5116 --- /dev/null +++ b/clang/test/Modules/Inputs/DebugDwoId.h @@ -0,0 +1,4 @@ +#ifndef DEBUG_DWO_ID_H +#define DEBUG_DWO_ID_H +struct Dummy {}; +#endif diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index ed220e667f05..e7cb4b27bc08 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -357,6 +357,10 @@ module DebugObjCImport { } } +module DebugDwoId { + header "DebugDwoId.h" +} + module ImportNam
[clang] c1dd5df - Revert "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"
Author: Raphael Isemann Date: 2020-08-21T16:08:37+02:00 New Revision: c1dd5df4255cd870e96a59e73163b22d85fbaba3 URL: https://github.com/llvm/llvm-project/commit/c1dd5df4255cd870e96a59e73163b22d85fbaba3 DIFF: https://github.com/llvm/llvm-project/commit/c1dd5df4255cd870e96a59e73163b22d85fbaba3.diff LOG: Revert "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)" This reverts commit a4c3ed42ba5625af54254584d762ebf96cc06942. The test is curiously failing with a plain exit code 1 on Fuchsia. Added: Modified: clang/include/clang/Basic/Module.h clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp clang/test/Modules/Inputs/module.map Removed: clang/test/Modules/Inputs/DebugDwoId.h clang/test/Modules/ModuleDebugInfoDwoId.cpp diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index ac33c7573f35..94dd21537966 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -62,15 +62,6 @@ struct ASTFileSignature : std::array { explicit operator bool() const { return *this != BaseT({{0}}); } - /// Returns the value truncated to the size of an uint64_t. - uint64_t truncatedValue() const { -uint64_t Value = 0; -static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate."); -for (unsigned I = 0; I < sizeof(uint64_t); ++I) - Value |= static_cast((*this)[I]) << (I * 8); -return Value; - } - static ASTFileSignature create(StringRef Bytes) { return create(Bytes.bytes_begin(), Bytes.bytes_end()); } diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e3442ecd4bd5..2faf944d07d1 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2545,11 +2545,12 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod, // We use the lower 64 bits for debug info. uint64_t Signature = 0; -if (const auto &ModSig = Mod.getSignature()) - Signature = ModSig.truncatedValue(); -else +if (const auto &ModSig = Mod.getSignature()) { + for (unsigned I = 0; I != sizeof(Signature); ++I) +Signature |= (uint64_t)ModSig[I] << (I * 8); +} else { Signature = ~1ULL; - +} llvm::DIBuilder DIB(CGM.getModule()); SmallString<0> PCM; if (!llvm::sys::path::is_absolute(Mod.getASTFile())) diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 04bd6680e31c..0c7e5f4598f8 100644 --- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer { // PCH files don't have a signature field in the control block, // but LLVM detects DWO CUs by looking for a non-zero DWO id. // We use the lower 64 bits for debug info. - uint64_t Signature = -Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL; - +Buffer->Signature +? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] +: ~1ULL; Builder->getModuleDebugInfo()->setDwoId(Signature); // Finalize the Builder. diff --git a/clang/test/Modules/Inputs/DebugDwoId.h b/clang/test/Modules/Inputs/DebugDwoId.h deleted file mode 100644 index 242e4c7f5116.. --- a/clang/test/Modules/Inputs/DebugDwoId.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef DEBUG_DWO_ID_H -#define DEBUG_DWO_ID_H -struct Dummy {}; -#endif diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index e7cb4b27bc08..ed220e667f05 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -357,10 +357,6 @@ module DebugObjCImport { } } -module DebugDwoId { - header "DebugDwoId.h" -} - module ImportNameInDir { header "ImportNameInDir.h" export * diff --git a/clang/test/Modules/ModuleDebugInfoDwoId.cpp b/clang/test/Modules/ModuleDebugInfoDwoId.cpp deleted file mode 100644 index 566db048df84.. --- a/clang/test/Modules/ModuleDebugInfoDwoId.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Tests that dwoIds in modules match the dwoIDs in the main file. - -// RUN: rm -rf %t.cache -// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I %S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &> %t.mod-out -// RUN: cat %t.ll %t.mod-out | FileCheck %s -// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s -// RUN: cat %t.mod-out | FileCheck --check-prefix=CHECK-REALIDS %s - -@import DebugDwoId; - -Dummy d; - -// Find the emitted dwoID for DebugInfoId and compare it
[clang] ada2e8e - Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"
Author: Raphael Isemann Date: 2020-08-24T11:51:32+02:00 New Revision: ada2e8ea67393aa8c44fe8e9d46be62df6d1c702 URL: https://github.com/llvm/llvm-project/commit/ada2e8ea67393aa8c44fe8e9d46be62df6d1c702 DIFF: https://github.com/llvm/llvm-project/commit/ada2e8ea67393aa8c44fe8e9d46be62df6d1c702.diff LOG: Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)" This relands D84013 but with a test that relies on less shell features to hopefully make the test pass on Fuchsia (where the test from the previous patch version strangely failed with a plain "Exit code 1"). Original summary: D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5 uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations that creates the dwoID in the module from the ASTFileSignature (`Buffer->Signature` being the array subclass that is now `std::array` instead of `std::array`). ``` uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] ``` This code works with the old ASTFileSignature (where two uint32_t are enough to fill the uint64_t), but after the patch this only took two bytes from the ASTFileSignature and only partly filled the Signature uint64_t. This caused that the dwoID in the module ref and the dwoID in the actual module no longer match (which in turns causes that LLDB keeps warning about the dwoID's not matching when debugging -gmodules-compiled binaries). This patch just unifies the logic for turning the ASTFileSignature into an uint64_t which makes the dwoID match again (and should prevent issues like that in the future). Reviewed By: aprantl, dang Differential Revision: https://reviews.llvm.org/D84013 Added: clang/test/Modules/Inputs/DebugDwoId.h clang/test/Modules/ModuleDebugInfoDwoId.cpp Modified: clang/include/clang/Basic/Module.h clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp clang/test/Modules/Inputs/module.map Removed: diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index 94dd21537966..ac33c7573f35 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -62,6 +62,15 @@ struct ASTFileSignature : std::array { explicit operator bool() const { return *this != BaseT({{0}}); } + /// Returns the value truncated to the size of an uint64_t. + uint64_t truncatedValue() const { +uint64_t Value = 0; +static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate."); +for (unsigned I = 0; I < sizeof(uint64_t); ++I) + Value |= static_cast((*this)[I]) << (I * 8); +return Value; + } + static ASTFileSignature create(StringRef Bytes) { return create(Bytes.bytes_begin(), Bytes.bytes_end()); } diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 2faf944d07d1..e3442ecd4bd5 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2545,12 +2545,11 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod, // We use the lower 64 bits for debug info. uint64_t Signature = 0; -if (const auto &ModSig = Mod.getSignature()) { - for (unsigned I = 0; I != sizeof(Signature); ++I) -Signature |= (uint64_t)ModSig[I] << (I * 8); -} else { +if (const auto &ModSig = Mod.getSignature()) + Signature = ModSig.truncatedValue(); +else Signature = ~1ULL; -} + llvm::DIBuilder DIB(CGM.getModule()); SmallString<0> PCM; if (!llvm::sys::path::is_absolute(Mod.getASTFile())) diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 0c7e5f4598f8..04bd6680e31c 100644 --- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer { // PCH files don't have a signature field in the control block, // but LLVM detects DWO CUs by looking for a non-zero DWO id. // We use the lower 64 bits for debug info. + uint64_t Signature = -Buffer->Signature -? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] -: ~1ULL; +Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL; + Builder->getModuleDebugInfo()->setDwoId(Signature); // Finalize the Builder. diff --git a/clang/test/Modules/Inputs/DebugDwoId.h b/clang/test/Modules/Inputs/DebugDwoId.h new file mode 100644 index ..242e4c7f5116 --- /dev/null +++ b/clang/test/Modules/Inputs/DebugDwoId.h @@ -0,0 +1,4 @@ +#ifndef DEBUG_DWO_ID_H +#define DEBUG_DWO_ID_H +struct Dummy {}; +#endif diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index
[clang] 2b3074c - Revert "Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)""
Author: Raphael Isemann Date: 2020-08-24T12:54:25+02:00 New Revision: 2b3074c0d14cadbd9595346fc795d4a49a479a20 URL: https://github.com/llvm/llvm-project/commit/2b3074c0d14cadbd9595346fc795d4a49a479a20 DIFF: https://github.com/llvm/llvm-project/commit/2b3074c0d14cadbd9595346fc795d4a49a479a20.diff LOG: Revert "Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"" This reverts commit ada2e8ea67393aa8c44fe8e9d46be62df6d1c702. Still breaking on Fuchsia (and also Fedora) with exit code 1, so back to investigating. Added: Modified: clang/include/clang/Basic/Module.h clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp clang/test/Modules/Inputs/module.map Removed: clang/test/Modules/Inputs/DebugDwoId.h clang/test/Modules/ModuleDebugInfoDwoId.cpp diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index ac33c7573f35..94dd21537966 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -62,15 +62,6 @@ struct ASTFileSignature : std::array { explicit operator bool() const { return *this != BaseT({{0}}); } - /// Returns the value truncated to the size of an uint64_t. - uint64_t truncatedValue() const { -uint64_t Value = 0; -static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate."); -for (unsigned I = 0; I < sizeof(uint64_t); ++I) - Value |= static_cast((*this)[I]) << (I * 8); -return Value; - } - static ASTFileSignature create(StringRef Bytes) { return create(Bytes.bytes_begin(), Bytes.bytes_end()); } diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e3442ecd4bd5..2faf944d07d1 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2545,11 +2545,12 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod, // We use the lower 64 bits for debug info. uint64_t Signature = 0; -if (const auto &ModSig = Mod.getSignature()) - Signature = ModSig.truncatedValue(); -else +if (const auto &ModSig = Mod.getSignature()) { + for (unsigned I = 0; I != sizeof(Signature); ++I) +Signature |= (uint64_t)ModSig[I] << (I * 8); +} else { Signature = ~1ULL; - +} llvm::DIBuilder DIB(CGM.getModule()); SmallString<0> PCM; if (!llvm::sys::path::is_absolute(Mod.getASTFile())) diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 04bd6680e31c..0c7e5f4598f8 100644 --- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer { // PCH files don't have a signature field in the control block, // but LLVM detects DWO CUs by looking for a non-zero DWO id. // We use the lower 64 bits for debug info. - uint64_t Signature = -Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL; - +Buffer->Signature +? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] +: ~1ULL; Builder->getModuleDebugInfo()->setDwoId(Signature); // Finalize the Builder. diff --git a/clang/test/Modules/Inputs/DebugDwoId.h b/clang/test/Modules/Inputs/DebugDwoId.h deleted file mode 100644 index 242e4c7f5116.. --- a/clang/test/Modules/Inputs/DebugDwoId.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef DEBUG_DWO_ID_H -#define DEBUG_DWO_ID_H -struct Dummy {}; -#endif diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index e7cb4b27bc08..ed220e667f05 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -357,10 +357,6 @@ module DebugObjCImport { } } -module DebugDwoId { - header "DebugDwoId.h" -} - module ImportNameInDir { header "ImportNameInDir.h" export * diff --git a/clang/test/Modules/ModuleDebugInfoDwoId.cpp b/clang/test/Modules/ModuleDebugInfoDwoId.cpp deleted file mode 100644 index 7a450c2580ea.. --- a/clang/test/Modules/ModuleDebugInfoDwoId.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Tests that dwoIds in modules match the dwoIDs in the main file. - -// RUN: rm -rf %t.cache -// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I %S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 2> %t.mod-out -// RUN: cat %t.ll > %t.combined_output -// RUN: cat %t.mod-out >> %t.combined_output -// RUN: cat %t.combined_output | FileCheck %s -// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s -// RUN: cat %t.mod-out | FileCheck --check-p
[clang] 105151c - Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"
Author: Raphael Isemann Date: 2020-08-24T14:52:53+02:00 New Revision: 105151ca5669a0536fb5bb1bc02bd3279cdbbfda URL: https://github.com/llvm/llvm-project/commit/105151ca5669a0536fb5bb1bc02bd3279cdbbfda DIFF: https://github.com/llvm/llvm-project/commit/105151ca5669a0536fb5bb1bc02bd3279cdbbfda.diff LOG: Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)" The orignal patch with the missing 'REQUIRES: asserts' as there is a debug-only flag used in the test. Original summary: D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5 uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations that creates the dwoID in the module from the ASTFileSignature (`Buffer->Signature` being the array subclass that is now `std::array` instead of `std::array`). ``` uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] ``` This code works with the old ASTFileSignature (where two uint32_t are enough to fill the uint64_t), but after the patch this only took two bytes from the ASTFileSignature and only partly filled the Signature uint64_t. This caused that the dwoID in the module ref and the dwoID in the actual module no longer match (which in turns causes that LLDB keeps warning about the dwoID's not matching when debugging -gmodules-compiled binaries). This patch just unifies the logic for turning the ASTFileSignature into an uint64_t which makes the dwoID match again (and should prevent issues like that in the future). Reviewed By: aprantl, dang Differential Revision: https://reviews.llvm.org/D84013 Added: clang/test/Modules/Inputs/DebugDwoId.h clang/test/Modules/ModuleDebugInfoDwoId.cpp Modified: clang/include/clang/Basic/Module.h clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp clang/test/Modules/Inputs/module.map Removed: diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index 94dd21537966..ac33c7573f35 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -62,6 +62,15 @@ struct ASTFileSignature : std::array { explicit operator bool() const { return *this != BaseT({{0}}); } + /// Returns the value truncated to the size of an uint64_t. + uint64_t truncatedValue() const { +uint64_t Value = 0; +static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate."); +for (unsigned I = 0; I < sizeof(uint64_t); ++I) + Value |= static_cast((*this)[I]) << (I * 8); +return Value; + } + static ASTFileSignature create(StringRef Bytes) { return create(Bytes.bytes_begin(), Bytes.bytes_end()); } diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 2faf944d07d1..e3442ecd4bd5 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2545,12 +2545,11 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod, // We use the lower 64 bits for debug info. uint64_t Signature = 0; -if (const auto &ModSig = Mod.getSignature()) { - for (unsigned I = 0; I != sizeof(Signature); ++I) -Signature |= (uint64_t)ModSig[I] << (I * 8); -} else { +if (const auto &ModSig = Mod.getSignature()) + Signature = ModSig.truncatedValue(); +else Signature = ~1ULL; -} + llvm::DIBuilder DIB(CGM.getModule()); SmallString<0> PCM; if (!llvm::sys::path::is_absolute(Mod.getASTFile())) diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 0c7e5f4598f8..04bd6680e31c 100644 --- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer { // PCH files don't have a signature field in the control block, // but LLVM detects DWO CUs by looking for a non-zero DWO id. // We use the lower 64 bits for debug info. + uint64_t Signature = -Buffer->Signature -? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] -: ~1ULL; +Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL; + Builder->getModuleDebugInfo()->setDwoId(Signature); // Finalize the Builder. diff --git a/clang/test/Modules/Inputs/DebugDwoId.h b/clang/test/Modules/Inputs/DebugDwoId.h new file mode 100644 index ..242e4c7f5116 --- /dev/null +++ b/clang/test/Modules/Inputs/DebugDwoId.h @@ -0,0 +1,4 @@ +#ifndef DEBUG_DWO_ID_H +#define DEBUG_DWO_ID_H +struct Dummy {}; +#endif diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index ed220e667f05..e7cb4b27bc08 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/mod
[clang] c9b45ce - [clang][NFC] Fix a GCC warning in ASTImporterTest.cpp
Author: Raphael Isemann Date: 2020-08-24T17:10:55+02:00 New Revision: c9b45ce1fd97531c228e092bedee719b971f82a3 URL: https://github.com/llvm/llvm-project/commit/c9b45ce1fd97531c228e092bedee719b971f82a3 DIFF: https://github.com/llvm/llvm-project/commit/c9b45ce1fd97531c228e092bedee719b971f82a3.diff LOG: [clang][NFC] Fix a GCC warning in ASTImporterTest.cpp Apparently only overriding one of the two CompleteType overloads causes GCC to emit a warning with -Woverloaded-virtual . Added: Modified: clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 9cab6cca0dc4..ecddd4d43752 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -5803,6 +5803,7 @@ struct SourceWithCompletedTagList : clang::ExternalASTSource { Record->completeDefinition(); CompletedTags.push_back(Tag); } + void CompleteType(ObjCInterfaceDecl *) override {} }; TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 677e3db - [clang][NFC] Properly fix a GCC warning in ASTImporterTest.cpp
Author: Raphael Isemann Date: 2020-08-26T17:10:13+02:00 New Revision: 677e3db5806af9c6bbe9e76c135f801e8b06a8ed URL: https://github.com/llvm/llvm-project/commit/677e3db5806af9c6bbe9e76c135f801e8b06a8ed DIFF: https://github.com/llvm/llvm-project/commit/677e3db5806af9c6bbe9e76c135f801e8b06a8ed.diff LOG: [clang][NFC] Properly fix a GCC warning in ASTImporterTest.cpp Follow up to c9b45ce1fd97531c228e092bedee719b971f82a3 which just defined the function instead of just 'using' the function from the base class (thanks David). Added: Modified: clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index ecddd4d43752..51391d221626 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -5803,7 +5803,7 @@ struct SourceWithCompletedTagList : clang::ExternalASTSource { Record->completeDefinition(); CompletedTags.push_back(Tag); } - void CompleteType(ObjCInterfaceDecl *) override {} + using clang::ExternalASTSource::CompleteType; }; TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e0e7eb2 - [clang] Add missing .def files to Clang's modulemap
Author: Raphael Isemann Date: 2020-09-02T20:42:12+02:00 New Revision: e0e7eb2e2648aee83caf2ecfe2972ce2f653d306 URL: https://github.com/llvm/llvm-project/commit/e0e7eb2e2648aee83caf2ecfe2972ce2f653d306 DIFF: https://github.com/llvm/llvm-project/commit/e0e7eb2e2648aee83caf2ecfe2972ce2f653d306.diff LOG: [clang] Add missing .def files to Clang's modulemap These new .def files weren't marked as textual so they ended up being compiled into the Clang module (which completely defeats the purpose of .def files). Added: Modified: clang/include/clang/module.modulemap Removed: diff --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap index 13d4dbf9dc2e..6290548b41f1 100644 --- a/clang/include/clang/module.modulemap +++ b/clang/include/clang/module.modulemap @@ -52,8 +52,10 @@ module Clang_Basic { textual header "Basic/BuiltinsX86_64.def" textual header "Basic/BuiltinsXCore.def" textual header "Basic/CodeGenOptions.def" + textual header "Basic/CommentOptions.def" textual header "Basic/DiagnosticOptions.def" textual header "Basic/Features.def" + textual header "Basic/FileSystemOptions.def" textual header "Basic/FPOptions.def" textual header "Basic/MSP430Target.def" textual header "Basic/LangOptions.def" @@ -63,6 +65,7 @@ module Clang_Basic { textual header "Basic/OpenMPKinds.def" textual header "Basic/OperatorKinds.def" textual header "Basic/Sanitizers.def" + textual header "Basic/TargetOptions.def" textual header "Basic/TokenKinds.def" textual header "Basic/X86Target.def" @@ -107,17 +110,35 @@ module Clang_Frontend { umbrella "Frontend" textual header "Basic/LangStandards.def" + textual header "Frontend/DependencyOutputOptions.def" + textual header "Frontend/FrontendOptions.def" + textual header "Frontend/MigratorOptions.def" + textual header "Frontend/PreprocessorOutputOptions.def" module * { export * } } module Clang_FrontendTool { requires cplusplus umbrella "FrontendTool" module * { export * } } module Clang_Index { requires cplusplus umbrella "Index" module * { export * } } -module Clang_Lex { requires cplusplus umbrella "Lex" module * { export * } } +module Clang_Lex { + requires cplusplus + umbrella "Lex" + textual header "Lex/HeaderSearchOptions.def" + textual header "Lex/PreprocessorOptions.def" + + module * { export * } +} module Clang_Parse { requires cplusplus umbrella "Parse" module * { export * } } module Clang_Rewrite { requires cplusplus umbrella "Rewrite/Core" module * { export * } } module Clang_RewriteFrontend { requires cplusplus umbrella "Rewrite/Frontend" module * { export * } } -module Clang_Sema { requires cplusplus umbrella "Sema" module * { export * } } +module Clang_Sema { + requires cplusplus + umbrella "Sema" + + textual header "Sema/CodeCompleteOptions.def" + + module * { export * } +} module Clang_Serialization { requires cplusplus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0478720 - [clang] Prevent that Decl::dump on a CXXRecordDecl deserialises further declarations.
Author: Raphael Isemann Date: 2020-09-07T12:31:30+02:00 New Revision: 0478720157f6413fad7595b8eff9c70d2d99b637 URL: https://github.com/llvm/llvm-project/commit/0478720157f6413fad7595b8eff9c70d2d99b637 DIFF: https://github.com/llvm/llvm-project/commit/0478720157f6413fad7595b8eff9c70d2d99b637.diff LOG: [clang] Prevent that Decl::dump on a CXXRecordDecl deserialises further declarations. Decl::dump is primarily used for debugging to visualise the current state of a declaration. Usually Decl::dump just displays the current state of the Decl and doesn't actually change any of its state, however since commit 457226e02a6e8533eaaa864a3fd7c8eeccd2bf58 the method actually started loading additional declarations from the ExternalASTSource. This causes that calling Decl::dump during a debugging session now actually does permanent changes to the AST and will cause the debugged program run to deviate from the original run. The change that caused this behaviour is the addition of `hasConstexprDestructor` (which is called from the TextNodeDumper) which performs a lookup into the current CXXRecordDecl to find the destructor. All other similar methods just return their respective bit in the DefinitionData (which obviously doesn't have such side effects). This just changes the node printer to emit "unknown_constexpr" in case a CXXRecordDecl is dumped that could potentially call into the ExternalASTSource instead of the usually empty string/"constexpr". For CXXRecordDecls that can safely be dumped the old behaviour is preserved Reviewed By: bruno Differential Revision: https://reviews.llvm.org/D80878 Added: clang/unittests/AST/ASTDumpTest.cpp Modified: clang/lib/AST/TextNodeDumper.cpp clang/test/AST/ast-dump-lambda.cpp clang/test/AST/ast-dump-records.cpp clang/unittests/AST/CMakeLists.txt Removed: diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 16c4c3736a4a..19b7b4c801d5 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1960,7 +1960,11 @@ void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) { FLAG(hasTrivialDestructor, trivial); FLAG(hasNonTrivialDestructor, non_trivial); FLAG(hasUserDeclaredDestructor, user_declared); - FLAG(hasConstexprDestructor, constexpr); + // Avoid calls to the external source. + if (!D->hasExternalVisibleStorage()) { +FLAG(hasConstexprDestructor, constexpr); + } else +OS << " maybe_constexpr"; FLAG(needsImplicitDestructor, needs_implicit); FLAG(needsOverloadResolutionForDestructor, needs_overload_resolution); if (!D->needsOverloadResolutionForDestructor()) diff --git a/clang/test/AST/ast-dump-lambda.cpp b/clang/test/AST/ast-dump-lambda.cpp index 37fb62ef9930..302b93734459 100644 --- a/clang/test/AST/ast-dump-lambda.cpp +++ b/clang/test/AST/ast-dump-lambda.cpp @@ -48,7 +48,7 @@ template void test(Ts... a) { // CHECK-NEXT:| | |-MoveConstructor exists simple trivial needs_implicit // CHECK-NEXT:| | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param // CHECK-NEXT:| | |-MoveAssignment exists simple trivial needs_implicit -// CHECK-NEXT:| | `-Destructor simple irrelevant trivial needs_implicit +// CHECK-NEXT:| | `-Destructor simple irrelevant trivial{{( maybe_constexpr)?}} needs_implicit // CHECK-NEXT:| |-CXXRecordDecl {{.*}} col:10{{( imported)?}} implicit struct V // CHECK-NEXT:| `-CXXMethodDecl {{.*}} line:17:10{{( imported)?}} f 'void ()' // CHECK-NEXT:| `-CompoundStmt {{.*}} @@ -60,7 +60,7 @@ template void test(Ts... a) { // CHECK-NEXT:| | | | |-MoveConstructor exists simple trivial needs_implicit // CHECK-NEXT:| | | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param // CHECK-NEXT:| | | | |-MoveAssignment -// CHECK-NEXT:| | | | `-Destructor simple irrelevant trivial needs_implicit +// CHECK-NEXT:| | | | `-Destructor simple irrelevant trivial{{( maybe_constexpr)?}} needs_implicit // CHECK-NEXT:| | | |-CXXMethodDecl {{.*}} col:7{{( imported)?}} operator() 'auto () const -> auto' inline // CHECK-NEXT:| | | | `-CompoundStmt {{.*}} // CHECK-NEXT:| | | `-FieldDecl {{.*}} col:8{{( imported)?}} implicit 'V *' @@ -75,7 +75,7 @@ template void test(Ts... a) { // CHECK-NEXT:| | | |-MoveConstructor exists simple trivial needs_implicit // CHECK-NEXT:| | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param // CHECK-NEXT:| | | |-MoveAssignment -// CHECK-NEXT:| | | `-Destructor simple irrelevant trivial needs_implicit +// CHECK-NEXT:| | | `-Destructor simple irrelevant trivial{{( maybe_constexpr)?}} needs_
[clang] 23f700c - Revert "[clang] Prevent that Decl::dump on a CXXRecordDecl deserialises further declarations."
Author: Raphael Isemann Date: 2020-09-07T14:50:13+02:00 New Revision: 23f700c785a141355fa6d022552aafc73135bf5d URL: https://github.com/llvm/llvm-project/commit/23f700c785a141355fa6d022552aafc73135bf5d DIFF: https://github.com/llvm/llvm-project/commit/23f700c785a141355fa6d022552aafc73135bf5d.diff LOG: Revert "[clang] Prevent that Decl::dump on a CXXRecordDecl deserialises further declarations." This reverts commit 0478720157f6413fad7595b8eff9c70d2d99b637. This probably doesn't work when forcing deserialising while dumping (which the ASTDumper optionally supports). Added: Modified: clang/lib/AST/TextNodeDumper.cpp clang/test/AST/ast-dump-lambda.cpp clang/test/AST/ast-dump-records.cpp clang/unittests/AST/CMakeLists.txt Removed: clang/unittests/AST/ASTDumpTest.cpp diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 19b7b4c801d5..16c4c3736a4a 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1960,11 +1960,7 @@ void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) { FLAG(hasTrivialDestructor, trivial); FLAG(hasNonTrivialDestructor, non_trivial); FLAG(hasUserDeclaredDestructor, user_declared); - // Avoid calls to the external source. - if (!D->hasExternalVisibleStorage()) { -FLAG(hasConstexprDestructor, constexpr); - } else -OS << " maybe_constexpr"; + FLAG(hasConstexprDestructor, constexpr); FLAG(needsImplicitDestructor, needs_implicit); FLAG(needsOverloadResolutionForDestructor, needs_overload_resolution); if (!D->needsOverloadResolutionForDestructor()) diff --git a/clang/test/AST/ast-dump-lambda.cpp b/clang/test/AST/ast-dump-lambda.cpp index 302b93734459..37fb62ef9930 100644 --- a/clang/test/AST/ast-dump-lambda.cpp +++ b/clang/test/AST/ast-dump-lambda.cpp @@ -48,7 +48,7 @@ template void test(Ts... a) { // CHECK-NEXT:| | |-MoveConstructor exists simple trivial needs_implicit // CHECK-NEXT:| | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param // CHECK-NEXT:| | |-MoveAssignment exists simple trivial needs_implicit -// CHECK-NEXT:| | `-Destructor simple irrelevant trivial{{( maybe_constexpr)?}} needs_implicit +// CHECK-NEXT:| | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT:| |-CXXRecordDecl {{.*}} col:10{{( imported)?}} implicit struct V // CHECK-NEXT:| `-CXXMethodDecl {{.*}} line:17:10{{( imported)?}} f 'void ()' // CHECK-NEXT:| `-CompoundStmt {{.*}} @@ -60,7 +60,7 @@ template void test(Ts... a) { // CHECK-NEXT:| | | | |-MoveConstructor exists simple trivial needs_implicit // CHECK-NEXT:| | | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param // CHECK-NEXT:| | | | |-MoveAssignment -// CHECK-NEXT:| | | | `-Destructor simple irrelevant trivial{{( maybe_constexpr)?}} needs_implicit +// CHECK-NEXT:| | | | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT:| | | |-CXXMethodDecl {{.*}} col:7{{( imported)?}} operator() 'auto () const -> auto' inline // CHECK-NEXT:| | | | `-CompoundStmt {{.*}} // CHECK-NEXT:| | | `-FieldDecl {{.*}} col:8{{( imported)?}} implicit 'V *' @@ -75,7 +75,7 @@ template void test(Ts... a) { // CHECK-NEXT:| | | |-MoveConstructor exists simple trivial needs_implicit // CHECK-NEXT:| | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param // CHECK-NEXT:| | | |-MoveAssignment -// CHECK-NEXT:| | | `-Destructor simple irrelevant trivial{{( maybe_constexpr)?}} needs_implicit +// CHECK-NEXT:| | | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT:| | |-CXXMethodDecl {{.*}} col:7{{( imported)?}} operator() 'auto () const -> auto' inline // CHECK-NEXT:| | | `-CompoundStmt {{.*}} // CHECK-NEXT:| | `-FieldDecl {{.*}} col:8{{( imported)?}} implicit 'V' @@ -94,7 +94,7 @@ template void test(Ts... a) { // CHECK-NEXT:| | | |-MoveConstructor exists simple trivial needs_implicit // CHECK-NEXT:| | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param // CHECK-NEXT:| | | |-MoveAssignment -// CHECK-NEXT:| | | `-Destructor simple irrelevant trivial{{( maybe_constexpr)?}} needs_implicit +// CHECK-NEXT:| | | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT:| | |-CXXMethodDecl {{.*}} col:3{{( imported)?}} operator() 'auto () const' inline // CHECK-NEXT:| | | `-CompoundStmt {{.*}} // CHECK-NEXT:| | |-CXXConversionDecl {{.*}} col:3{{( imported)?}} implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline @@ -108
[clang] 22ccdb7 - Revert "Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types."
Author: Raphael Isemann Date: 2020-12-14T14:03:38+01:00 New Revision: 22ccdb787024e954318e35fcf904fd4fa36f5679 URL: https://github.com/llvm/llvm-project/commit/22ccdb787024e954318e35fcf904fd4fa36f5679 DIFF: https://github.com/llvm/llvm-project/commit/22ccdb787024e954318e35fcf904fd4fa36f5679.diff LOG: Revert "Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types." This reverts commit 05cdf4acf42acce9ddcff646a5d6ac666710fe6d. It breaks stage-2 compilation of LLVM, see https://reviews.llvm.org/D91488#2451534 Added: Modified: clang/include/clang/Basic/LangOptions.h clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/StmtProfile.cpp clang/lib/AST/TemplateBase.cpp clang/test/CodeGenCXX/clang-abi-compat.cpp clang/test/CodeGenCXX/mangle-class-nttp.cpp clang/test/CodeGenCXX/mangle-template.cpp clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp Removed: diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 251c9a9ecb5d..203c45fdd9a7 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -155,10 +155,8 @@ class LangOptions : public LangOptionsBase { /// Attempt to be ABI-compatible with code generated by Clang 11.0.x /// (git 2e10b7a39b93). This causes clang to pass unions with a 256-bit -/// vector member on the stack instead of using registers, to not properly -/// mangle substitutions for template names in some cases, and to mangle -/// declaration template arguments without a cast to the parameter type -/// even when that can lead to mangling collisions. +/// vector member on the stack instead of using registers, and to not +/// properly mangle substitutions for template names in some cases. Ver11, /// Conform to the underlying platform's C and C++ ABIs as closely diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index fe4968052e17..f5a4f6708c83 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -551,15 +551,13 @@ class CXXNameMangler { void mangleCXXCtorType(CXXCtorType T, const CXXRecordDecl *InheritedFrom); void mangleCXXDtorType(CXXDtorType T); - void mangleTemplateArgs(TemplateName TN, - const TemplateArgumentLoc *TemplateArgs, + void mangleTemplateArgs(const TemplateArgumentLoc *TemplateArgs, unsigned NumTemplateArgs); - void mangleTemplateArgs(TemplateName TN, const TemplateArgument *TemplateArgs, + void mangleTemplateArgs(const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs); - void mangleTemplateArgs(TemplateName TN, const TemplateArgumentList &AL); - void mangleTemplateArg(TemplateArgument A, bool NeedExactType); - void mangleValueInTemplateArg(QualType T, const APValue &V, bool TopLevel, -bool NeedExactType = false); + void mangleTemplateArgs(const TemplateArgumentList &AL); + void mangleTemplateArg(TemplateArgument A); + void mangleValueInTemplateArg(QualType T, const APValue &V); void mangleTemplateParameter(unsigned Depth, unsigned Index); @@ -825,11 +823,6 @@ isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs) { return GlobalDecl(); } -static TemplateName asTemplateName(GlobalDecl GD) { - const TemplateDecl *TD = dyn_cast_or_null(GD.getDecl()); - return TemplateName(const_cast(TD)); -} - void CXXNameMangler::mangleName(GlobalDecl GD) { const NamedDecl *ND = cast(GD.getDecl()); if (const VarDecl *VD = dyn_cast(ND)) { @@ -906,7 +899,7 @@ void CXXNameMangler::mangleNameWithAbiTags(GlobalDecl GD, const TemplateArgumentList *TemplateArgs = nullptr; if (GlobalDecl TD = isTemplate(GD, TemplateArgs)) { mangleUnscopedTemplateName(TD, AdditionalAbiTags); - mangleTemplateArgs(asTemplateName(TD), *TemplateArgs); + mangleTemplateArgs(*TemplateArgs); return; } @@ -959,7 +952,7 @@ void CXXNameMangler::mangleTemplateName(const TemplateDecl *TD, if (DC->isTranslationUnit() || isStdNamespace(DC)) { mangleUnscopedTemplateName(TD, nullptr); -mangleTemplateArgs(asTemplateName(TD), TemplateArgs, NumTemplateArgs); +mangleTemplateArgs(TemplateArgs, NumTemplateArgs); } else { mangleNestedName(TD, TemplateArgs, NumTemplateArgs); } @@ -1109,8 +1102,7 @@ void CXXNameMangler::manglePrefix(QualType type) { // FIXME: GCC does not appear to mangle the template arguments when // the template in question is a dependent template name. Should we // emulate that badness? - mangleTemplateArgs(TST->getTemplateName(), TST->getArgs(), - TST->getNumArgs()); + mangleTemplateArgs(TST->getArgs(), TST->getNumArgs()); addSubstitution(QualType
[clang] 659f4bd - [clang] Add an option for hiding line numbers in diagnostics
Author: Raphael Isemann Date: 2020-11-05T16:10:18+01:00 New Revision: 659f4bd87efc7cae379aa128814e03fc8b006471 URL: https://github.com/llvm/llvm-project/commit/659f4bd87efc7cae379aa128814e03fc8b006471 DIFF: https://github.com/llvm/llvm-project/commit/659f4bd87efc7cae379aa128814e03fc8b006471.diff LOG: [clang] Add an option for hiding line numbers in diagnostics Clang offers a `-f[no]-show-column` flag for hiding the column numbers when printing diagnostics but there is no option for doing the same with line numbers. In LLDB having this option would be useful, as LLDB sometimes only knows the file name for a SourceLocation and just assigns it the dummy line/column `1:1`. These fake line/column numbers are confusing to the user and LLDB should be able to tell clang to hide *both* the column and the line number when rendering text diagnostics. This patch adds a flag for also hiding the line numbers. It's not exposed via the command line flags as it's most likely not very useful for any user and can lead to ambiguous output when the user decides to only hide either the line or the column number (where `file:1: ...` could now refer to both line 1 or column 1 depending on the compiler flags). LLDB can just access the DiagnosticOptions directly when constructing its internal Clang instance. The effect doesn't apply to Vi/MSVC style diagnostics because it's not defined how these diagnostic styles would show an omitted line number (MSVC doesn't have such an option and Vi's line mode is theory only supporting line numbers if I understand it correctly). Reviewed By: thakis, MaskRay Differential Revision: https://reviews.llvm.org/D83038 Added: clang/unittests/Frontend/TextDiagnosticTest.cpp Modified: clang/include/clang/Basic/DiagnosticOptions.def clang/lib/Frontend/TextDiagnostic.cpp clang/unittests/Frontend/CMakeLists.txt Removed: diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def index a946b5c6be8e..927710a0cb9a 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.def +++ b/clang/include/clang/Basic/DiagnosticOptions.def @@ -47,6 +47,7 @@ SEMANTIC_DIAGOPT(IgnoreWarnings, 1, 0) /// -w DIAGOPT(NoRewriteMacros, 1, 0) /// -Wno-rewrite-macros DIAGOPT(Pedantic, 1, 0) /// -pedantic DIAGOPT(PedanticErrors, 1, 0) /// -pedantic-errors +DIAGOPT(ShowLine, 1, 1) /// Show line number on diagnostics. DIAGOPT(ShowColumn, 1, 1) /// Show column number on diagnostics. DIAGOPT(ShowLocation, 1, 1) /// Show source location information. DIAGOPT(ShowLevel, 1, 1)/// Show diagnostic level. diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index 78acaaf9f96e..e781fd2c0229 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -827,7 +827,10 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc, emitFilename(PLoc.getFilename(), Loc.getManager()); switch (DiagOpts->getFormat()) { - case DiagnosticOptions::Clang: OS << ':' << LineNo; break; + case DiagnosticOptions::Clang: +if (DiagOpts->ShowLine) + OS << ':' << LineNo; +break; case DiagnosticOptions::MSVC: OS << '(' << LineNo; break; case DiagnosticOptions::Vi:OS << " +" << LineNo; break; } diff --git a/clang/unittests/Frontend/CMakeLists.txt b/clang/unittests/Frontend/CMakeLists.txt index d247089e9295..3c25b43e9530 100644 --- a/clang/unittests/Frontend/CMakeLists.txt +++ b/clang/unittests/Frontend/CMakeLists.txt @@ -12,6 +12,7 @@ add_clang_unittest(FrontendTests ParsedSourceLocationTest.cpp PCHPreambleTest.cpp OutputStreamTest.cpp + TextDiagnosticTest.cpp ) clang_target_link_libraries(FrontendTests PRIVATE diff --git a/clang/unittests/Frontend/TextDiagnosticTest.cpp b/clang/unittests/Frontend/TextDiagnosticTest.cpp new file mode 100644 index ..1e05104d9388 --- /dev/null +++ b/clang/unittests/Frontend/TextDiagnosticTest.cpp @@ -0,0 +1,100 @@ +//===- unittests/Frontend/TextDiagnosticTest.cpp - ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "clang/Frontend/TextDiagnostic.h" +#include "clang/Basic/FileManager.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/SourceManager.h" +#include "llvm/Support/SmallVectorMemoryBuffer.h" +#include "gtest/gtest.h" + +using namespace llvm; +using namespace clang; + +namespace { + +/// Prints a diagnostic with the given DiagnosticOptions and the given +/// SourceLocation and returns the printed diagnostic text. +static std::string PrintDiag(const Diagnos
[libunwind] 6b7a49b - Fix all the CMake code that can only handle -stdlib= but not --stdlib=
Author: Raphael Isemann Date: 2020-10-13T16:05:21+02:00 New Revision: 6b7a49bb43d58c2c08fddb9f6c538ee52806de0a URL: https://github.com/llvm/llvm-project/commit/6b7a49bb43d58c2c08fddb9f6c538ee52806de0a DIFF: https://github.com/llvm/llvm-project/commit/6b7a49bb43d58c2c08fddb9f6c538ee52806de0a.diff LOG: Fix all the CMake code that can only handle -stdlib= but not --stdlib= There are several places in LLVM's CMake setup that try to remove the `stdlib=...` flag from the CMake flags. All this code however only considered the `-stdlib=` variant of the flag but not the alternative spelling with a double dash. This causes that when one adds `--stdlib=...` to the user-provided CMake flags that this gets transformed into just `-` which ends up causing the build system to think it should read the source from stdin (which then lead to very confusing build errors). This just adds the alternative spelling before the`-stdlib=` variant in all these places Reviewed By: ldionne Differential Revision: https://reviews.llvm.org/D87133 Added: Modified: libcxx/CMakeLists.txt libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt Removed: diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 287059548e42..ee250374732d 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -478,7 +478,7 @@ if (NOT LIBCXX_STANDALONE_BUILD) remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG -lc++abi) endif() -remove_flags(-stdlib=libc++ -stdlib=libstdc++) +remove_flags(--stdlib=libc++ -stdlib=libc++ --stdlib=libstdc++ -stdlib=libstdc++) # FIXME: Remove all debug flags and flags that change which Windows # default libraries are linked. Currently we only support linking the diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 10ac112c90d9..c4d76ea22eca 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -248,6 +248,8 @@ if (LIBCXXABI_HAS_NOSTDINCXX_FLAG) # See: https://gitlab.kitware.com/cmake/cmake/issues/19227 set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "") # Remove -stdlib flags to prevent them from causing an unused flag warning. + string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "--stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 7851f3e45d0c..ebe9e449ec02 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -321,6 +321,8 @@ add_cxx_compile_flags_if_supported(-fno-rtti) if (LIBUNWIND_HAS_NOSTDINCXX_FLAG) list(APPEND LIBUNWIND_COMPILE_FLAGS -nostdinc++) # Remove -stdlib flags to prevent them from causing an unused flag warning. + string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "--stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0c926e6 - [ASTImporter] Make the Import() return value consistent with the map of imported decls when merging ClassTemplateSpecializationDecls
Author: Raphael Isemann Date: 2020-11-24T23:46:18+01:00 New Revision: 0c926e6d245bec176bf2554a9f0bd48ef2276678 URL: https://github.com/llvm/llvm-project/commit/0c926e6d245bec176bf2554a9f0bd48ef2276678 DIFF: https://github.com/llvm/llvm-project/commit/0c926e6d245bec176bf2554a9f0bd48ef2276678.diff LOG: [ASTImporter] Make the Import() return value consistent with the map of imported decls when merging ClassTemplateSpecializationDecls When importing a `ClassTemplateSpecializationDecl` definition into a TU with a matching `ClassTemplateSpecializationDecl` definition and a more recent forward decl, the ASTImporter currently will call `MapImported()` for the definitions, but will return the forward declaration from the `ASTImporter::Import()` call. This is triggering some assertions in LLDB when we try to fully import some DeclContexts before we delete the 'From' AST. The returned 'To' Decl before this patch is just the most recent forward decl but that's not the Decl with the definition to which the ASTImporter will import the child declarations. This patch just changes that the ASTImporter returns the definition that the imported Decl was merged with instead of the found forward declaration. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92016 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index de1f13edf3ca..0886980fe905 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -5423,8 +5423,9 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl( if (PrevDecl) { if (IsStructuralMatch(D, PrevDecl)) { - if (D->isThisDeclarationADefinition() && PrevDecl->getDefinition()) { -Importer.MapImported(D, PrevDecl->getDefinition()); + CXXRecordDecl *PrevDefinition = PrevDecl->getDefinition(); + if (D->isThisDeclarationADefinition() && PrevDefinition) { +Importer.MapImported(D, PrevDefinition); // Import those default field initializers which have been // instantiated in the "From" context, but not in the "To" context. for (auto *FromField : D->fields()) { @@ -5446,7 +5447,7 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl( // // Generally, ASTCommon.h/DeclUpdateKind enum gives a very good hint // what else could be fused during an AST merge. -return PrevDecl; +return PrevDefinition; } } else { // ODR violation. // FIXME HandleNameConflict diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index f869e492c90a..97a18a76622b 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -3104,6 +3104,25 @@ TEST_P(ASTImporterOptionSpecificTestBase, EXPECT_TRUE(ToFun->hasBody()); } +TEST_P(ASTImporterOptionSpecificTestBase, MergeTemplateSpecWithForwardDecl) { + std::string ClassTemplate = + R"( + template + struct X { int m; }; + template<> + struct X { int m; }; + )"; + // Append a forward decl for our template specialization. + getToTuDecl(ClassTemplate + "template<> struct X;", Lang_CXX11); + Decl *FromTU = getTuDecl(ClassTemplate, Lang_CXX11); + auto *FromSpec = FirstDeclMatcher().match( + FromTU, classTemplateSpecializationDecl(hasName("X"), isDefinition())); + auto *ImportedSpec = Import(FromSpec, Lang_CXX11); + // Check that our definition got merged with the existing definition. + EXPECT_TRUE(FromSpec->isThisDeclarationADefinition()); + EXPECT_TRUE(ImportedSpec->isThisDeclarationADefinition()); +} + TEST_P(ASTImporterOptionSpecificTestBase, ODRViolationOfClassTemplateSpecializationsShouldBeReported) { std::string ClassTemplate = ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 39a5dd1 - [ASTImporter] Import the default argument of TemplateTemplateParmDecl
Author: Raphael Isemann Date: 2020-11-26T15:12:45+01:00 New Revision: 39a5dd164ca8648e24525869c934c9137c4887ef URL: https://github.com/llvm/llvm-project/commit/39a5dd164ca8648e24525869c934c9137c4887ef DIFF: https://github.com/llvm/llvm-project/commit/39a5dd164ca8648e24525869c934c9137c4887ef.diff LOG: [ASTImporter] Import the default argument of TemplateTemplateParmDecl Same idea as in D92103 and D92106, but I realised after creating those reviews that there are also TemplateTemplateParmDecls that can have default arguments, so here's hopefully the last patch for default template arguments. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92119 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 0886980fe905..835551528e0d 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -5250,15 +5250,22 @@ ASTNodeImporter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { if (!TemplateParamsOrErr) return TemplateParamsOrErr.takeError(); - // FIXME: Import default argument. - TemplateTemplateParmDecl *ToD = nullptr; - (void)GetImportedOrCreateDecl( - ToD, D, Importer.getToContext(), - Importer.getToContext().getTranslationUnitDecl(), *LocationOrErr, - D->getDepth(), D->getPosition(), D->isParameterPack(), - (*NameOrErr).getAsIdentifierInfo(), - *TemplateParamsOrErr); + if (GetImportedOrCreateDecl( + ToD, D, Importer.getToContext(), + Importer.getToContext().getTranslationUnitDecl(), *LocationOrErr, + D->getDepth(), D->getPosition(), D->isParameterPack(), + (*NameOrErr).getAsIdentifierInfo(), *TemplateParamsOrErr)) +return ToD; + + if (D->hasDefaultArgument()) { +Expected ToDefaultArgOrErr = +import(D->getDefaultArgument()); +if (!ToDefaultArgOrErr) + return ToDefaultArgOrErr.takeError(); +ToD->setDefaultArgument(Importer.getToContext(), *ToDefaultArgOrErr); + } + return ToD; } diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 97a18a76622b..33e4b7226fba 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -901,6 +901,39 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportBeginLocOfDeclRefExpr) { .isValid()); } +TEST_P(ASTImporterOptionSpecificTestBase, + TemplateTemplateParmDeclNoDefaultArg) { + Decl *FromTU = getTuDecl(R"( + template typename TT> struct Y {}; + )", + Lang_CXX17); + auto From = FirstDeclMatcher().match( + FromTU, templateTemplateParmDecl(hasName("TT"))); + TemplateTemplateParmDecl *To = Import(From, Lang_CXX17); + ASSERT_FALSE(To->hasDefaultArgument()); +} + +TEST_P(ASTImporterOptionSpecificTestBase, TemplateTemplateParmDeclDefaultArg) { + Decl *FromTU = getTuDecl(R"( + template struct X {}; + template typename TT = X> struct Y {}; + )", + Lang_CXX17); + auto From = FirstDeclMatcher().match( + FromTU, templateTemplateParmDecl(hasName("TT"))); + TemplateTemplateParmDecl *To = Import(From, Lang_CXX17); + ASSERT_TRUE(To->hasDefaultArgument()); + const TemplateArgument &ToDefaultArg = To->getDefaultArgument().getArgument(); + ASSERT_TRUE(To->isTemplateDecl()); + TemplateDecl *ToTemplate = ToDefaultArg.getAsTemplate().getAsTemplateDecl(); + + // Find the default argument template 'X' in the AST and compare it against + // the default argument we got. + auto ToExpectedDecl = FirstDeclMatcher().match( + To->getTranslationUnitDecl(), classTemplateDecl(hasName("X"))); + ASSERT_EQ(ToTemplate, ToExpectedDecl); +} + TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) { Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3f6c856 - [ASTImporter] Import the default argument of TemplateTypeParmDecl
Author: Raphael Isemann Date: 2020-11-26T18:01:30+01:00 New Revision: 3f6c856bb5ae4426a586426bca9f1ef2848a2b12 URL: https://github.com/llvm/llvm-project/commit/3f6c856bb5ae4426a586426bca9f1ef2848a2b12 DIFF: https://github.com/llvm/llvm-project/commit/3f6c856bb5ae4426a586426bca9f1ef2848a2b12.diff LOG: [ASTImporter] Import the default argument of TemplateTypeParmDecl The test case isn't using the AST matchers for all checks as there doesn't seem to be support for matching TemplateTypeParmDecl default arguments. Otherwise this is simply importing the default arguments. Also updates several LLDB tests that now as intended omit the default template arguments of several std templates. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92103 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py lldb/test/API/commands/expression/import-std-module/stack/TestStackFromStdModule.py lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py lldb/test/API/commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 835551528e0d..5159682da85f 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -5158,8 +5158,6 @@ ASTNodeImporter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { // context. This context will be fixed when the actual template declaration // is created. - // FIXME: Import default argument and constraint expression. - ExpectedSLoc BeginLocOrErr = import(D->getBeginLoc()); if (!BeginLocOrErr) return BeginLocOrErr.takeError(); @@ -5206,6 +5204,14 @@ ASTNodeImporter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { ToIDC); } + if (D->hasDefaultArgument()) { +Expected ToDefaultArgOrErr = +import(D->getDefaultArgumentInfo()); +if (!ToDefaultArgOrErr) + return ToDefaultArgOrErr.takeError(); +ToD->setDefaultArgument(*ToDefaultArgOrErr); + } + return ToD; } diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 33e4b7226fba..5a93a7348e7a 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -880,6 +880,25 @@ TEST_P(ImportExpr, DependentSizedArrayType) { has(fieldDecl(hasType(dependentSizedArrayType(; } +TEST_P(ASTImporterOptionSpecificTestBase, TemplateTypeParmDeclNoDefaultArg) { + Decl *FromTU = getTuDecl("template struct X {};", Lang_CXX03); + auto From = FirstDeclMatcher().match( + FromTU, templateTypeParmDecl(hasName("T"))); + TemplateTypeParmDecl *To = Import(From, Lang_CXX03); + ASSERT_FALSE(To->hasDefaultArgument()); +} + +TEST_P(ASTImporterOptionSpecificTestBase, TemplateTypeParmDeclDefaultArg) { + Decl *FromTU = + getTuDecl("template struct X {};", Lang_CXX03); + auto From = FirstDeclMatcher().match( + FromTU, templateTypeParmDecl(hasName("T"))); + TemplateTypeParmDecl *To = Import(From, Lang_CXX03); + ASSERT_TRUE(To->hasDefaultArgument()); + QualType ToArg = To->getDefaultArgument(); + ASSERT_EQ(ToArg, QualType(To->getASTContext().IntTy)); +} + TEST_P(ASTImporterOptionSpecificTestBase, ImportBeginLocOfDeclRefExpr) { Decl *FromTU = getTuDecl("class A { public: static int X; }; void f() { (void)A::X; }", diff --git a/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py index 18bd8ae37ff9..0eaa50a12727 100644 --- a/lldb/test/API
[clang] 89c1a7a - [ASTImporter] Import the default argument of NonTypeTemplateParmDecl
Author: Raphael Isemann Date: 2020-11-27T11:40:07+01:00 New Revision: 89c1a7a67d6947f56dc2db189d3872626f5a8609 URL: https://github.com/llvm/llvm-project/commit/89c1a7a67d6947f56dc2db189d3872626f5a8609 DIFF: https://github.com/llvm/llvm-project/commit/89c1a7a67d6947f56dc2db189d3872626f5a8609.diff LOG: [ASTImporter] Import the default argument of NonTypeTemplateParmDecl The test case isn't using the AST matchers for all checks as there doesn't seem to be support for matching NonTypeTemplateParmDecl default arguments. Otherwise this is simply importing the default arguments. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92106 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 5159682da85f..01ee8d275af1 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -5227,15 +5227,22 @@ ASTNodeImporter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { if (Err) return std::move(Err); - // FIXME: Import default argument. - NonTypeTemplateParmDecl *ToD = nullptr; - (void)GetImportedOrCreateDecl( - ToD, D, Importer.getToContext(), - Importer.getToContext().getTranslationUnitDecl(), - ToInnerLocStart, ToLocation, D->getDepth(), - D->getPosition(), ToDeclName.getAsIdentifierInfo(), ToType, - D->isParameterPack(), ToTypeSourceInfo); + if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), + Importer.getToContext().getTranslationUnitDecl(), + ToInnerLocStart, ToLocation, D->getDepth(), + D->getPosition(), + ToDeclName.getAsIdentifierInfo(), ToType, + D->isParameterPack(), ToTypeSourceInfo)) +return ToD; + + if (D->hasDefaultArgument()) { +ExpectedExpr ToDefaultArgOrErr = import(D->getDefaultArgument()); +if (!ToDefaultArgOrErr) + return ToDefaultArgOrErr.takeError(); +ToD->setDefaultArgument(*ToDefaultArgOrErr); + } + return ToD; } diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 5a93a7348e7a..81a92a10f48d 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -953,6 +953,27 @@ TEST_P(ASTImporterOptionSpecificTestBase, TemplateTemplateParmDeclDefaultArg) { ASSERT_EQ(ToTemplate, ToExpectedDecl); } +TEST_P(ASTImporterOptionSpecificTestBase, NonTypeTemplateParmDeclNoDefaultArg) { + Decl *FromTU = getTuDecl("template struct X {};", Lang_CXX03); + auto From = FirstDeclMatcher().match( + FromTU, nonTypeTemplateParmDecl(hasName("N"))); + NonTypeTemplateParmDecl *To = Import(From, Lang_CXX03); + ASSERT_FALSE(To->hasDefaultArgument()); +} + +TEST_P(ASTImporterOptionSpecificTestBase, NonTypeTemplateParmDeclDefaultArg) { + Decl *FromTU = getTuDecl("template struct X {};", Lang_CXX03); + auto From = FirstDeclMatcher().match( + FromTU, nonTypeTemplateParmDecl(hasName("S"))); + NonTypeTemplateParmDecl *To = Import(From, Lang_CXX03); + ASSERT_TRUE(To->hasDefaultArgument()); + Stmt *ToArg = To->getDefaultArgument(); + ASSERT_TRUE(isa(ToArg)); + ToArg = *ToArg->child_begin(); + ASSERT_TRUE(isa(ToArg)); + ASSERT_EQ(cast(ToArg)->getValue().getLimitedValue(), 1U); +} + TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) { Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 888ce70 - [DebugInfo] Fix DWARF expressions for __block vars that are not on the heap
Author: Raphael Isemann Date: 2021-05-17T14:32:07+02:00 New Revision: 888ce70af288168136cf1ca658c3cf6d6759bb3f URL: https://github.com/llvm/llvm-project/commit/888ce70af288168136cf1ca658c3cf6d6759bb3f DIFF: https://github.com/llvm/llvm-project/commit/888ce70af288168136cf1ca658c3cf6d6759bb3f.diff LOG: [DebugInfo] Fix DWARF expressions for __block vars that are not on the heap `__block` variables used to be always stored on the head instead of stack. D51564 allowed `__block` variables to the stored on the stack like normal variablesif they not captured by any escaping block, but the debug-info generation code wasn't made aware of it so we still unconditionally emit DWARF expressions pointing to the heap. This patch makes CGDebugInfo use the `EscapingByref` introduced in D51564 that tracks whether the `__block` variable is actually on the heap. If it's stored on the stack instead we just use the debug info we would generate for normal variables instead. Reviewed By: ahatanak, aprantl Differential Revision: https://reviews.llvm.org/D99946 Added: Modified: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGen/debug-info-block-expr.c Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 3d96bf1964e1..fefcf7a4e973 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4303,7 +4303,9 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD, auto *Scope = cast(LexicalBlockStack.back()); StringRef Name = VD->getName(); if (!Name.empty()) { -if (VD->hasAttr()) { +// __block vars are stored on the heap if they are captured by a block that +// can escape the local scope. +if (VD->isEscapingByref()) { // Here, we need an offset *into* the alloca. CharUnits offset = CharUnits::fromQuantity(32); Expr.push_back(llvm::dwarf::DW_OP_plus_uconst); diff --git a/clang/test/CodeGen/debug-info-block-expr.c b/clang/test/CodeGen/debug-info-block-expr.c index 009e7800b6ee..5626c5c33a4f 100644 --- a/clang/test/CodeGen/debug-info-block-expr.c +++ b/clang/test/CodeGen/debug-info-block-expr.c @@ -1,9 +1,55 @@ // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -DDEAD_CODE -fblocks -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s + +typedef void (^BlockTy)(); +void escapeFunc(BlockTy); +typedef void (^BlockTy)(); +void noEscapeFunc(__attribute__((noescape)) BlockTy); + +// Verify that the desired DIExpression are generated for escaping (i.e, not +// 'noescape') blocks. +void test_escape_func() { +// CHECK-LABEL: void @test_escape_func +// CHECK: call void @llvm.dbg.declare({{.*}}metadata ![[ESCAPE_VAR:[0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}){{.*}}) + __block int escape_var; +// Blocks in dead code branches still capture __block variables. +#ifdef DEAD_CODE + if (0) +#endif + escapeFunc(^{ (void)escape_var; }); +} + +// Verify that the desired DIExpression are generated for noescape blocks. +void test_noescape_func() { +// CHECK-LABEL: void @test_noescape_func +// CHECK: call void @llvm.dbg.declare({{.*}}metadata ![[NOESCAPE_VAR:[0-9]+]], metadata !DIExpression()) + __block int noescape_var; + noEscapeFunc(^{ (void)noescape_var; }); +} + // Verify that the desired DIExpression are generated for blocks. +void test_local_block() { +// CHECK-LABEL: void @test_local_block +// CHECK: call void @llvm.dbg.declare({{.*}}metadata ![[BLOCK_VAR:[0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}){{.*}}) + __block int block_var; -void test() { -// CHECK: call void @llvm.dbg.declare({{.*}}!DIExpression(DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}){{.*}}) - __block int i; +// CHECK-LABEL: @__test_local_block_block_invoke // CHECK: call void @llvm.dbg.declare({{.*}}!DIExpression(DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}){{.*}}) - ^ { i = 1; }(); + ^ { block_var = 1; }(); +} + +// Verify that the desired DIExpression are generated for __block vars not used +// in any block. +void test_unused() { +// CHECK-LABEL: void @test_unused +// CHECK: call void @llvm.dbg.declare({{.*}}metadata ![[UNUSED_VAR:[0-9]+]], metadata !DIExpression()) + __block int unused_var; +// Use i (not inside a block). + ++unused_var; } + +// CHECK: ![[ESCAPE_VAR]] = !DILocalVariable(name: "escape_var" +// CHECK: ![[NOESCAPE_VAR]] = !DILocalVariable(name: "noescape_var" +// CHECK: ![[BLOCK_VAR]] = !DILocalVariable(name: "block_var" +// CHECK: ![[UNUSED_VAR]] = !DILocalVariable(name: "unused_var" + ___ cfe-commits mailing list cfe-commits@lists.llvm.or
[clang] ebd25fd - [clang] Fix Wnested-anon-types in ABIArgInfo
Author: Raphael Isemann Date: 2021-05-21T11:18:43+02:00 New Revision: ebd25fde5e04fa954f3fbad3fa0ee89f511a907a URL: https://github.com/llvm/llvm-project/commit/ebd25fde5e04fa954f3fbad3fa0ee89f511a907a DIFF: https://github.com/llvm/llvm-project/commit/ebd25fde5e04fa954f3fbad3fa0ee89f511a907a.diff LOG: [clang] Fix Wnested-anon-types in ABIArgInfo D98794 added the DirectAttr/IndirectAttr struct fields to that union, but declaring anonymous structs in an anonymous union triggers `-Wnested-anon-types` warnings. We can't just give them a name as they are in an anonymous union, so this just declares the type outside. ``` clang/include/clang/CodeGen/CGFunctionInfo.h:97:5: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types] struct { ^ clang/include/clang/CodeGen/CGFunctionInfo.h:101:5: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types] struct { ^ ``` Reviewed By: chill Differential Revision: https://reviews.llvm.org/D102903 Added: Modified: clang/include/clang/CodeGen/CGFunctionInfo.h Removed: diff --git a/clang/include/clang/CodeGen/CGFunctionInfo.h b/clang/include/clang/CodeGen/CGFunctionInfo.h index 91d867e7f64a5..4899c9deda6a3 100644 --- a/clang/include/clang/CodeGen/CGFunctionInfo.h +++ b/clang/include/clang/CodeGen/CGFunctionInfo.h @@ -93,15 +93,17 @@ class ABIArgInfo { llvm::Type *PaddingType; // canHavePaddingType() llvm::Type *UnpaddedCoerceAndExpandType; // isCoerceAndExpand() }; + struct DirectAttrInfo { +unsigned Offset; +unsigned Align; + }; + struct IndirectAttrInfo { +unsigned Align; +unsigned AddrSpace; + }; union { -struct { - unsigned Offset; - unsigned Align; -} DirectAttr; // isDirect() || isExtend() -struct { - unsigned Align; - unsigned AddrSpace; -} IndirectAttr;// isIndirect() +DirectAttrInfo DirectAttr; // isDirect() || isExtend() +IndirectAttrInfo IndirectAttr; // isIndirect() unsigned AllocaFieldIndex; // isInAlloca() }; Kind TheKind; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 7e3b9ab - [Timer] On macOS count number of executed instructions
Author: Alex Hoppen Date: 2021-02-11T17:26:37+01:00 New Revision: 7e3b9aba609f7f6c944baa319f0a61041ccdc707 URL: https://github.com/llvm/llvm-project/commit/7e3b9aba609f7f6c944baa319f0a61041ccdc707 DIFF: https://github.com/llvm/llvm-project/commit/7e3b9aba609f7f6c944baa319f0a61041ccdc707.diff LOG: [Timer] On macOS count number of executed instructions In addition to wall time etc. this should allow us to get less noisy values for time measurements. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D96049 Added: Modified: clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp llvm/CMakeLists.txt llvm/include/llvm/Config/config.h.cmake llvm/include/llvm/Support/Timer.h llvm/lib/Support/Timer.cpp Removed: diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp index 832723ba4ab5..f0939f71edc0 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp @@ -17,8 +17,9 @@ // CHECK-FILE-NEXT:"profile": { // CHECK-FILE-NEXT:"time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, // CHECK-FILE-NEXT:"time.clang-tidy.readability-function-size.user": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, -// CHECK-FILE-NEXT:"time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}} -// CHECK-FILE-NEXT: } +// CHECK-FILE-NEXT:"time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}{{,?}} +// If available on the platform, we also have a "time.clang-tidy.readability-function-size.instr" entry +// CHECK-FILE: } // CHECK-FILE-NEXT: } // CHECK-FILE-NOT: { @@ -27,7 +28,7 @@ // CHECK-FILE-NOT: "profile": { // CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, // CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.user": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, -// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}} +// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}{{,?}} // CHECK-FILE-NOT: } // CHECK-FILE-NOT: } diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index f5298de9f7ca..5d705b17f6f1 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -649,6 +649,12 @@ if (LLVM_BUILD_STATIC) endforeach() endif() +include(CheckSymbolExists) +check_symbol_exists(proc_pid_rusage "libproc.h" HAVE_PROC_PID_RUSAGE) +if(HAVE_PROC_PID_RUSAGE) + list(APPEND CMAKE_REQUIRED_LIBRARIES proc) +endif() + # Use libtool instead of ar if you are both on an Apple host, and targeting Apple. if(CMAKE_HOST_APPLE AND APPLE) include(UseLibtool) diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake index 0783fbcfe4d4..10d16d3f1f8e 100644 --- a/llvm/include/llvm/Config/config.h.cmake +++ b/llvm/include/llvm/Config/config.h.cmake @@ -353,4 +353,6 @@ /* Whether Timers signpost passes in Xcode Instruments */ #cmakedefine01 LLVM_SUPPORT_XCODE_SIGNPOSTS +#cmakedefine HAVE_PROC_PID_RUSAGE 1 + #endif diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h index 045ac448bdb4..c5874ed35698 100644 --- a/llvm/include/llvm/Support/Timer.h +++ b/llvm/include/llvm/Support/Timer.h @@ -24,12 +24,15 @@ class TimerGroup; class raw_ostream; class TimeRecord { - double WallTime; ///< Wall clock time elapsed in seconds. - double UserTime; ///< User time elapsed. - double SystemTime; ///< System time elapsed. - ssize_t MemUsed; ///< Memory allocated (in bytes). + double WallTime; ///< Wall clock time elapsed in seconds. + double UserTime; ///< User time elapsed. + double SystemTime; ///< System time elapsed. + ssize_t MemUsed; ///< Memory allocated (in bytes). + uint64_t InstructionsExecuted; ///< Number of instructions executed public: - TimeRecord() : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0) {} + TimeRecord() + : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0), +InstructionsExecuted(0) {} /// Get the current time and memory usage. If Start is true we get the memory /// usage before the time, otherwise we get time before memory usage. This @@ -42,6 +45,7 @@ class TimeRecord { double getSystemTime() const { return SystemTime; } double getWallTime() const { r
[clang] a54f160 - Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk
Author: Harmen Stoppels Date: 2021-02-25T11:32:27+01:00 New Revision: a54f160b3a98b91cd241a555d904a6b6453affc4 URL: https://github.com/llvm/llvm-project/commit/a54f160b3a98b91cd241a555d904a6b6453affc4 DIFF: https://github.com/llvm/llvm-project/commit/a54f160b3a98b91cd241a555d904a6b6453affc4.diff LOG: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk Allow users to use a non-system version of perl, python and awk, which is useful in certain package managers. Reviewed By: JDevlieghere, MaskRay Differential Revision: https://reviews.llvm.org/D95119 Added: Modified: clang/test/make_test_dirs.pl clang/tools/scan-build/bin/set-xcode-analyzer clang/utils/TestUtils/pch-test.pl clang/utils/analyzer/reducer.pl clang/utils/analyzer/update_plist_test.pl clang/www/demo/index.cgi debuginfo-tests/llgdb-tests/test_debuginfo.pl lldb/docs/use/python-reference.rst lldb/scripts/disasm-gdb-remote.pl llvm/utils/GenLibDeps.pl llvm/utils/codegen-diff llvm/utils/findsym.pl llvm/utils/llvm-compilers-check llvm/utils/llvm-native-gxx openmp/runtime/tools/check-execstack.pl openmp/runtime/tools/check-instruction-set.pl openmp/runtime/tools/message-converter.pl polly/lib/External/isl/doc/mypod2latex Removed: diff --git a/clang/test/make_test_dirs.pl b/clang/test/make_test_dirs.pl index 3a524d2adb1b..c2af9c485f93 100755 --- a/clang/test/make_test_dirs.pl +++ b/clang/test/make_test_dirs.pl @@ -1,9 +1,10 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl # # Simple little Perl script that takes the cxx-sections.data file as # input and generates a directory structure that mimics the standard's # structure. use English; +use warnings; $current_indent_level = -4; while ($line = ) { diff --git a/clang/tools/scan-build/bin/set-xcode-analyzer b/clang/tools/scan-build/bin/set-xcode-analyzer index 9faaec1e8e6e..f8c3f775ef7d 100755 --- a/clang/tools/scan-build/bin/set-xcode-analyzer +++ b/clang/tools/scan-build/bin/set-xcode-analyzer @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # [PR 11661] Note that we hardwire to /usr/bin/python because we # want to the use the system version of Python on Mac OS X. diff --git a/clang/utils/TestUtils/pch-test.pl b/clang/utils/TestUtils/pch-test.pl index e4311e965bb7..cff8255b85a3 100755 --- a/clang/utils/TestUtils/pch-test.pl +++ b/clang/utils/TestUtils/pch-test.pl @@ -1,10 +1,11 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl # This tiny little script, which should be run from the clang # directory (with clang in your patch), tries to take each # compilable Clang test and build a PCH file from that test, then read # and dump the contents of the PCH file just created. use POSIX; +use warnings; $exitcode = 0; sub testfiles($$) { diff --git a/clang/utils/analyzer/reducer.pl b/clang/utils/analyzer/reducer.pl index 872f61b33a77..75c0bf6ce7a6 100755 --- a/clang/utils/analyzer/reducer.pl +++ b/clang/utils/analyzer/reducer.pl @@ -1,5 +1,6 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl use strict; +use warnings; use File::Temp qw/ tempdir /; my $prog = "reducer"; @@ -31,8 +32,9 @@ my $commandStr = "@$command"; print OUT < # +use warnings; + # Give first option a name. my $Directory = $ARGV[0]; my $Symbol = $ARGV[1]; diff --git a/llvm/utils/llvm-compilers-check b/llvm/utils/llvm-compilers-check index 1fd0b93b..3b132454d20b 100755 --- a/llvm/utils/llvm-compilers-check +++ b/llvm/utils/llvm-compilers-check @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 ##===- utils/llvmbuild - Build the LLVM project *-python-*-===## # # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. diff --git a/llvm/utils/llvm-native-gxx b/llvm/utils/llvm-native-gxx index db547f654e2f..3c8a703b5b63 100755 --- a/llvm/utils/llvm-native-gxx +++ b/llvm/utils/llvm-native-gxx @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Wrapper around LLVM tools to generate a native .o from llvm-gxx using an # LLVM back-end (CBE by default). diff --git a/openmp/runtime/tools/check-execstack.pl b/openmp/runtime/tools/check-execstack.pl index e4a8e7c883ab..7a710072f972 100755 --- a/openmp/runtime/tools/check-execstack.pl +++ b/openmp/runtime/tools/check-execstack.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # #//===--===// diff --git a/openmp/runtime/tools/check-instruction-set.pl b/openmp/runtime/tools/check-instruction-set.pl index 65c315d59236..6edfb55e99ff 100755 --- a/openmp/runtime/tools/check-instruction-set.pl +++ b/openmp/runtime/tools/check-instruction-set.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # #//===--===// diff --git a/openmp/runtime/tools/message-converte
[clang] 96808c6 - [ASTImporter] Remove redundant IsStructuralMatch overloads
Author: Raphael Isemann Date: 2021-10-29T12:23:38+02:00 New Revision: 96808c69a13c68280c2808b04dc5b733193bef6d URL: https://github.com/llvm/llvm-project/commit/96808c69a13c68280c2808b04dc5b733193bef6d DIFF: https://github.com/llvm/llvm-project/commit/96808c69a13c68280c2808b04dc5b733193bef6d.diff LOG: [ASTImporter] Remove redundant IsStructuralMatch overloads Nearly all of the overloads have pretty much the same behaviour. The only exception here is that some of them call back `GetOriginalDecl` and others don't, but the only real user of that overload (which is LLDB) actually prefers getting this callback. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D112796 Added: Modified: clang/lib/AST/ASTImporter.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 4e74355f2639a..183849c86f01c 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -467,18 +467,8 @@ namespace clang { template bool hasSameVisibilityContextAndLinkage(T *Found, T *From); -bool IsStructuralMatch(Decl *From, Decl *To, bool Complain); -bool IsStructuralMatch(RecordDecl *FromRecord, RecordDecl *ToRecord, - bool Complain = true); -bool IsStructuralMatch(VarDecl *FromVar, VarDecl *ToVar, - bool Complain = true); -bool IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToRecord); +bool IsStructuralMatch(Decl *From, Decl *To, bool Complain = true); bool IsStructuralMatch(EnumConstantDecl *FromEC, EnumConstantDecl *ToEC); -bool IsStructuralMatch(FunctionTemplateDecl *From, - FunctionTemplateDecl *To); -bool IsStructuralMatch(FunctionDecl *From, FunctionDecl *To); -bool IsStructuralMatch(ClassTemplateDecl *From, ClassTemplateDecl *To); -bool IsStructuralMatch(VarTemplateDecl *From, VarTemplateDecl *To); ExpectedDecl VisitDecl(Decl *D); ExpectedDecl VisitImportDecl(ImportDecl *D); ExpectedDecl VisitEmptyDecl(EmptyDecl *D); @@ -2178,68 +2168,17 @@ getStructuralEquivalenceKind(const ASTImporter &Importer) { } bool ASTNodeImporter::IsStructuralMatch(Decl *From, Decl *To, bool Complain) { - StructuralEquivalenceContext Ctx( - Importer.getFromContext(), Importer.getToContext(), - Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer), - false, Complain); - return Ctx.IsEquivalent(From, To); -} - -bool ASTNodeImporter::IsStructuralMatch(RecordDecl *FromRecord, -RecordDecl *ToRecord, bool Complain) { // Eliminate a potential failure point where we attempt to re-import // something we're trying to import while completing ToRecord. - Decl *ToOrigin = Importer.GetOriginalDecl(ToRecord); + Decl *ToOrigin = Importer.GetOriginalDecl(To); if (ToOrigin) { -auto *ToOriginRecord = dyn_cast(ToOrigin); -if (ToOriginRecord) - ToRecord = ToOriginRecord; +To = ToOrigin; } - StructuralEquivalenceContext Ctx(Importer.getFromContext(), - ToRecord->getASTContext(), - Importer.getNonEquivalentDecls(), - getStructuralEquivalenceKind(Importer), - false, Complain); - return Ctx.IsEquivalent(FromRecord, ToRecord); -} - -bool ASTNodeImporter::IsStructuralMatch(VarDecl *FromVar, VarDecl *ToVar, -bool Complain) { StructuralEquivalenceContext Ctx( Importer.getFromContext(), Importer.getToContext(), Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer), false, Complain); - return Ctx.IsEquivalent(FromVar, ToVar); -} - -bool ASTNodeImporter::IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToEnum) { - // Eliminate a potential failure point where we attempt to re-import - // something we're trying to import while completing ToEnum. - if (Decl *ToOrigin = Importer.GetOriginalDecl(ToEnum)) -if (auto *ToOriginEnum = dyn_cast(ToOrigin)) -ToEnum = ToOriginEnum; - - StructuralEquivalenceContext Ctx( - Importer.getFromContext(), Importer.getToContext(), - Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer)); - return Ctx.IsEquivalent(FromEnum, ToEnum); -} - -bool ASTNodeImporter::IsStructuralMatch(FunctionTemplateDecl *From, -FunctionTemplateDecl *To) { - StructuralEquivalenceContext Ctx( - Importer.getFromContext(), Importer.getToContext(), - Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer), - false, false); - return Ctx.IsEquivalent(From, To); -} - -bool ASTNodeImporter::IsStructuralMatch(FunctionDecl *From, FunctionDecl *To) { - StructuralEquivalenceContext Ctx( - Importer.getFromContext(),
[clang] 01b3bd3 - [ASTImporter] Remove ASTNodeImporter::IsStructuralMatch overload for EnumConstantDecl
Author: Raphael Isemann Date: 2021-10-30T13:12:12+02:00 New Revision: 01b3bd3992b4b79ef103558eccc49981e97be479 URL: https://github.com/llvm/llvm-project/commit/01b3bd3992b4b79ef103558eccc49981e97be479 DIFF: https://github.com/llvm/llvm-project/commit/01b3bd3992b4b79ef103558eccc49981e97be479.diff LOG: [ASTImporter] Remove ASTNodeImporter::IsStructuralMatch overload for EnumConstantDecl 1. Moves the check to ASTStructuralEquivalence.cpp like all the other checks. 2. Adds the missing checks for identifier and init expression. Also add the respective tests for that stuff. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D112804 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/lib/AST/ASTStructuralEquivalence.cpp clang/unittests/AST/StructuralEquivalenceTest.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 183849c86f01c..8062b4fcab532 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -468,7 +468,6 @@ namespace clang { bool hasSameVisibilityContextAndLinkage(T *Found, T *From); bool IsStructuralMatch(Decl *From, Decl *To, bool Complain = true); -bool IsStructuralMatch(EnumConstantDecl *FromEC, EnumConstantDecl *ToEC); ExpectedDecl VisitDecl(Decl *D); ExpectedDecl VisitImportDecl(ImportDecl *D); ExpectedDecl VisitEmptyDecl(EmptyDecl *D); @@ -2182,16 +2181,6 @@ bool ASTNodeImporter::IsStructuralMatch(Decl *From, Decl *To, bool Complain) { return Ctx.IsEquivalent(From, To); } -bool ASTNodeImporter::IsStructuralMatch(EnumConstantDecl *FromEC, -EnumConstantDecl *ToEC) { - const llvm::APSInt &FromVal = FromEC->getInitVal(); - const llvm::APSInt &ToVal = ToEC->getInitVal(); - - return FromVal.isSigned() == ToVal.isSigned() && - FromVal.getBitWidth() == ToVal.getBitWidth() && - FromVal == ToVal; -} - ExpectedDecl ASTNodeImporter::VisitDecl(Decl *D) { Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node) << D->getDeclKindName(); diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp index c4ff05ba9325d..e85feb779190f 100644 --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/clang/lib/AST/ASTStructuralEquivalence.cpp @@ -1591,6 +1591,26 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return true; } +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + EnumConstantDecl *D1, + EnumConstantDecl *D2) { + const llvm::APSInt &FromVal = D1->getInitVal(); + const llvm::APSInt &ToVal = D2->getInitVal(); + if (FromVal.isSigned() != ToVal.isSigned()) +return false; + if (FromVal.getBitWidth() != ToVal.getBitWidth()) +return false; + if (FromVal != ToVal) +return false; + + if (!IsStructurallyEquivalent(D1->getIdentifier(), D2->getIdentifier())) +return false; + + // Init expressions are the most expensive check, so do them last. + return IsStructurallyEquivalent(Context, D1->getInitExpr(), + D2->getInitExpr()); +} + /// Determine structural equivalence of two enums. static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, EnumDecl *D1, EnumDecl *D2) { diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp b/clang/unittests/AST/StructuralEquivalenceTest.cpp index d416e9d301274..9ae0da8b9dd2c 100644 --- a/clang/unittests/AST/StructuralEquivalenceTest.cpp +++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp @@ -956,6 +956,48 @@ TEST_F(StructuralEquivalenceEnumTest, EnumsWithDifferentBody) { EXPECT_FALSE(testStructuralMatch(t)); } +struct StructuralEquivalenceEnumConstantTest : StructuralEquivalenceTest {}; + +TEST_F(StructuralEquivalenceEnumConstantTest, EnumConstantsWithSameValues) { + auto t = makeNamedDecls("enum foo { foo = 1 };", "enum foo { foo = 1 };", + Lang_C89); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumConstantTest, + EnumConstantsWithDifferentValues) { + auto t = + makeNamedDecls("enum e { foo = 1 };", "enum e { foo = 2 };", Lang_C89); + EXPECT_FALSE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumConstantTest, + EnumConstantsWithDifferentExprsButSameValues) { + auto t = makeNamedDecls("enum e { foo = 1 + 1 };", "enum e { foo = 2 };", + Lang_CXX11); + EXPECT_FALSE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumConstantTest, + EnumConstantsWithDifferentSignedness) { + auto t = makeNamedDecls("enum e : unsigned { foo = 1 };", + "enum e : int { foo = 1 };", Lang_CXX11); + EXPECT_FALSE(testStructuralMatc
[clang] 08a53db - [clang] Minor cleanup in CloneDetectionTest
Author: Raphael Isemann Date: 2020-04-01T10:48:50+02:00 New Revision: 08a53dba93389a9859c12e948d8281a839cffbdb URL: https://github.com/llvm/llvm-project/commit/08a53dba93389a9859c12e948d8281a839cffbdb DIFF: https://github.com/llvm/llvm-project/commit/08a53dba93389a9859c12e948d8281a839cffbdb.diff LOG: [clang] Minor cleanup in CloneDetectionTest Follow up to e8f13f4f62f. Added: Modified: clang/unittests/Analysis/CloneDetectionTest.cpp Removed: diff --git a/clang/unittests/Analysis/CloneDetectionTest.cpp b/clang/unittests/Analysis/CloneDetectionTest.cpp index e09d0733f044..f8f3602f5a2a 100644 --- a/clang/unittests/Analysis/CloneDetectionTest.cpp +++ b/clang/unittests/Analysis/CloneDetectionTest.cpp @@ -42,7 +42,7 @@ class NoBarFunctionConstraint { for (const StmtSequence &Arg : {A, B}) { if (const auto *D = dyn_cast(Arg.getContainingDecl())) { - if (StringRef(D->getNameAsString()).startswith("bar")) + if (D->getName().startswith("bar")) return false; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ba7bde6 - [ASTImporter] Add support for BuiltinTemplateDecl
Author: Raphael Isemann Date: 2019-10-30T14:53:35+01:00 New Revision: ba7bde65dcfff543cefc1de9adcda7f503de URL: https://github.com/llvm/llvm-project/commit/ba7bde65dcfff543cefc1de9adcda7f503de DIFF: https://github.com/llvm/llvm-project/commit/ba7bde65dcfff543cefc1de9adcda7f503de.diff LOG: [ASTImporter] Add support for BuiltinTemplateDecl Summary: That decl kind is currently not implemented. BuiltinTemplateDecl is for decls that are hardcoded in the ASTContext, so we can import them like we do other builtin decls by just taking the equivalent decl from the target ASTContext. Reviewers: martong, a.sidorin, shafik Reviewed By: martong, shafik Subscribers: rnkovacs, kristina, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69566 Added: clang/test/Import/builtin-template/Inputs/S.cpp clang/test/Import/builtin-template/test.cpp Modified: clang/lib/AST/ASTImporter.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 54acca7dc62c..9477e414cf55 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -44,6 +44,7 @@ #include "clang/AST/TypeLoc.h" #include "clang/AST/TypeVisitor.h" #include "clang/AST/UnresolvedSet.h" +#include "clang/Basic/Builtins.h" #include "clang/Basic/ExceptionSpecificationType.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/IdentifierTable.h" @@ -483,6 +484,7 @@ namespace clang { ExpectedDecl VisitUsingDirectiveDecl(UsingDirectiveDecl *D); ExpectedDecl VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); ExpectedDecl VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); +ExpectedDecl VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D); Expected ImportObjCTypeParamList(ObjCTypeParamList *list); @@ -4464,6 +4466,20 @@ ExpectedDecl ASTNodeImporter::VisitUnresolvedUsingTypenameDecl( return ToUsing; } +ExpectedDecl ASTNodeImporter::VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D) { + Decl* ToD = nullptr; + switch (D->getBuiltinTemplateKind()) { + case BuiltinTemplateKind::BTK__make_integer_seq: +ToD = Importer.getToContext().getMakeIntegerSeqDecl(); +break; + case BuiltinTemplateKind::BTK__type_pack_element: +ToD = Importer.getToContext().getTypePackElementDecl(); +break; + } + assert(ToD && "BuiltinTemplateDecl of unsupported kind!"); + Importer.MapImported(D, ToD); + return ToD; +} Error ASTNodeImporter::ImportDefinition( ObjCInterfaceDecl *From, ObjCInterfaceDecl *To, ImportDefinitionKind Kind) { diff --git a/clang/test/Import/builtin-template/Inputs/S.cpp b/clang/test/Import/builtin-template/Inputs/S.cpp new file mode 100644 index ..d5c9a9ae0309 --- /dev/null +++ b/clang/test/Import/builtin-template/Inputs/S.cpp @@ -0,0 +1,16 @@ +template +struct Seq { + static constexpr T PackSize = sizeof...(I); +}; + +template +using MakeSeq = __make_integer_seq; + + +using SizeT = decltype(sizeof(int)); + +template +using TypePackElement = __type_pack_element; + +template +struct X; diff --git a/clang/test/Import/builtin-template/test.cpp b/clang/test/Import/builtin-template/test.cpp new file mode 100644 index ..3ae7b53e9d45 --- /dev/null +++ b/clang/test/Import/builtin-template/test.cpp @@ -0,0 +1,30 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s -Xcc -DSEQ | FileCheck --check-prefix=CHECK-SEQ %s +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s -Xcc -DPACK | FileCheck --check-prefix=CHECK-PACK %s +// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s -Xcc -DPACK -Xcc -DSEQ | FileCheck --check-prefixes=CHECK-SEQ,CHECK-PACK %s + +// CHECK-SEQ: BuiltinTemplateDecl +// CHECK-SEQ-SAME: +// CHECK-SEQ-SAME: implicit +// CHECK-SEQ-SAME: __make_integer_seq + +// CHECK-PACK: BuiltinTemplateDecl +// CHECK-PACK-SAME: +// CHECK-PACK-SAME: implicit +// CHECK-PACK-SAME: __type_pack_element + +void expr() { +#ifdef SEQ + typedef MakeSeq M1; + M1 m1; + typedef MakeSeq M2; + M2 m2; + static_assert(M1::PackSize == 3, ""); + static_assert(M2::PackSize == 4, ""); +#endif + +#ifdef PACK + static_assert(__is_same(TypePackElement<0, X<0>>, X<0>), ""); + static_assert(__is_same(TypePackElement<0, X<0>, X<1>>, X<0>), ""); + static_assert(__is_same(TypePackElement<1, X<0>, X<1>>, X<1>), ""); +#endif +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7e6294c - Modernize llvm::Error handling in ExternalASTMerger
Author: Raphael Isemann Date: 2019-11-14T13:58:32+01:00 New Revision: 7e6294c056838683f43670c8390ef13df6657e57 URL: https://github.com/llvm/llvm-project/commit/7e6294c056838683f43670c8390ef13df6657e57 DIFF: https://github.com/llvm/llvm-project/commit/7e6294c056838683f43670c8390ef13df6657e57.diff LOG: Modernize llvm::Error handling in ExternalASTMerger Added: Modified: clang/lib/AST/ExternalASTMerger.cpp Removed: diff --git a/clang/lib/AST/ExternalASTMerger.cpp b/clang/lib/AST/ExternalASTMerger.cpp index f678c2dd3b59..88bbe90a4e90 100644 --- a/clang/lib/AST/ExternalASTMerger.cpp +++ b/clang/lib/AST/ExternalASTMerger.cpp @@ -510,9 +510,7 @@ bool ExternalASTMerger::FindExternalVisibleDeclsByName(const DeclContext *DC, Decl *LookupRes = C.first.get(); ASTImporter *Importer = C.second; auto NDOrErr = Importer->Import(LookupRes); -assert(NDOrErr); -(void)static_cast(NDOrErr); -NamedDecl *ND = cast_or_null(*NDOrErr); +NamedDecl *ND = cast(llvm::cantFail(std::move(NDOrErr))); assert(ND); // If we don't import specialization, they are not available via lookup // because the lookup result is imported TemplateDecl and it does not ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 164e0fc - [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls
Author: Raphael Isemann Date: 2019-12-06T18:50:32+01:00 New Revision: 164e0fc5c7f782b174db5c87b37725ea0e174853 URL: https://github.com/llvm/llvm-project/commit/164e0fc5c7f782b174db5c87b37725ea0e174853 DIFF: https://github.com/llvm/llvm-project/commit/164e0fc5c7f782b174db5c87b37725ea0e174853.diff LOG: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls Summary: When Sema encounters a ObjCMethodDecl definition it declares the implicit parameters for the ObjCMethodDecl. When importing such a method with the ASTImporter we need to do the same for the imported method otherwise we will crash when generating code (where CodeGen expects that this was called by Sema). Note I had to implement Objective-C[++] support in Language.cpp as this is the first test for Objective-C and this would otherwise just hit this 'not implemented' assert when running the unit test. Reviewers: martong, a.sidorin, shafik Reviewed By: martong Subscribers: rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71112 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp clang/unittests/AST/Language.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index ff844f98bfb2..7d71a4a143cc 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -4010,6 +4010,14 @@ ExpectedDecl ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { ToMethod->setLexicalDeclContext(LexicalDC); LexicalDC->addDeclInternal(ToMethod); + + // Implicit params are declared when Sema encounters the definition but this + // never happens when the method is imported. Manually declare the implicit + // params now that the MethodDecl knows its class interface. + if (D->getSelfDecl()) +ToMethod->createImplicitParams(Importer.getToContext(), + ToMethod->getClassInterface()); + return ToMethod; } diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index ba2feff5fca6..abf29966e92f 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -5599,6 +5599,30 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportDefaultConstructibleLambdas) { 2u); } +TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) { + Decl *FromTU = getTuDecl(R"( + __attribute__((objc_root_class)) + @interface Root + @end + @interface C : Root + -(void)method; + @end + @implementation C + -(void)method {} + @end + )", + Lang_OBJCXX, "input.mm"); + auto *FromMethod = LastDeclMatcher().match( + FromTU, namedDecl(hasName("method"))); + ASSERT_TRUE(FromMethod); + auto ToMethod = Import(FromMethod, Lang_OBJCXX); + ASSERT_TRUE(ToMethod); + + // Both methods should have their implicit parameters. + EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr); + EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr); +} + INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest, DefaultTestValuesForRunOptions, ); diff --git a/clang/unittests/AST/Language.cpp b/clang/unittests/AST/Language.cpp index 68b78a3179d6..47993cbb99ec 100644 --- a/clang/unittests/AST/Language.cpp +++ b/clang/unittests/AST/Language.cpp @@ -37,8 +37,10 @@ ArgVector getBasicRunOptionsForLanguage(Language Lang) { case Lang_CXX2a: BasicArgs = {"-std=c++2a", "-frtti"}; break; - case Lang_OpenCL: case Lang_OBJCXX: +BasicArgs = {"-x", "objective-c++", "-frtti"}; +break; + case Lang_OpenCL: llvm_unreachable("Not implemented yet!"); } return BasicArgs; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5708f2d - [clang] Fix modules build after addition of TypeBitCodes.def
Author: Raphael Isemann Date: 2019-12-14T18:24:53+01:00 New Revision: 5708f2daf7386ef5f1ec54db4bda2b48bbcbe934 URL: https://github.com/llvm/llvm-project/commit/5708f2daf7386ef5f1ec54db4bda2b48bbcbe934 DIFF: https://github.com/llvm/llvm-project/commit/5708f2daf7386ef5f1ec54db4bda2b48bbcbe934.diff LOG: [clang] Fix modules build after addition of TypeBitCodes.def In revision 139006ceb641f038a2b19cac1174316e57004ed6 the Serialization folder got its first def file 'TypeBitCodes.def'. This broke the modules build as this .def file was not textually included but implicitly converted into a module due to our umbrella directive. This patch fixes this by explicitly marking the .def file as textual. Added: Modified: clang/include/clang/module.modulemap Removed: diff --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap index 2cbe865bce87..b3e2108d3fa6 100644 --- a/clang/include/clang/module.modulemap +++ b/clang/include/clang/module.modulemap @@ -114,7 +114,15 @@ module Clang_Parse { requires cplusplus umbrella "Parse" module * { export * } } module Clang_Rewrite { requires cplusplus umbrella "Rewrite/Core" module * { export * } } module Clang_RewriteFrontend { requires cplusplus umbrella "Rewrite/Frontend" module * { export * } } module Clang_Sema { requires cplusplus umbrella "Sema" module * { export * } } -module Clang_Serialization { requires cplusplus umbrella "Serialization" module * { export * } } + +module Clang_Serialization { + requires cplusplus + umbrella "Serialization" + + textual header "Serialization/TypeBitCodes.def" + + module * { export * } +} module Clang_StaticAnalyzer_Core { requires cplusplus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] aa45584 - [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource
Author: Raphael Isemann Date: 2019-12-15T18:11:01+01:00 New Revision: aa4558497ff6301881adf38960dd2f4d95aa8fc5 URL: https://github.com/llvm/llvm-project/commit/aa4558497ff6301881adf38960dd2f4d95aa8fc5 DIFF: https://github.com/llvm/llvm-project/commit/aa4558497ff6301881adf38960dd2f4d95aa8fc5.diff LOG: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource Summary: We currently have some very basic LLVM-style RTTI support in the ExternalASTSource class hierarchy based on the `SemaSource` bool( to discriminate it form the ExternalSemaSource). As ExternalASTSource is supposed to be subclassed we should have extendable LLVM-style RTTI in this class hierarchy to make life easier for projects building on top of Clang. Most notably the current RTTI implementation forces LLDB to implement RTTI for its own ExternalASTSource class (ClangExternalASTSourceCommon) by keeping a global set of ExternalASTSources that are known to be ClangExternalASTSourceCommon. Projects using Clang currently have to dosimilar workarounds to get RTTI support for their subclasses. This patch turns this into full-fledged LLVM-style RTTI based on a static `ID` variable similar to other LLVM class hierarchies. Also removes the friend declaration from ExternalASTSource to its child class that was only used to grant access to the `SemaSource` member. Reviewers: aprantl, dblaikie, rjmccall Reviewed By: aprantl Subscribers: riccibruno, labath, lhames, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71397 Added: Modified: clang/include/clang/AST/ExternalASTSource.h clang/include/clang/Sema/ExternalSemaSource.h clang/include/clang/Sema/MultiplexExternalSemaSource.h clang/lib/AST/ExternalASTSource.cpp clang/lib/Sema/MultiplexExternalSemaSource.cpp clang/lib/Sema/Sema.cpp Removed: diff --git a/clang/include/clang/AST/ExternalASTSource.h b/clang/include/clang/AST/ExternalASTSource.h index 304633668bd1..899ac3f66937 100644 --- a/clang/include/clang/AST/ExternalASTSource.h +++ b/clang/include/clang/AST/ExternalASTSource.h @@ -66,9 +66,8 @@ class ExternalASTSource : public RefCountedBase { /// whenever we might have added new redeclarations for existing decls. uint32_t CurrentGeneration = 0; - /// Whether this AST source also provides information for - /// semantic analysis. - bool SemaSource = false; + /// LLVM-style RTTI. + static char ID; public: ExternalASTSource() = default; @@ -325,6 +324,12 @@ class ExternalASTSource : public RefCountedBase { virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; + /// LLVM-style RTTI. + /// \{ + virtual bool isA(const void *ClassID) const { return ClassID == &ID; } + static bool classof(const ExternalASTSource *S) { return S->isA(&ID); } + /// \} + protected: static DeclContextLookupResult SetExternalVisibleDeclsForName(const DeclContext *DC, diff --git a/clang/include/clang/Sema/ExternalSemaSource.h b/clang/include/clang/Sema/ExternalSemaSource.h index 88fa6f53d8bf..c79ca0e71df5 100644 --- a/clang/include/clang/Sema/ExternalSemaSource.h +++ b/clang/include/clang/Sema/ExternalSemaSource.h @@ -50,10 +50,11 @@ struct ExternalVTableUse { /// external AST sources that also provide information for semantic /// analysis. class ExternalSemaSource : public ExternalASTSource { + /// LLVM-style RTTI. + static char ID; + public: - ExternalSemaSource() { -ExternalASTSource::SemaSource = true; - } + ExternalSemaSource() = default; ~ExternalSemaSource() override; @@ -222,10 +223,13 @@ class ExternalSemaSource : public ExternalASTSource { return false; } - // isa/cast/dyn_cast support - static bool classof(const ExternalASTSource *Source) { -return Source->SemaSource; + /// LLVM-style RTTI. + /// \{ + bool isA(const void *ClassID) const override { +return ClassID == &ID || ExternalASTSource::isA(ClassID); } + static bool classof(const ExternalASTSource *S) { return S->isA(&ID); } + /// \} }; } // end namespace clang diff --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h b/clang/include/clang/Sema/MultiplexExternalSemaSource.h index 8157e488d3b1..dcbac9f0ba10 100644 --- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h +++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h @@ -36,6 +36,8 @@ namespace clang { /// external AST sources that also provide information for semantic /// analysis. class MultiplexExternalSemaSource : public ExternalSemaSource { + /// LLVM-style RTTI. + static char ID; private: SmallVector Sources; // doesn't own them. @@ -352,9 +354,13 @@ class MultiplexExternalSemaSource : public ExternalSemaSource { bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc, QualType T) override; - // isa/cast/dyn_cast support - static
[clang] ccfab8e - [ObjC][DWARF] Emit DW_AT_APPLE_objc_direct for methods marked as __attribute__((objc_direct))
Author: Raphael Isemann Date: 2019-12-17T09:40:36+01:00 New Revision: ccfab8e4596e59c8eea6b3610cd163c5d0312193 URL: https://github.com/llvm/llvm-project/commit/ccfab8e4596e59c8eea6b3610cd163c5d0312193 DIFF: https://github.com/llvm/llvm-project/commit/ccfab8e4596e59c8eea6b3610cd163c5d0312193.diff LOG: [ObjC][DWARF] Emit DW_AT_APPLE_objc_direct for methods marked as __attribute__((objc_direct)) Summary: With DWARF5 it is no longer possible to distinguish normal methods and methods with `__attribute__((objc_direct))` by just looking at the debug information as they are both now children of the of the DW_TAG_structure_type that defines them (before only the `__attribute__((objc_direct))` methods were children). This means that in LLDB we are no longer able to create a correct Clang AST of a module by just looking at the debug information. Instead we would need to call the Objective-C runtime to see which of the methods have a `__attribute__((objc_direct))` and then add the attribute to our own Clang AST depending on what the runtime returns. This would mean that we either let the module AST be dependent on the Objective-C runtime (which doesn't seem right) or we retroactively add the missing attribute to the imported AST in our expressions. A third option is to annotate methods with `__attribute__((objc_direct))` as `DW_AT_APPLE_objc_direct` which is what this patch implements. This way LLDB doesn't have to call the runtime for any `__attribute__((objc_direct))` method and the AST in our module will already be correct when we create it. Reviewers: aprantl, SouraVX Reviewed By: aprantl Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D71201 Added: llvm/test/DebugInfo/X86/objc_direct.ll Modified: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenObjC/debug-info-direct-method.m llvm/include/llvm/BinaryFormat/Dwarf.def llvm/include/llvm/IR/DebugInfoFlags.def llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 06204a860091..675df309e3f0 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3495,6 +3495,9 @@ llvm::DISubprogram *CGDebugInfo::getObjCMethodDeclaration( if (CGM.getCodeGenOpts().DwarfVersion < 5 && !OMD->isDirectMethod()) return nullptr; + if (OMD->isDirectMethod()) +SPFlags |= llvm::DISubprogram::SPFlagObjCDirect; + // Starting with DWARF V5 method declarations are emitted as children of // the interface type. auto *ID = dyn_cast_or_null(D->getDeclContext()); diff --git a/clang/test/CodeGenObjC/debug-info-direct-method.m b/clang/test/CodeGenObjC/debug-info-direct-method.m index f822088f946c..e5e2939a8c81 100644 --- a/clang/test/CodeGenObjC/debug-info-direct-method.m +++ b/clang/test/CodeGenObjC/debug-info-direct-method.m @@ -1,12 +1,17 @@ // RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s // RUN: %clang_cc1 -dwarf-version=4 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - -DDISABLE_DIRECT | FileCheck --check-prefix=CHECK-DISABLED %s __attribute__((objc_root_class)) @interface Root @end @implementation Root -- (int)getInt __attribute__((objc_direct)) { +- (int)getInt +#ifndef DISABLE_DIRECT + __attribute__((objc_direct)) +#endif +{ return 42; } @end @@ -19,3 +24,6 @@ - (int)getInt __attribute__((objc_direct)) { // CHECK-SAME: runtimeLang: DW_LANG_ObjC) // CHECK: ![[MEMBERS]] = !{![[GETTER:[0-9]+]]} // CHECK: ![[GETTER]] = !DISubprogram(name: "-[Root getInt]", +// CHECK-SAME: spFlags: DISPFlagObjCDirect + +// CHECK-DISABLED-NOT: DISPFlagObjCDirect diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.def b/llvm/include/llvm/BinaryFormat/Dwarf.def index 34a7410f7474..8b1b14de6f09 100644 --- a/llvm/include/llvm/BinaryFormat/Dwarf.def +++ b/llvm/include/llvm/BinaryFormat/Dwarf.def @@ -421,6 +421,7 @@ HANDLE_DW_AT(0x3fea, APPLE_property_setter, 0, APPLE) HANDLE_DW_AT(0x3feb, APPLE_property_attribute, 0, APPLE) HANDLE_DW_AT(0x3fec, APPLE_objc_complete_type, 0, APPLE) HANDLE_DW_AT(0x3fed, APPLE_property, 0, APPLE) +HANDLE_DW_AT(0x3fee, APPLE_objc_direct, 0, APPLE) // Attribute form encodings. HANDLE_DW_FORM(0x01, addr, 2, DWARF) diff --git a/llvm/include/llvm/IR/DebugInfoFlags.def b/llvm/include/llvm/IR/DebugInfoFlags.def index 587df8bec79c..df375b6c68e8 100644 --- a/llvm/include/llvm/IR/DebugInfoFlags.def +++ b/llvm/include/llvm/IR/DebugInfoFlags.def @@ -90,11 +90,12 @@ HANDLE_DISP_FLAG((1u << 8), MainSubprogram) // May al
[clang] a37734f - [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.
Author: Raphael Isemann Date: 2020-02-18T08:37:26+01:00 New Revision: a37734f643fbac04ce6d7f2f6b1c8dcd3c4d5e0e URL: https://github.com/llvm/llvm-project/commit/a37734f643fbac04ce6d7f2f6b1c8dcd3c4d5e0e DIFF: https://github.com/llvm/llvm-project/commit/a37734f643fbac04ce6d7f2f6b1c8dcd3c4d5e0e.diff LOG: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs. Summary: When importing the main FileID the ASTImporter currently gives it no include location. This means that any SourceLocations produced for this FileID look to Clang as if they are coming from the main FileID (as the main FileID has no include location). Clang seems to expect that there is only one main FileID in one translation unit (which makes sense during normal compilation), so this behavior leads to several problems when producing diagnostics, one being that when calling `SourceManager::isBeforeInTranslationUnit` on two SourceLocations that come from two different ASTContext instances, Clang fails to sort the SourceLocations as the include chains of the FileIDs don't end up in a single FileID. This causes that Clang crashes with "Unsortable locations found" in this function. This patch gives any imported main FileIDs the main FileID of the To ASTContext as its include location. This allows Clang to sort all imported SourceLocations as now all include chains point to the main FileID of the To ASTContext. The exact include location is currently set to the start of the To main file (just because that should always be a valid SourceLocation). Reviewers: martong, a_sidorin, a.sidorin, shafik, balazske Reviewed By: martong, a_sidorin, shafik Subscribers: balazske, rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74542 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 8710ef06aa51..5ce9d5cd16ac 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -8479,6 +8479,15 @@ Expected ASTImporter::Import(FileID FromID, bool IsBuiltin) { if (!ToIncludeLoc) return ToIncludeLoc.takeError(); + // Every FileID that is not the main FileID needs to have a valid include + // location so that the include chain points to the main FileID. When + // importing the main FileID (which has no include location), we need to + // create a fake include location in the main file to keep this property + // intact. + SourceLocation ToIncludeLocOrFakeLoc = *ToIncludeLoc; + if (FromID == FromSM.getMainFileID()) +ToIncludeLocOrFakeLoc = ToSM.getLocForStartOfFile(ToSM.getMainFileID()); + if (Cache->OrigEntry && Cache->OrigEntry->getDir()) { // FIXME: We probably want to use getVirtualFile(), so we don't hit the // disk again @@ -8490,7 +8499,7 @@ Expected ASTImporter::Import(FileID FromID, bool IsBuiltin) { // point to a valid file and we get no Entry here. In this case try with // the memory buffer below. if (Entry) - ToID = ToSM.createFileID(*Entry, *ToIncludeLoc, + ToID = ToSM.createFileID(*Entry, ToIncludeLocOrFakeLoc, FromSLoc.getFile().getFileCharacteristic()); } } diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 3e8f804374f4..6c1d87823562 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -5845,6 +5845,48 @@ TEST_P(ImportAutoFunctions, ReturnWithTypeInSwitch) { EXPECT_TRUE(isa(To->getReturnType())); } +struct ImportSourceLocations : ASTImporterOptionSpecificTestBase {}; + +TEST_P(ImportSourceLocations, PreserveFileIDTreeStructure) { + // Tests that the FileID tree structure (with the links being the include + // chains) is preserved while importing other files (which need to be + // added to this structure with fake include locations. + + SourceLocation Location1; + { +auto Pattern = varDecl(hasName("X")); +Decl *FromTU = getTuDecl("int X;", Lang_C, "input0.c"); +auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); + +Location1 = Import(FromD, Lang_C)->getLocation(); + } + SourceLocation Location2; + { +auto Pattern = varDecl(hasName("Y")); +Decl *FromTU = getTuDecl("int Y;", Lang_C, "input1.c"); +auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); + +Location2 = Import(FromD, Lang_C)->getLocation(); + } + + SourceManager &ToSM = ToAST->getSourceManager(); + FileID FileID1 = ToSM.getFileID(Location1); + FileID FileID2 = ToSM.getFileID(Location2); + + // Check that the imported files look like as if they were included from the + // start of the main file. + SourceLocation FileStart = ToSM.getLocForStart
[clang] 4481eef - [ASTImporter] Properly delete decls from SavedImportPaths
Author: Jaroslav Sevcik Date: 2020-01-22T15:20:06+01:00 New Revision: 4481eefbe8425c63289186dd13319aaa7043e67f URL: https://github.com/llvm/llvm-project/commit/4481eefbe8425c63289186dd13319aaa7043e67f DIFF: https://github.com/llvm/llvm-project/commit/4481eefbe8425c63289186dd13319aaa7043e67f.diff LOG: [ASTImporter] Properly delete decls from SavedImportPaths Summary: We see a significant regression (~40% slower on large codebases) in expression evaluation after https://reviews.llvm.org/rL364771. A sampling profile shows the extra time is spent in SavedImportPathsTy::operator[] when called from ASTImporter::Import. I believe this is because ASTImporter::Import adds an element to the SavedImportPaths map for each decl unconditionally (see https://github.com/llvm/llvm-project/blob/7b81c3f8793d30a4285095a9b67dcfca2117916c/clang/lib/AST/ASTImporter.cpp#L8256). To fix this, we call SavedImportPathsTy::erase on the declaration rather than clearing its value vector. That way we do not accidentally introduce new empty elements. (With this patch the performance is restored, and we do not see SavedImportPathsTy::operator[] in the profile anymore.) Reviewers: martong, teemperor, a.sidorin, shafik Reviewed By: martong Subscribers: rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73166 Added: Modified: clang/lib/AST/ASTImporter.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 1f2ce30398c9..9dd20e2d5921 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -8253,7 +8253,7 @@ Expected ASTImporter::Import(Decl *FromD) { // FIXME Should we remove these Decls from the LookupTable, // and from ImportedFromDecls? } -SavedImportPaths[FromD].clear(); +SavedImportPaths.erase(FromD); // Do not return ToDOrErr, error was taken out of it. return make_error(ErrOut); @@ -8286,7 +8286,7 @@ Expected ASTImporter::Import(Decl *FromD) { Imported(FromD, ToD); updateFlags(FromD, ToD); - SavedImportPaths[FromD].clear(); + SavedImportPaths.erase(FromD); return ToDOrErr; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 326c39b - [clang][NFC] Remove redundant cast
Author: Raphael Isemann Date: 2020-01-24T11:07:33+01:00 New Revision: 326c39b569e385b35cc117a31a3b20919c799352 URL: https://github.com/llvm/llvm-project/commit/326c39b569e385b35cc117a31a3b20919c799352 DIFF: https://github.com/llvm/llvm-project/commit/326c39b569e385b35cc117a31a3b20919c799352.diff LOG: [clang][NFC] Remove redundant cast This cast just casts Decl* to Decl*. Added: Modified: clang/lib/AST/ASTImporter.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 9dd20e2d5921..dc8d7bf5064e 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -1753,7 +1753,7 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) { // fix since operations such as code generation will expect this to be so. if (ImportedOrErr) { FieldDecl *FieldFrom = dyn_cast_or_null(From); - Decl *ImportedDecl = (Decl*)*ImportedOrErr; + Decl *ImportedDecl = *ImportedOrErr; FieldDecl *FieldTo = dyn_cast_or_null(ImportedDecl); if (FieldFrom && FieldTo) { const RecordType *RecordFrom = FieldFrom->getType()->getAs(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22515: [analyzer] Added custom hashing to the CloneDetector.
teemperor updated this revision to Diff 68170. teemperor added a comment. - Renamed FoldingSetWrapper to FoldingSetNodeIDWrapper - Added missing // end anonymous namespace https://reviews.llvm.org/D22515 Files: include/clang/Analysis/CloneDetection.h lib/Analysis/CloneDetection.cpp lib/StaticAnalyzer/Checkers/CloneChecker.cpp Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp === --- lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -51,15 +51,6 @@ "Related code clone is here."); for (CloneDetector::CloneGroup &Group : CloneGroups) { - // For readability reasons we sort the clones by line numbers. - std::sort(Group.Sequences.begin(), Group.Sequences.end(), -[&SM](const StmtSequence &LHS, const StmtSequence &RHS) { - return SM.isBeforeInTranslationUnit(LHS.getStartLoc(), - RHS.getStartLoc()) && - SM.isBeforeInTranslationUnit(LHS.getEndLoc(), - RHS.getEndLoc()); -}); - // We group the clones by printing the first as a warning and all others // as a note. DiagEngine.Report(Group.Sequences.front().getStartLoc(), WarnID); Index: lib/Analysis/CloneDetection.cpp === --- lib/Analysis/CloneDetection.cpp +++ lib/Analysis/CloneDetection.cpp @@ -244,46 +244,35 @@ /// This class defines what a code clone is: If it collects for two statements /// the same data, then those two statements are considered to be clones of each /// other. -class StmtDataCollector : public ConstStmtVisitor { +/// +/// All collected data is forwarded to the given data consumer of the type T. +/// The data consumer class needs to provide a member method with the signature: +/// write(const char *Data, size_t Size) +template +class StmtDataCollector : public ConstStmtVisitor> { ASTContext &Context; - std::vector &CollectedData; + /// \brief The data sink to which all data is forwarded. + T &DataConsumer; public: /// \brief Collects data of the given Stmt. /// \param S The given statement. /// \param Context The ASTContext of S. - /// \param D The given data vector to which all collected data is appended. - StmtDataCollector(const Stmt *S, ASTContext &Context, -std::vector &D) - : Context(Context), CollectedData(D) { -Visit(S); + /// \param D The data sink to which all data is forwarded. + StmtDataCollector(const Stmt *S, ASTContext &Context, T &DataConsumer) + : Context(Context), DataConsumer(DataConsumer) { +this->Visit(S); } // Below are utility methods for appending different data to the vector. void addData(CloneDetector::DataPiece Integer) { -CollectedData.push_back(Integer); +DataConsumer.write(reinterpret_cast(&Integer), sizeof(Integer)); } - // FIXME: The functions below add long strings to the data vector which are - // probably not good for performance. Replace the strings with pointer values - // or a some other unique integer. - void addData(llvm::StringRef Str) { -if (Str.empty()) - return; - -const size_t OldSize = CollectedData.size(); - -const size_t PieceSize = sizeof(CloneDetector::DataPiece); -// Calculate how many vector units we need to accomodate all string bytes. -size_t RoundedUpPieceNumber = (Str.size() + PieceSize - 1) / PieceSize; -// Allocate space for the string in the data vector. -CollectedData.resize(CollectedData.size() + RoundedUpPieceNumber); - -// Copy the string to the allocated space at the end of the vector. -std::memcpy(CollectedData.data() + OldSize, Str.data(), Str.size()); +DataConsumer.write(Str.data(), Str.size()); } void addData(const QualType &QT) { addData(QT.getAsString()); } @@ -429,8 +418,10 @@ // Create an empty signature that will be filled in this method. CloneDetector::CloneSignature Signature; +llvm::hash_stream Hash; + // Collect all relevant data from S and put it into the empty signature. -StmtDataCollector(S, Context, Signature.Data); +StmtDataCollector(S, Context, Hash); // Macro-generated code should increase the complexity value of its // containing clone by about the same value as an variable reference or @@ -479,7 +470,8 @@ auto ChildSignature = generateSignatures(Child, StartMacroName); // Add the collected data to the signature of the current statement. - Signature.add(ChildSignature); + Signature.Complexity += ChildSignature.Complexity; + Hash << static_cast(ChildSignature.Hash); // If the current statement is a CompoundStatement, we need to store the // signature for the generation of the sub-sequ
Re: [PATCH] D22515: [analyzer] Added custom hashing to the CloneDetector.
teemperor marked 2 inline comments as done. teemperor added a comment. https://reviews.llvm.org/D22515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits