This is an archive of the discontinued LLVM Phabricator instance.

MC: fix layering violation introduced in r325139
ClosedPublic

Authored by royger on Mar 15 2018, 11:44 AM.

Details

Summary

Move AsmToken from MC/MCParser/MCAsmLexer.h into MC/MCAsmMacro.h in
order to avoid MCAsmMacro definition depending on MCParser.

Note that I haven't been able to even fully build test this due to the
following issue:

llvm/tools/clang/lib/Basic/SourceManager.cpp:173:17: error: no viable conversion from 'const char [5]' to 'llvm::StringLiteral'

.StartsWith("\x00\x00\xFE\xFF", "UTF-32 (BE)")
            ^~~~~~~~~~~~~~~~~~

llvm/include/llvm/ADT/StringRef.h:857:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const char [5]' to 'const llvm::StringLiteral &' for 1st argument

class StringLiteral : public StringRef {
      ^

This is not related to my change.

Diff Detail

Event Timeline

royger created this revision.Mar 15 2018, 11:44 AM
rafael edited reviewers, added: espindola; removed: rafael.Mar 15 2018, 12:13 PM
espindola accepted this revision.Mar 15 2018, 2:07 PM

LGTM

This is unfortunate, but I don't think we can do better with the current split. The alternative would be to effectively revert r325139 and have clang/llc use a single parser for all the inline assembly in a file.

This revision is now accepted and ready to land.Mar 15 2018, 2:07 PM

llvm/tools/clang/lib/Basic/SourceManager.cpp:173:17: error: no viable conversion from 'const char [5]' to 'llvm::StringLiteral'

Are you using gcc (~4.x) by any chance? Older versions of gcc seem to have issues with the StringLiteral constructor. One solution is to wrap the argument in extra {}, so something like .StartsWith({"\x00\x00\xFE\xFF"}, "UTF-32 (BE)")

llvm/tools/clang/lib/Basic/SourceManager.cpp:173:17: error: no viable conversion from 'const char [5]' to 'llvm::StringLiteral'

Are you using gcc (~4.x) by any chance? Older versions of gcc seem to have issues with the StringLiteral constructor. One solution is to wrap the argument in extra {}, so something like .StartsWith({"\x00\x00\xFE\xFF"}, "UTF-32 (BE)")

No, I'm using clang 6.0:

FreeBSD clang version 6.0.0 (branches/release_60 325330) (based on LLVM 6.0.0)

TBH I'm not sure why I get this error, IIRC this is a pre-release clang 6.0, so maybe I'm missing some patches?

Ping on this patch - would be great to get the layering violation fixed.