[clang] Avoid suggesting typoed directives in .S files
This patch is itended to avoid suggesting typoed directives in `.S` files to support the cases of `#` directives treated as comments or various pseudo-ops. The feature is implemented in https://reviews.llvm.org/D124726. Fixes: https://reviews.llvm.org/D124726#3516346. Reviewed By: nickdesaulniers Differential Revision: https://reviews.llvm.org/D125727
This commit is contained in:
parent
7694442011
commit
45e01ce5fe
@ -481,6 +481,10 @@ Optional<unsigned> Preprocessor::getSkippedRangeForExcludedConditionalBlock(
|
||||
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"
|
||||
};
|
||||
|
||||
29
clang/test/Preprocessor/suggest-typoed-directive.S
Normal file
29
clang/test/Preprocessor/suggest-typoed-directive.S
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user