diff options
author | Marina Yatsina <marina.yatsina@intel.com> | 2015-12-29 08:49:34 +0000 |
---|---|---|
committer | Marina Yatsina <marina.yatsina@intel.com> | 2015-12-29 08:49:34 +0000 |
commit | b94e85d194919b5ab11862713b74da82021a4178 (patch) | |
tree | c718a2d8c1b26059d41e2b673568fb899c194ffe /lib/Sema/SemaStmtAsm.cpp | |
parent | a17defeefcbfef958a0f7785665b558e8e260303 (diff) | |
download | clang-b94e85d194919b5ab11862713b74da82021a4178.tar.gz |
[ms inline asm] Add support for label names with '$' chars
In MS inline asm syntax a label with '$' char produces an error, while in AT&T it does not.
In AT&T inline asm syntax Clang escapes the '$' char and replaces it with "$$". Adopted same approach for MS syntax.
Differential Revision: http://reviews.llvm.org/D15795
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256545 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmtAsm.cpp')
-rw-r--r-- | lib/Sema/SemaStmtAsm.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index 2917c5a360..0d6e0f8e41 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -750,7 +750,15 @@ LabelDecl *Sema::GetOrCreateMSAsmLabel(StringRef ExternalLabelName, // Create an internal name for the label. The name should not be a valid mangled // name, and should be unique. We use a dot to make the name an invalid mangled // name. - OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << ExternalLabelName; + OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__"; + for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end(); + ++it) { + OS << *it; + if (*it == '$') { + // We escape '$' in asm strings by replacing it with "$$" + OS << '$'; + } + } Label->setMSAsmLabel(OS.str()); } if (AlwaysCreate) { |