[cfe-commits] r160224 - /cfe/trunk/lib/AST/ASTImporter.cpp
Eric Christopher
echristo at apple.com
Sat Jul 14 17:23:58 PDT 2012
Author: echristo
Date: Sat Jul 14 19:23:57 2012
New Revision: 160224
URL: http://llvm.org/viewvc/llvm-project?rev=160224&view=rev
Log:
Replace IsSameValue with the llvm::APSInt/llvm::APInt versions
that we just copied from here and replace all uses.
Part of rdar://11875995
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=160224&r1=160223&r2=160224&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Sat Jul 14 19:23:57 2012
@@ -237,45 +237,6 @@
static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
Decl *D1, Decl *D2);
-/// \brief Determine if two APInts have the same value, after zero-extending
-/// one of them (if needed!) to ensure that the bit-widths match.
-static bool IsSameValue(const llvm::APInt &I1, const llvm::APInt &I2) {
- if (I1.getBitWidth() == I2.getBitWidth())
- return I1 == I2;
-
- if (I1.getBitWidth() > I2.getBitWidth())
- return I1 == I2.zext(I1.getBitWidth());
-
- return I1.zext(I2.getBitWidth()) == I2;
-}
-
-/// \brief Determine if two APSInts have the same value, zero- or sign-extending
-/// as needed.
-static bool IsSameValue(const llvm::APSInt &I1, const llvm::APSInt &I2) {
- if (I1.getBitWidth() == I2.getBitWidth() && I1.isSigned() == I2.isSigned())
- return I1 == I2;
-
- // Check for a bit-width mismatch.
- if (I1.getBitWidth() > I2.getBitWidth())
- return IsSameValue(I1, I2.extend(I1.getBitWidth()));
- else if (I2.getBitWidth() > I1.getBitWidth())
- return IsSameValue(I1.extend(I2.getBitWidth()), I2);
-
- // We have a signedness mismatch. Turn the signed value into an unsigned
- // value.
- if (I1.isSigned()) {
- if (I1.isNegative())
- return false;
-
- return llvm::APSInt(I1, true) == I2;
- }
-
- if (I2.isNegative())
- return false;
-
- return I1 == llvm::APSInt(I2, true);
-}
-
/// \brief Determine structural equivalence of two expressions.
static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
Expr *E1, Expr *E2) {
@@ -322,7 +283,7 @@
Arg2.getIntegralType()))
return false;
- return IsSameValue(Arg1.getAsIntegral(), Arg2.getAsIntegral());
+ return llvm::APSInt::isSameValue(Arg1.getAsIntegral(), Arg2.getAsIntegral());
case TemplateArgument::Declaration:
if (!Arg1.getAsDecl() || !Arg2.getAsDecl())
@@ -467,7 +428,7 @@
case Type::ConstantArray: {
const ConstantArrayType *Array1 = cast<ConstantArrayType>(T1);
const ConstantArrayType *Array2 = cast<ConstantArrayType>(T2);
- if (!IsSameValue(Array1->getSize(), Array2->getSize()))
+ if (!llvm::APInt::isSameValue(Array1->getSize(), Array2->getSize()))
return false;
if (!IsArrayStructurallyEquivalent(Context, Array1, Array2))
@@ -1053,7 +1014,7 @@
llvm::APSInt Val1 = EC1->getInitVal();
llvm::APSInt Val2 = EC2->getInitVal();
- if (!IsSameValue(Val1, Val2) ||
+ if (!llvm::APSInt::isSameValue(Val1, Val2) ||
!IsStructurallyEquivalent(EC1->getIdentifier(), EC2->getIdentifier())) {
Context.Diag2(D2->getLocation(), diag::warn_odr_tag_type_inconsistent)
<< Context.C2.getTypeDeclType(D2);
More information about the cfe-commits
mailing list