Skip to content

Commit 680463b

Browse files
authored
Fix error that reference to PointerType is ambiguous in clang/lib/Analysis/UnsafeBufferUsage.cpp (llvm#142966)
The CI on my PR llvm#138895 is failing with errors like `clang/lib/Analysis/UnsafeBufferUsage.cpp:971:45: error: reference to 'PointerType' is ambiguous` This patch should resolve it by removing `using namespace llvm`
1 parent 9cacc41 commit 680463b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <set>
3838
#include <sstream>
3939

40-
using namespace llvm;
4140
using namespace clang;
4241

4342
#ifndef NDEBUG
@@ -474,7 +473,7 @@ static bool isSafeSpanTwoParamConstruct(const CXXConstructExpr &Node,
474473
auto HaveEqualConstantValues = [&Ctx](const Expr *E0, const Expr *E1) {
475474
if (auto E0CV = E0->getIntegerConstantExpr(Ctx))
476475
if (auto E1CV = E1->getIntegerConstantExpr(Ctx)) {
477-
return APSInt::compareValues(*E0CV, *E1CV) == 0;
476+
return llvm::APSInt::compareValues(*E0CV, *E1CV) == 0;
478477
}
479478
return false;
480479
};
@@ -485,7 +484,7 @@ static bool isSafeSpanTwoParamConstruct(const CXXConstructExpr &Node,
485484
}
486485
return false;
487486
};
488-
std::optional<APSInt> Arg1CV = Arg1->getIntegerConstantExpr(Ctx);
487+
std::optional<llvm::APSInt> Arg1CV = Arg1->getIntegerConstantExpr(Ctx);
489488

490489
if (Arg1CV && Arg1CV->isZero())
491490
// Check form 5:
@@ -528,10 +527,10 @@ static bool isSafeSpanTwoParamConstruct(const CXXConstructExpr &Node,
528527
QualType Arg0Ty = Arg0->IgnoreImplicit()->getType();
529528

530529
if (auto *ConstArrTy = Ctx.getAsConstantArrayType(Arg0Ty)) {
531-
const APSInt ConstArrSize = APSInt(ConstArrTy->getSize());
530+
const llvm::APSInt ConstArrSize = llvm::APSInt(ConstArrTy->getSize());
532531

533532
// Check form 4:
534-
return Arg1CV && APSInt::compareValues(ConstArrSize, *Arg1CV) == 0;
533+
return Arg1CV && llvm::APSInt::compareValues(ConstArrSize, *Arg1CV) == 0;
535534
}
536535
// Check form 6:
537536
if (auto CCast = dyn_cast<CStyleCastExpr>(Arg0)) {
@@ -1099,9 +1098,10 @@ static bool hasUnsafeSnprintfBuffer(const CallExpr &Node,
10991098
// explicit cast will be needed, which will make this check unreachable.
11001099
// Therefore, the array extent is same as its' bytewise size.
11011100
if (Size->EvaluateAsInt(ER, Ctx)) {
1102-
APSInt EVal = ER.Val.getInt(); // Size must have integer type
1101+
llvm::APSInt EVal = ER.Val.getInt(); // Size must have integer type
11031102

1104-
return APSInt::compareValues(EVal, APSInt(CAT->getSize(), true)) != 0;
1103+
return llvm::APSInt::compareValues(
1104+
EVal, llvm::APSInt(CAT->getSize(), true)) != 0;
11051105
}
11061106
}
11071107
}
@@ -2148,8 +2148,8 @@ namespace {
21482148
// declarations to its uses and make sure we've covered all uses with our
21492149
// analysis before we try to fix the declaration.
21502150
class DeclUseTracker {
2151-
using UseSetTy = SmallSet<const DeclRefExpr *, 16>;
2152-
using DefMapTy = DenseMap<const VarDecl *, const DeclStmt *>;
2151+
using UseSetTy = llvm::SmallSet<const DeclRefExpr *, 16>;
2152+
using DefMapTy = llvm::DenseMap<const VarDecl *, const DeclStmt *>;
21532153

21542154
// Allocate on the heap for easier move.
21552155
std::unique_ptr<UseSetTy> Uses{std::make_unique<UseSetTy>()};
@@ -3640,7 +3640,7 @@ static FixItList fixVarDeclWithArray(const VarDecl *D, const ASTContext &Ctx,
36403640
}
36413641

36423642
SmallString<32> Replacement;
3643-
raw_svector_ostream OS(Replacement);
3643+
llvm::raw_svector_ostream OS(Replacement);
36443644
OS << "std::array<" << ElemTypeTxt << ", " << ArraySizeTxt << "> "
36453645
<< IdentText->str();
36463646

@@ -4064,7 +4064,8 @@ static void applyGadgets(const Decl *D, FixableGadgetList FixableGadgets,
40644064
#endif
40654065

40664066
// Fixpoint iteration for pointer assignments
4067-
using DepMapTy = DenseMap<const VarDecl *, llvm::SetVector<const VarDecl *>>;
4067+
using DepMapTy =
4068+
llvm::DenseMap<const VarDecl *, llvm::SetVector<const VarDecl *>>;
40684069
DepMapTy DependenciesMap{};
40694070
DepMapTy PtrAssignmentGraph{};
40704071

0 commit comments

Comments
 (0)