Author: abataev Date: Thu Oct 10 08:15:26 2019 New Revision: 374363 URL: http://llvm.org/viewvc/llvm-project?rev=374363&view=rev Log: [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. Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp cfe/trunk/test/OpenMP/declare_variant_ast_print.c cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=374363&r1=374362&r2=374363&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original) +++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Oct 10 08:15:26 2019 @@ -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<llvm::SmallString<16>, 4> Vendors; + llvm::UniqueVector<llvm::SmallString<16>> Vendors; do { // Parse <vendor>. 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<StringRef, 4> 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); } Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.c?rev=374363&r1=374362&r2=374363&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/declare_variant_ast_print.c (original) +++ cfe/trunk/test/OpenMP/declare_variant_ast_print.c Thu Oct 10 08:15:26 2019 @@ -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(); Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp?rev=374363&r1=374362&r2=374363&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp (original) +++ cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp Thu Oct 10 08:15:26 2019 @@ -40,7 +40,7 @@ int bar(); #pragma omp declare variant(foofoo <T>) match(user = {condition(<expr>)}) #pragma omp declare variant(foofoo <T>) match(implementation={vendor(llvm)}) #pragma omp declare variant(foofoo <T>) match(implementation={vendor(unknown)}) -#pragma omp declare variant(foofoo <T>) match(implementation={vendor(score(C+5): ibm, xxx)}) +#pragma omp declare variant(foofoo <T>) match(implementation={vendor(score(C+5): ibm, xxx, ibm)}) template <typename T, int C> T barbar(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits