ken-matsui updated this revision to Diff 429869. ken-matsui added a comment.
Update the code as reviewed 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 -x assembler-with-cpp - < %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 -x assembler-with-cpp - < %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