This is an archive of the discontinued LLVM Phabricator instance.

[clang] Avoid suggesting typoed directives in `.S` files
ClosedPublic

Authored by ken-matsui on May 16 2022, 2:26 PM.

Details

Summary

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.

Diff Detail

Event Timeline

ken-matsui created this revision.May 16 2022, 2:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2022, 2:26 PM
ken-matsui requested review of this revision.May 16 2022, 2:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2022, 2:26 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
nickdesaulniers added inline comments.
clang/test/Preprocessor/suggest-typoed-directive.S
1

Consider adding a test:

// RUN: %clang_cc1 -fsyntax-only -verify %s -x assembler-with-cpp < %s

I don't think you need -S here or -o %t since there should be nothing produced from -fsyntax-only.

nickdesaulniers removed a subscriber: nickdesaulniers.
nickdesaulniers added inline comments.
clang/lib/Lex/PPDirectives.cpp
484

Also, IIRC the token used to start a comment in assembler differs per architecture. This might be the simplest fix, for now.

clang/test/Preprocessor/suggest-typoed-directive.S
1

Sorry, I missed a - for "read from stdin":

// RUN: %clang_cc1 -fsyntax-only -verify %s -x assembler-with-cpp - < %s
nickdesaulniers retitled this revision from Avoid suggesting typoed directives in `.S` files to [clang] Avoid suggesting typoed directives in `.S` files.May 16 2022, 2:33 PM

Update the code as reviewed

Thank you for your review! I've fixed it.

ken-matsui added inline comments.May 16 2022, 3:00 PM
clang/lib/Lex/PPDirectives.cpp
484

Ah, I did not know that. Thank you!

clang/test/Preprocessor/suggest-typoed-directive.S
1

Sorry, I meant for you to have two run lines. One that specified -x assembler-with-cpp and one without. But I think -x assembler-with-cpp is not necessary, you should/can/may drop it.

Remove -x assembler-with-cpp

Removed it 👍

clang/test/Preprocessor/suggest-typoed-directive.S
2

These three can be removed now as well. Clang will read %s as input without the need to read from stdin, which is what - < [filename] is doing.

Remove - < %s

Sorry for having missed it. Thank you!

nickdesaulniers accepted this revision.May 16 2022, 3:28 PM

thanks for the patch!

This revision is now accepted and ready to land.May 16 2022, 3:28 PM

@nickdesaulniers
Thank you for your review!

I do not have permission to land this patch, so could you please do it on my behalf?
Here is my information:
Name: Ken Matsui
Email: vcs@kmatsui.me

I do not have permission to land this patch, so could you please do it on my behalf?

Will do.

Sorry, it looks like arcanist or my PHP runtime was auto updated on my host and has regressed. I need to sort that out first.

sorted, will commit soon

This revision was landed with ongoing or failed builds.May 16 2022, 3:47 PM
This revision was automatically updated to reflect the committed changes.

I know it's retroactive, but this also LGTM. Thank you for the fix!