This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG45e01ce5fe6a: [clang] Avoid suggesting typoed directives in `.S` files (authored by ken-matsui, committed by nickdesaulniers).
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" };
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" };
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits