1

これは非常に単純な質問だと思いますが、解決できません。とても悲しい。そう。私がする時

llc.exe -march=cpp test.bc 

次のコードで興味深い test.cpp を取得します。

AttrListPtr func__Z2f1i_PAL;
{
 SmallVector<AttributeWithIndex, 4> Attrs;
 AttributeWithIndex PAWI;
 PAWI.Index = 4294967295U; PAWI.Attrs = Attribute::None  | Attribute::NoUnwind;
 Attrs.push_back(PAWI);
 func__Z2f1i_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
}

しかし、次のような文字列を書きたいときPAWI.Attrs = Attribute::None | Attribute::NoUnwind;

私のプロジェクトでエラーが発生しました IntelliSense: no operator "=" matches these operands operand types are: llvm::Attributes = int何をする必要がありますか? 必要なすべてのヘッダーが含まれています。[OS - Windows 7 x64、LLVM - 3.2]

4

1 に答える 1

1

cpp バックエンドがこのコードを生成する理由がわかりません。いずれにせよ、属性の扱いは 3.2 で変更されました (3.3 で再び変更されます)。3.2 で属性を取得する適切な方法は次のとおりです。

Attributes::get(Context, Attributes::NoUnwind)

(複数の値で属性セットを初期化するために、いつでもここで ArrayRef を 2 番目の引数として渡すことができます)。

関数に属性を追加する最も簡単な方法は次のとおりです。

Function->addFnAttr(Attributes::NoUnwind)

そして、あなたがしたい場合AttributeWithIndex

AttributeWithIndex::get(Context, ID, Attributes::NoUnwind)
// OR:
AttributeWithIndex::get(ID, Attributes::get(Context, Attributes::NoUnwind))
于 2013-05-01T07:04:50.477 に答える