[PATCH] D125727: [clang] Avoid suggesting typoed directives in `.S` files
Ken Matsui via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 16 15:23:47 PDT 2022
ken-matsui updated this revision to Diff 429877.
ken-matsui added a comment.
Remove `- < %s`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125727/new/
https://reviews.llvm.org/D125727
Files:
clang/lib/Lex/PPDirectives.cpp
clang/test/Preprocessor/suggest-typoed-directive.S
Index: clang/test/Preprocessor/suggest-typoed-directive.S
===================================================================
--- /dev/null
+++ clang/test/Preprocessor/suggest-typoed-directive.S
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#ifdef UNDEFINED
+#id
+#ifd
+#ifde
+#elf
+#elsif
+#elseif
+#elfidef
+#elfindef
+#elfinndef
+#els
+#endi
+#endif
+
+#ifdef UNDEFINED
+# in in order to perform
+#endif
+
+#ifdef UNDEFINED
+#i
+#endif
+
+#if special_compiler
+#special_compiler_directive
+#endif
Index: clang/lib/Lex/PPDirectives.cpp
===================================================================
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -481,6 +481,10 @@
void Preprocessor::SuggestTypoedDirective(const Token &Tok,
StringRef Directive,
const SourceLocation &EndLoc) const {
+ // If this is a `.S` file, treat unknown # directives as non-preprocessor
+ // directives.
+ if (getLangOpts().AsmPreprocessor) return;
+
std::vector<StringRef> Candidates = {
"if", "ifdef", "ifndef", "elif", "else", "endif"
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125727.429877.patch
Type: text/x-patch
Size: 1198 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220516/85e623a8/attachment-0001.bin>
More information about the cfe-commits
mailing list