From: Alexey Bataev Date: Thu, 10 Oct 2019 15:15:26 +0000 (+0000) Subject: [OPENMP50]Register vendor name only once in vendor context selector. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20b3d56a1f44ea1972f39422f21dcc1e2d6f9f87;p=clang [OPENMP50]Register vendor name only once in vendor context selector. No need to store multiple copies of the same vendor names in the context selector, keep only single copy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374363 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseOpenMP.cpp b/lib/Parse/ParseOpenMP.cpp index 82a4e70055..760cec258f 100644 --- a/lib/Parse/ParseOpenMP.cpp +++ b/lib/Parse/ParseOpenMP.cpp @@ -17,6 +17,7 @@ #include "clang/Parse/RAIIObjectsForParser.h" #include "clang/Sema/Scope.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/UniqueVector.h" using namespace clang; @@ -853,7 +854,7 @@ static void parseImplementationSelector( (void)T.expectAndConsume(diag::err_expected_lparen_after, CtxSelectorName.data()); const ExprResult Score = parseContextScore(P); - SmallVector, 4> Vendors; + llvm::UniqueVector> Vendors; do { // Parse . StringRef VendorName; @@ -862,7 +863,7 @@ static void parseImplementationSelector( VendorName = P.getPreprocessor().getSpelling(P.getCurToken(), Buffer); (void)P.ConsumeToken(); if (!VendorName.empty()) - Vendors.push_back(VendorName); + Vendors.insert(VendorName); } else { P.Diag(Tok.getLocation(), diag::err_omp_declare_variant_item_expected) << "vendor identifier" @@ -878,10 +879,10 @@ static void parseImplementationSelector( (void)T.consumeClose(); if (!Vendors.empty()) { SmallVector ImplVendors(Vendors.size()); - for (int I = 0, E = Vendors.size(); I < E; ++I) - ImplVendors[I] = Vendors[I]; + llvm::copy(Vendors, ImplVendors.begin()); Sema::OpenMPDeclareVariantCtsSelectorData Data( - OMPDeclareVariantAttr::CtxSetImplementation, CSKind, ImplVendors, + OMPDeclareVariantAttr::CtxSetImplementation, CSKind, + llvm::makeMutableArrayRef(ImplVendors.begin(), ImplVendors.size()), Score); Callback(SourceRange(Loc, Tok.getLocation()), Data); } diff --git a/test/OpenMP/declare_variant_ast_print.c b/test/OpenMP/declare_variant_ast_print.c index a8a11bc53d..971211c1e9 100644 --- a/test/OpenMP/declare_variant_ast_print.c +++ b/test/OpenMP/declare_variant_ast_print.c @@ -11,7 +11,7 @@ int foo(void); #pragma omp declare variant(foo) match(implementation={vendor(llvm)}) #pragma omp declare variant(foo) match(implementation={vendor(llvm), xxx}) #pragma omp declare variant(foo) match(implementation={vendor(unknown)}) -#pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm, xxx)}) +#pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm, xxx, ibm)}) int bar(void); // CHECK: int foo(); diff --git a/test/OpenMP/declare_variant_ast_print.cpp b/test/OpenMP/declare_variant_ast_print.cpp index ce67b818f3..a026febfb5 100644 --- a/test/OpenMP/declare_variant_ast_print.cpp +++ b/test/OpenMP/declare_variant_ast_print.cpp @@ -40,7 +40,7 @@ int bar(); #pragma omp declare variant(foofoo ) match(user = {condition()}) #pragma omp declare variant(foofoo ) match(implementation={vendor(llvm)}) #pragma omp declare variant(foofoo ) match(implementation={vendor(unknown)}) -#pragma omp declare variant(foofoo ) match(implementation={vendor(score(C+5): ibm, xxx)}) +#pragma omp declare variant(foofoo ) match(implementation={vendor(score(C+5): ibm, xxx, ibm)}) template T barbar();