diff options
author | Michael Kruse <llvm@meinersbur.de> | 2018-06-25 20:06:13 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2018-06-25 20:06:13 +0000 |
commit | 41dd6ced2c8323aa804c3aed57f120746ab7f3fc (patch) | |
tree | bafdc35a26910c8a213596380a4bc25559485804 /clang/lib/Serialization | |
parent | 05f6626fc48b40c332c0f4d082284b39d38e23c7 (diff) | |
download | bcm5719-llvm-41dd6ced2c8323aa804c3aed57f120746ab7f3fc.tar.gz bcm5719-llvm-41dd6ced2c8323aa804c3aed57f120746ab7f3fc.zip |
Revert "Append new attributes to the end of an AttributeList."
This reverts commit r335084 as requested by David Jones and
Eric Christopher because of differences of emitted warnings.
llvm-svn: 335516
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 0daf1b3bdb7..a1ce26d27ca 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2804,25 +2804,36 @@ static bool hasSameOverloadableAttrs(const FunctionDecl *A, // Note that pass_object_size attributes are represented in the function's // ExtParameterInfo, so we don't need to check them here. - // Return false if any of the enable_if expressions of A and B are different. + SmallVector<const EnableIfAttr *, 4> AEnableIfs; + // Since this is an equality check, we can ignore that enable_if attrs show up + // in reverse order. + for (const auto *EIA : A->specific_attrs<EnableIfAttr>()) + AEnableIfs.push_back(EIA); + + SmallVector<const EnableIfAttr *, 4> BEnableIfs; + for (const auto *EIA : B->specific_attrs<EnableIfAttr>()) + BEnableIfs.push_back(EIA); + + // Two very common cases: either we have 0 enable_if attrs, or we have an + // unequal number of enable_if attrs. + if (AEnableIfs.empty() && BEnableIfs.empty()) + return true; + + if (AEnableIfs.size() != BEnableIfs.size()) + return false; + llvm::FoldingSetNodeID Cand1ID, Cand2ID; - auto AEnableIfAttrs = A->specific_attrs<EnableIfAttr>(); - auto BEnableIfAttrs = B->specific_attrs<EnableIfAttr>(); - auto AEnableIf = AEnableIfAttrs.begin(); - auto BEnableIf = BEnableIfAttrs.begin(); - for (; AEnableIf != AEnableIfAttrs.end() && BEnableIf != BEnableIfAttrs.end(); - ++BEnableIf, ++AEnableIf) { + for (unsigned I = 0, E = AEnableIfs.size(); I != E; ++I) { Cand1ID.clear(); Cand2ID.clear(); - AEnableIf->getCond()->Profile(Cand1ID, A->getASTContext(), true); - BEnableIf->getCond()->Profile(Cand2ID, B->getASTContext(), true); + AEnableIfs[I]->getCond()->Profile(Cand1ID, A->getASTContext(), true); + BEnableIfs[I]->getCond()->Profile(Cand2ID, B->getASTContext(), true); if (Cand1ID != Cand2ID) return false; } - // Return false if the number of enable_if attributes was different. - return AEnableIf == AEnableIfAttrs.end() && BEnableIf == BEnableIfAttrs.end(); + return true; } /// Determine whether the two declarations refer to the same entity. |