From: Balázs Kéri <1.int32@gmail.com> Date: Tue, 12 Apr 2022 07:07:28 +0000 (+0200) Subject: [clang][ASTImporter] Add import of attribute 'enable_if'. X-Git-Tag: upstream/15.0.7~10720 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b6e5fa62b80f4c0ca540e2fc0ebe3b15e50b78a;p=platform%2Fupstream%2Fllvm.git [clang][ASTImporter] Add import of attribute 'enable_if'. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D123397 --- diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index e3b3def..b368dbf 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -8583,6 +8583,13 @@ Expected ASTImporter::Import(const Attr *FromAttr) { break; } + case attr::EnableIf: { + const auto *From = cast(FromAttr); + AI.importAttr(From, AI.importArg(From->getCond()).value(), + From->getMessage()); + break; + } + case attr::AssertCapability: { const auto *From = cast(FromAttr); AI.importAttr(From, diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 1e66701..7988603 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -6634,6 +6634,15 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportFormatAttr) { EXPECT_EQ(FromAttr->getType()->getName(), ToAttr->getType()->getName()); } +TEST_P(ImportAttributes, ImportEnableIf) { + EnableIfAttr *FromAttr, *ToAttr; + importAttr( + "void test(int A) __attribute__((enable_if(A == 1, \"message\")));", + FromAttr, ToAttr); + checkImported(FromAttr->getCond(), ToAttr->getCond()); + EXPECT_EQ(FromAttr->getMessage(), ToAttr->getMessage()); +} + TEST_P(ImportAttributes, ImportGuardedVar) { GuardedVarAttr *FromAttr, *ToAttr; importAttr("int test __attribute__((guarded_var));", FromAttr,