summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-modernize
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/test/clang-modernize')
-rw-r--r--clang-tools-extra/test/clang-modernize/Core/Inputs/.clang-format43
-rw-r--r--clang-tools-extra/test/clang-modernize/Core/NoReformattingNeeded.cpp10
-rw-r--r--clang-tools-extra/test/clang-modernize/Core/Reformatting.cpp38
-rw-r--r--clang-tools-extra/test/clang-modernize/HeaderReplacements/main.cpp2
4 files changed, 77 insertions, 16 deletions
diff --git a/clang-tools-extra/test/clang-modernize/Core/Inputs/.clang-format b/clang-tools-extra/test/clang-modernize/Core/Inputs/.clang-format
new file mode 100644
index 00000000000..d210decfa4f
--- /dev/null
+++ b/clang-tools-extra/test/clang-modernize/Core/Inputs/.clang-format
@@ -0,0 +1,43 @@
+---
+# BasedOnStyle: Google
+AccessModifierOffset: -1
+ConstructorInitializerIndentWidth: 4
+AlignEscapedNewlinesLeft: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakTemplateDeclarations: true
+AlwaysBreakBeforeMultilineStrings: true
+BreakBeforeBinaryOperators: false
+BreakConstructorInitializersBeforeComma: false
+BinPackParameters: true
+ColumnLimit: 80
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+DerivePointerBinding: true
+ExperimentalAutoDetectBinPacking: false
+IndentCaseLabels: true
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCSpaceBeforeProtocolList: false
+PenaltyBreakComment: 60
+PenaltyBreakString: 1000
+PenaltyBreakFirstLessLess: 120
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 200
+PointerBindsToType: true
+SpacesBeforeTrailingComments: 2
+Cpp11BracedListStyle: true
+Standard: Auto
+IndentWidth: 2
+TabWidth: 8
+UseTab: Never
+BreakBeforeBraces: Attach
+IndentFunctionDeclarationAfterType: true
+SpacesInParentheses: false
+SpaceInEmptyParentheses: false
+SpacesInCStyleCastParentheses: false
+SpaceAfterControlStatementKeyword: true
+SpaceBeforeAssignmentOperators: true
+...
+
diff --git a/clang-tools-extra/test/clang-modernize/Core/NoReformattingNeeded.cpp b/clang-tools-extra/test/clang-modernize/Core/NoReformattingNeeded.cpp
deleted file mode 100644
index e58fdb24068..00000000000
--- a/clang-tools-extra/test/clang-modernize/Core/NoReformattingNeeded.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-modernize -format-style=LLVM -use-auto %t.cpp -- -std=c++11
-// RUN: FileCheck --strict-whitespace -input-file=%t.cpp %s
-
-class C {};
-
-void f() { //
- C *a = new C();
- // CHECK: {{^\ \ auto\ a\ \=\ new\ C\(\);}}
-}
diff --git a/clang-tools-extra/test/clang-modernize/Core/Reformatting.cpp b/clang-tools-extra/test/clang-modernize/Core/Reformatting.cpp
index 129871809d8..338a17889d1 100644
--- a/clang-tools-extra/test/clang-modernize/Core/Reformatting.cpp
+++ b/clang-tools-extra/test/clang-modernize/Core/Reformatting.cpp
@@ -1,11 +1,37 @@
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: not clang-modernize -format-style=non_existent_file.yaml -use-auto %t.cpp -- -std=c++11
-// RUN: touch %T/non_format_config.yaml
-// RUN: not clang-modernize -format-style=%T/non_format_config.yaml -use-auto %t.cpp -- -std=c++11
-// RUN: clang-modernize -format-style=LLVM -use-auto %t.cpp -- -std=c++11
+// RUN: clang-modernize -format -use-auto %t.cpp
// RUN: FileCheck --strict-whitespace -input-file=%t.cpp %s
-class MyType012345678901234567890123456789 {};
+// Ensure that -style is forwarded to clang-apply-replacements by using a style
+// other than LLVM and ensuring the result is styled as requested.
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-modernize -format -style=Google -use-nullptr %t.cpp
+// RUN: FileCheck --check-prefix=Google --strict-whitespace -input-file=%t.cpp %s
+
+// Ensure -style-config is forwarded to clang-apply-replacements. The .clang-format
+// in %S/Inputs is a dump of the Google style so the same test can be used.
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-modernize -format -style=file -style-config=%S/Inputs -use-nullptr %t.cpp
+// RUN: FileCheck --check-prefix=Google --strict-whitespace -input-file=%t.cpp %s
+
+class MyType012345678901234567890123456789 {
+public:
+ MyType012345678901234567890123456789()
+ : iiiiiiiiiiii(0), jjjjjjjjjjjj(0), kkkkkkkkkkkk(0), mmmmmmmmmmmm(0),
+ nnnnnnnnnnnn(0) {}
+ // Google: iiiiiiiiiiii(nullptr),
+ // Google-NEXT: jjjjjjjjjjjj(nullptr),
+ // Google-NEXT: kkkkkkkkkkkk(nullptr),
+ // Google-NEXT: mmmmmmmmmmmm(nullptr),
+ // Google-NEXT: nnnnnnnnnnnn(nullptr) {}
+
+private:
+ int *iiiiiiiiiiii;
+ int *jjjjjjjjjjjj;
+ int *kkkkkkkkkkkk;
+ int *mmmmmmmmmmmm;
+ int *nnnnnnnnnnnn;
+};
int f() {
MyType012345678901234567890123456789 *a =
@@ -13,4 +39,6 @@ int f() {
// CHECK: {{^\ \ auto\ a\ \=\ new\ MyType012345678901234567890123456789\(\);}}
delete a;
+
+ return 0;
}
diff --git a/clang-tools-extra/test/clang-modernize/HeaderReplacements/main.cpp b/clang-tools-extra/test/clang-modernize/HeaderReplacements/main.cpp
index ce06794dfb0..c25dba7268a 100644
--- a/clang-tools-extra/test/clang-modernize/HeaderReplacements/main.cpp
+++ b/clang-tools-extra/test/clang-modernize/HeaderReplacements/main.cpp
@@ -7,7 +7,7 @@
// RUN: rm -rf %T/SerializeTest
// RUN: mkdir -p %T/SerializeTest
// RUN: cp %S/main.cpp %S/common.cpp %S/common.h %T/SerializeTest
-// RUN: clang-modernize -loop-convert -serialize-replacements -include=%T/SerializeTest %T/SerializeTest/main.cpp %T/SerializeTest/common.cpp --
+// RUN: clang-modernize -loop-convert -serialize-replacements -serialize-dir=%T/SerializeTest -include=%T/SerializeTest %T/SerializeTest/main.cpp %T/SerializeTest/common.cpp --
// Check that only 1 file is generated per translation unit
// RUN: ls -1 %T/SerializeTest | FileCheck %s --check-prefix=MAIN_CPP
// RUN: ls -1 %T/SerializeTest | FileCheck %s --check-prefix=COMMON_CPP
OpenPOWER on IntegriCloud