Skip to content

Fix error that reference to PointerType is ambiguous in clang/lib/Analysis/UnsafeBufferUsage.cpp #142966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions clang/lib/Analysis/UnsafeBufferUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <set>
#include <sstream>

using namespace llvm;
using namespace clang;

#ifndef NDEBUG
Expand Down Expand Up @@ -474,7 +473,7 @@ static bool isSafeSpanTwoParamConstruct(const CXXConstructExpr &Node,
auto HaveEqualConstantValues = [&Ctx](const Expr *E0, const Expr *E1) {
if (auto E0CV = E0->getIntegerConstantExpr(Ctx))
if (auto E1CV = E1->getIntegerConstantExpr(Ctx)) {
return APSInt::compareValues(*E0CV, *E1CV) == 0;
return llvm::APSInt::compareValues(*E0CV, *E1CV) == 0;
}
return false;
};
Expand All @@ -485,7 +484,7 @@ static bool isSafeSpanTwoParamConstruct(const CXXConstructExpr &Node,
}
return false;
};
std::optional<APSInt> Arg1CV = Arg1->getIntegerConstantExpr(Ctx);
std::optional<llvm::APSInt> Arg1CV = Arg1->getIntegerConstantExpr(Ctx);

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

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

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

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

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

SmallString<32> Replacement;
raw_svector_ostream OS(Replacement);
llvm::raw_svector_ostream OS(Replacement);
OS << "std::array<" << ElemTypeTxt << ", " << ArraySizeTxt << "> "
<< IdentText->str();

Expand Down Expand Up @@ -4064,7 +4064,8 @@ static void applyGadgets(const Decl *D, FixableGadgetList FixableGadgets,
#endif

// Fixpoint iteration for pointer assignments
using DepMapTy = DenseMap<const VarDecl *, llvm::SetVector<const VarDecl *>>;
using DepMapTy =
llvm::DenseMap<const VarDecl *, llvm::SetVector<const VarDecl *>>;
DepMapTy DependenciesMap{};
DepMapTy PtrAssignmentGraph{};

Expand Down
Loading