Skip to content

Conversation

@abhina-sree
Copy link
Contributor

@abhina-sree abhina-sree commented Jun 5, 2025

The CI on my PR #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

@abhina-sree abhina-sree self-assigned this Jun 5, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:analysis labels Jun 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-analysis

Author: Abhina Sree (abhina-sree)

Changes

The CI on my PR #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 specifying clang::


Full diff: https://github.com/llvm/llvm-project/pull/142966.diff

1 Files Affected:

  • (modified) clang/lib/Analysis/UnsafeBufferUsage.cpp (+4-4)
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index ec648e1a17af9..e874a483afed5 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -247,11 +247,11 @@ class MatchDescendantVisitor : public DynamicRecursiveASTVisitor {
 
 // Because we're dealing with raw pointers, let's define what we mean by that.
 static bool hasPointerType(const Expr &E) {
-  return isa<PointerType>(E.getType().getCanonicalType());
+  return isa<clang::PointerType>(E.getType().getCanonicalType());
 }
 
 static bool hasArrayType(const Expr &E) {
-  return isa<ArrayType>(E.getType().getCanonicalType());
+  return isa<clang::ArrayType>(E.getType().getCanonicalType());
 }
 
 static void
@@ -968,7 +968,7 @@ static bool hasUnsafePrintfStringArg(const CallExpr &Node, ASTContext &Ctx,
   if (!FirstParmTy->isPointerType())
     return false; // possibly some user-defined printf function
 
-  QualType FirstPteTy = FirstParmTy->castAs<PointerType>()->getPointeeType();
+  QualType FirstPteTy = FirstParmTy->castAs<clang::PointerType>()->getPointeeType();
 
   if (!Ctx.getFILEType()
            .isNull() && //`FILE *` must be in the context if it is fprintf
@@ -1052,7 +1052,7 @@ static bool hasUnsafeSnprintfBuffer(const CallExpr &Node,
   if (!FirstParmTy->isPointerType())
     return false; // Not an snprint
 
-  QualType FirstPteTy = FirstParmTy->castAs<PointerType>()->getPointeeType();
+  QualType FirstPteTy = FirstParmTy->castAs<clang::PointerType>()->getPointeeType();
   const Expr *Buf = Node.getArg(0), *Size = Node.getArg(1);
 
   if (FirstPteTy.isConstQualified() || !Buf->getType()->isPointerType() ||

@abhina-sree abhina-sree changed the title Fix error that reference to PointerType is ambiguous Fix error that reference to PointerType is ambiguous in clang/lib/Analysis/UnsafeBufferUsage.cpp Jun 5, 2025
@github-actions
Copy link

github-actions bot commented Jun 5, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@abhina-sree abhina-sree force-pushed the abhina/fix_build_err branch from 4850d42 to f536c94 Compare June 5, 2025 13:50
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I would also consider dropping the "using namespace llvm" instead. This seems a bit unusual for a file in clang/lib/Analysis.

@abhina-sree
Copy link
Contributor Author

LGTM, but I would also consider dropping the "using namespace llvm" instead. This seems a bit unusual for a file in clang/lib/Analysis.

Thanks! I've implemented your suggested solution instead

@abhina-sree abhina-sree merged commit 680463b into llvm:main Jun 5, 2025
11 checks passed
@abhina-sree abhina-sree deleted the abhina/fix_build_err branch June 5, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:analysis clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants