Skip to content

Commit a49f571

Browse files
committed
Add a tidy check to check for ". \w"
1 parent 6a28fb4 commit a49f571

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/tools/tidy/src/style.rs

+16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ C++ code used llvm_unreachable, which triggers undefined behavior
4545
when executed when assertions are disabled.
4646
Use llvm::report_fatal_error for increased robustness.";
4747

48+
const DOUBLE_SPACE_AFTER_DOT: &str = r"\
49+
Use a single space after dots in comments.";
50+
4851
const ANNOTATIONS_TO_IGNORE: &[&str] = &[
4952
"// @!has",
5053
"// @has",
@@ -405,6 +408,19 @@ pub fn check(path: &Path, bad: &mut bool) {
405408
if filename.ends_with(".cpp") && line.contains("llvm_unreachable") {
406409
err(LLVM_UNREACHABLE_INFO);
407410
}
411+
412+
// For now only enforce in compiler
413+
let is_compiler = || file.components().any(|c| c.as_os_str() == "compiler");
414+
if is_compiler()
415+
&& line.contains("//")
416+
&& line
417+
.chars()
418+
.collect::<Vec<_>>()
419+
.windows(4)
420+
.any(|cs| matches!(cs, ['.', ' ', ' ', last] if last.is_alphabetic()))
421+
{
422+
err(DOUBLE_SPACE_AFTER_DOT)
423+
}
408424
}
409425
if leading_new_lines {
410426
let mut err = |_| {

0 commit comments

Comments
 (0)