-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-apply-replacements] Add support for the
.yml
file extension (#…
…78842) The `.yml` file extension is a valid extension for the YAML files, but it was not previously supported by the Clang Apply Replacements tool. This commit adds support for processing `.yml` files. Without this change, running the tool on a folder containing `.yml` files generated by clang-tidy would have no effect.
- Loading branch information
1 parent
f9dc0b6
commit 45fec0c
Showing
5 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
clang-tools-extra/test/clang-apply-replacements/Inputs/yml-basic/basic.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef BASIC_H | ||
#define BASIC_H | ||
|
||
|
||
class Parent { | ||
public: | ||
virtual void func() {} | ||
}; | ||
|
||
class Derived : public Parent { | ||
public: | ||
virtual void func() {} | ||
// CHECK: virtual void func() override {} | ||
}; | ||
|
||
extern void ext(int (&)[5], const Parent &); | ||
|
||
void func(int t) { | ||
int ints[5]; | ||
for (unsigned i = 0; i < 5; ++i) { | ||
int &e = ints[i]; | ||
e = t; | ||
// CHECK: for (auto & elem : ints) { | ||
// CHECK-NEXT: elem = t; | ||
} | ||
|
||
Derived d; | ||
|
||
ext(ints, d); | ||
} | ||
|
||
#endif // BASIC_H |
26 changes: 26 additions & 0 deletions
26
clang-tools-extra/test/clang-apply-replacements/Inputs/yml-basic/file1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
MainSourceFile: source1.cpp | ||
Diagnostics: | ||
- DiagnosticName: test-basic | ||
DiagnosticMessage: | ||
Message: Fix | ||
FilePath: $(path)/basic.h | ||
FileOffset: 242 | ||
Replacements: | ||
- FilePath: $(path)/basic.h | ||
Offset: 242 | ||
Length: 26 | ||
ReplacementText: 'auto & elem : ints' | ||
- FilePath: $(path)/basic.h | ||
Offset: 276 | ||
Length: 22 | ||
ReplacementText: '' | ||
- FilePath: $(path)/basic.h | ||
Offset: 298 | ||
Length: 1 | ||
ReplacementText: elem | ||
- FilePath: $(path)/../yml-basic/basic.h | ||
Offset: 148 | ||
Length: 0 | ||
ReplacementText: 'override ' | ||
... |
14 changes: 14 additions & 0 deletions
14
clang-tools-extra/test/clang-apply-replacements/Inputs/yml-basic/file2.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
MainSourceFile: source2.cpp | ||
Diagnostics: | ||
- DiagnosticName: test-basic | ||
DiagnosticMessage: | ||
Message: Fix | ||
FilePath: $(path)/basic.h | ||
FileOffset: 148 | ||
Replacements: | ||
- FilePath: $(path)/../yml-basic/basic.h | ||
Offset: 298 | ||
Length: 1 | ||
ReplacementText: elem | ||
... |
17 changes: 17 additions & 0 deletions
17
clang-tools-extra/test/clang-apply-replacements/yml-basic.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: mkdir -p %T/Inputs/yml-basic | ||
// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/yml-basic/basic.h > %T/Inputs/yml-basic/basic.h | ||
// RUN: sed "s#\$(path)#%/T/Inputs/yml-basic#" %S/Inputs/yml-basic/file1.yml > %T/Inputs/yml-basic/file1.yml | ||
// RUN: sed "s#\$(path)#%/T/Inputs/yml-basic#" %S/Inputs/yml-basic/file2.yml > %T/Inputs/yml-basic/file2.yml | ||
// RUN: clang-apply-replacements %T/Inputs/yml-basic | ||
// RUN: FileCheck -input-file=%T/Inputs/yml-basic/basic.h %S/Inputs/yml-basic/basic.h | ||
// | ||
// Check that the yml files are *not* deleted after running clang-apply-replacements without remove-change-desc-files. | ||
// RUN: ls -1 %T/Inputs/yml-basic | FileCheck %s --check-prefix=YML | ||
// | ||
// Check that the yml files *are* deleted after running clang-apply-replacements with remove-change-desc-files. | ||
// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/yml-basic/basic.h > %T/Inputs/yml-basic/basic.h | ||
// RUN: clang-apply-replacements -remove-change-desc-files %T/Inputs/yml-basic | ||
// RUN: ls -1 %T/Inputs/yml-basic | FileCheck %s --check-prefix=NO_YML | ||
// | ||
// YML: {{^file.\.yml$}} | ||
// NO_YML-NOT: {{^file.\.yml$}} |