[clang] Fix label (de-)serialization in ASM statements.

Differential Revision: https://reviews.llvm.org/D151073
This commit is contained in:
Viktoriia Bakalova 2023-05-22 10:10:49 +00:00
parent 9e7f14a821
commit 6b50e87f21
3 changed files with 30 additions and 2 deletions

View File

@ -400,8 +400,10 @@ void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
// Labels
for (unsigned I = 0, N = NumLabels; I != N; ++I)
for (unsigned I = 0, N = NumLabels; I != N; ++I) {
Names.push_back(Record.readIdentifier());
Exprs.push_back(Record.readSubStmt());
}
S->setOutputsAndInputsAndClobbers(Record.getContext(),
Names.data(), Constraints.data(),

View File

@ -317,7 +317,10 @@ void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt *S) {
Record.AddStmt(S->getClobberStringLiteral(I));
// Labels
for (auto *E : S->labels()) Record.AddStmt(E);
for (unsigned I = 0, N = S->getNumLabels(); I != N; ++I) {
Record.AddIdentifierRef(S->getLabelIdentifier(I));
Record.AddStmt(S->getLabelExpr(I));
}
Code = serialization::STMT_GCCASM;
}

View File

@ -0,0 +1,23 @@
// RUN: %clang_cc1 -emit-pch %s -o %t
// RUN: %clang_cc1 -include-pch %t %s -verify
#ifndef HEADER_H
#define HEADER_H
template<int = 0>
void MyMethod() {
void *bar;
some_path:
asm goto
(
"mov %w[foo], %w[foo]"
: [foo] "=r"(bar)
: [foo2] "r"(bar), [foo3] "r"(bar), [foo4] "r"(bar)
:
: some_path
);
}
#else
void test() {
MyMethod();
// expected-no-diagnostics
}
#endif