[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-22 Thread via cfe-commits

https://github.com/smanna12 closed 
https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-22 Thread via cfe-commits

smanna12 wrote:

> My concerns are resolved, sorry for holding this!

No worries. Thank you

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-22 Thread via cfe-commits

smanna12 wrote:

Thank you everyone for reviews.

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-22 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon approved this pull request.

My concerns are resolved, sorry for holding this!

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-22 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits


@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();

Sirraide wrote:

Right, I think what I was remembering then is that we might sometimes end up w/ 
prototypeless functions in the analysis code, but we just don’t do much w/ them.

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread Doug Wyatt via cfe-commits


@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();

dougsonos wrote:

I'm mobile and away from code until Monday, but IIRC effects are stored as 
trailing objects on FunctionProtoType and we simply don't allow them on 
prototype-less functions. I think there's a custom diagnostic if the user 
tries. The test is in something like Sema/attr-nonblocking-syntax.c.

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits

https://github.com/Sirraide edited 
https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits


@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();

Sirraide wrote:

Well, also, we only get here if we’re analysing a block. Can blocks be 
prototypeless? I hope not...

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits


@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();

Sirraide wrote:

Actually, both of those questions are irrelevant because this entire code path 
is guarded by a check for `S.getLangOpts().CPlusPlus`. So yes, changing this to 
`castAs` is fine.

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits


@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();

Sirraide wrote:

> are K&R C functions supposed to support function effects?

They should yes; we had to add checks for functions w/o prototypes in several 
places to avoid crashes.

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread Mariya Podchishchaeva via cfe-commits


@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();

Fznamznon wrote:

I'm not sure that if we have a signature, we're guaranteed to have the 
FunctionProtoType. Perhaps we should leave `getAs` and check that returned 
value is not null before working with it.
@AaronBallman , any change you can help to clarify that?

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread Aaron Ballman via cfe-commits


@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();

AaronBallman wrote:

This code path is hit from:
```
  if (Context.hasAnyFunctionEffects())
performFunctionEffectAnalysis(Context.getTranslationUnitDecl());
```
and the only thing that sets `AnyFunctionEffects` is through a call to 
`ASTContext::getFunctionTypeInternal()`, which is only called for functions 
with prototypes. So I believe this change is correct as-is, but is a bit 
fragile.

CC @Sirraide @cjappl @dougsonos for extra eyes; are K&R C functions supposed to 
support function effects? If so, I suspect that doesn't work today.

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (smanna12)


Changes

This commit addresses several null pointer issues identified by static analysis 
by replacing dyn_cast<> with cast<> and getAs<> with 
castAs<> in various parts of the Clang codebase. The cast and castAs 
method is used to ensure that the type is correctly cast, which helps prevent 
potential null pointer dereferences.

Changes:
1. ASTContext.cpp:
   Replaced dyn_cast with cast to ensure that the type is correctly cast to 
AttributedType.

2. SemaFunctionEffects.cpp:
 Replaced getAs with castAs to ensure that the type is correctly cast to 
FunctionProtoType.

3. SemaHLSL.cpp:
  Replaced getAs with castAs to ensure that the type is correctly cast to 
VectorType.

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


3 Files Affected:

- (modified) clang/lib/AST/ASTContext.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaFunctionEffects.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaHLSL.cpp (+2-2) 


``diff
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 14fbadbc35ae5d..23df7878a3bf29 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3558,7 +3558,7 @@ ASTContext::adjustType(QualType Orig,
llvm::function_ref Adjust) const {
   switch (Orig->getTypeClass()) {
   case Type::Attributed: {
-const auto *AT = dyn_cast(Orig);
+const auto *AT = cast(Orig);
 return getAttributedType(AT->getAttrKind(),
  adjustType(AT->getModifiedType(), Adjust),
  adjustType(AT->getEquivalentType(), Adjust),
diff --git a/clang/lib/Sema/SemaFunctionEffects.cpp 
b/clang/lib/Sema/SemaFunctionEffects.cpp
index 6fe4d2353a2282..c5c1e3fb41a2ff 100644
--- a/clang/lib/Sema/SemaFunctionEffects.cpp
+++ b/clang/lib/Sema/SemaFunctionEffects.cpp
@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();
 IsNoexcept = FPT->isNothrow() || BD->hasAttr();
   }
 }
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index f4fc0f2ddc27a6..a1adc66ddb9ce9 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1908,9 +1908,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 // ensure both args have 3 elements
 int NumElementsArg1 =
-TheCall->getArg(0)->getType()->getAs()->getNumElements();
+TheCall->getArg(0)->getType()->casAs()->getNumElements();
 int NumElementsArg2 =
-TheCall->getArg(1)->getType()->getAs()->getNumElements();
+TheCall->getArg(1)->getType()->castAs()->getNumElements();
 
 if (NumElementsArg1 != 3) {
   int LessOrMore = NumElementsArg1 > 3 ? 1 : 0;

``




https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits


@@ -1908,9 +1908,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 // ensure both args have 3 elements
 int NumElementsArg1 =
-TheCall->getArg(0)->getType()->getAs()->getNumElements();
+TheCall->getArg(0)->getType()->casAs()->getNumElements();

smanna12 wrote:

Done

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits

https://github.com/smanna12 updated 
https://github.com/llvm/llvm-project/pull/117176

>From 1b6b411291b4d7cfd830d43609eaddc65b0f2c56 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Thu, 21 Nov 2024 07:25:11 -0800
Subject: [PATCH 1/2] [Clang] Prevent potential null pointer dereferences

---
 clang/lib/AST/ASTContext.cpp   | 2 +-
 clang/lib/Sema/SemaFunctionEffects.cpp | 2 +-
 clang/lib/Sema/SemaHLSL.cpp| 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 14fbadbc35ae5d..23df7878a3bf29 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3558,7 +3558,7 @@ ASTContext::adjustType(QualType Orig,
llvm::function_ref Adjust) const {
   switch (Orig->getTypeClass()) {
   case Type::Attributed: {
-const auto *AT = dyn_cast(Orig);
+const auto *AT = cast(Orig);
 return getAttributedType(AT->getAttrKind(),
  adjustType(AT->getModifiedType(), Adjust),
  adjustType(AT->getEquivalentType(), Adjust),
diff --git a/clang/lib/Sema/SemaFunctionEffects.cpp 
b/clang/lib/Sema/SemaFunctionEffects.cpp
index 6fe4d2353a2282..c5c1e3fb41a2ff 100644
--- a/clang/lib/Sema/SemaFunctionEffects.cpp
+++ b/clang/lib/Sema/SemaFunctionEffects.cpp
@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();
 IsNoexcept = FPT->isNothrow() || BD->hasAttr();
   }
 }
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index f4fc0f2ddc27a6..a1adc66ddb9ce9 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1908,9 +1908,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 // ensure both args have 3 elements
 int NumElementsArg1 =
-TheCall->getArg(0)->getType()->getAs()->getNumElements();
+TheCall->getArg(0)->getType()->casAs()->getNumElements();
 int NumElementsArg2 =
-TheCall->getArg(1)->getType()->getAs()->getNumElements();
+TheCall->getArg(1)->getType()->castAs()->getNumElements();
 
 if (NumElementsArg1 != 3) {
   int LessOrMore = NumElementsArg1 > 3 ? 1 : 0;

>From dd7c34b8309e744e329b10ec5270444bb455a00c Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Thu, 21 Nov 2024 07:38:00 -0800
Subject: [PATCH 2/2] Address review comments

---
 clang/lib/Sema/SemaHLSL.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index a1adc66ddb9ce9..0c70d4e5cff25c 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1908,7 +1908,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 // ensure both args have 3 elements
 int NumElementsArg1 =
-TheCall->getArg(0)->getType()->casAs()->getNumElements();
+TheCall->getArg(0)->getType()->castAs()->getNumElements();
 int NumElementsArg2 =
 TheCall->getArg(1)->getType()->castAs()->getNumElements();
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: None (smanna12)


Changes

This commit addresses several null pointer issues identified by static analysis 
by replacing dyn_cast<> with cast<> and getAs<> with 
castAs<> in various parts of the Clang codebase. The cast and castAs 
method is used to ensure that the type is correctly cast, which helps prevent 
potential null pointer dereferences.

Changes:
1. ASTContext.cpp:
   Replaced dyn_cast with cast to ensure that the type is correctly cast to 
AttributedType.

2. SemaFunctionEffects.cpp:
 Replaced getAs with castAs to ensure that the type is correctly cast to 
FunctionProtoType.

3. SemaHLSL.cpp:
  Replaced getAs with castAs to ensure that the type is correctly cast to 
VectorType.

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


3 Files Affected:

- (modified) clang/lib/AST/ASTContext.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaFunctionEffects.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaHLSL.cpp (+2-2) 


``diff
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 14fbadbc35ae5d..23df7878a3bf29 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3558,7 +3558,7 @@ ASTContext::adjustType(QualType Orig,
llvm::function_ref Adjust) const {
   switch (Orig->getTypeClass()) {
   case Type::Attributed: {
-const auto *AT = dyn_cast(Orig);
+const auto *AT = cast(Orig);
 return getAttributedType(AT->getAttrKind(),
  adjustType(AT->getModifiedType(), Adjust),
  adjustType(AT->getEquivalentType(), Adjust),
diff --git a/clang/lib/Sema/SemaFunctionEffects.cpp 
b/clang/lib/Sema/SemaFunctionEffects.cpp
index 6fe4d2353a2282..c5c1e3fb41a2ff 100644
--- a/clang/lib/Sema/SemaFunctionEffects.cpp
+++ b/clang/lib/Sema/SemaFunctionEffects.cpp
@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();
 IsNoexcept = FPT->isNothrow() || BD->hasAttr();
   }
 }
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index f4fc0f2ddc27a6..a1adc66ddb9ce9 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1908,9 +1908,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 // ensure both args have 3 elements
 int NumElementsArg1 =
-TheCall->getArg(0)->getType()->getAs()->getNumElements();
+TheCall->getArg(0)->getType()->casAs()->getNumElements();
 int NumElementsArg2 =
-TheCall->getArg(1)->getType()->getAs()->getNumElements();
+TheCall->getArg(1)->getType()->castAs()->getNumElements();
 
 if (NumElementsArg1 != 3) {
   int LessOrMore = NumElementsArg1 > 3 ? 1 : 0;

``




https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread Steven Perron via cfe-commits


@@ -1908,9 +1908,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 // ensure both args have 3 elements
 int NumElementsArg1 =
-TheCall->getArg(0)->getType()->getAs()->getNumElements();
+TheCall->getArg(0)->getType()->casAs()->getNumElements();

s-perron wrote:

```suggestion
TheCall->getArg(0)->getType()->castAs()->getNumElements();
```

https://github.com/llvm/llvm-project/pull/117176
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Prevent potential null pointer dereferences (PR #117176)

2024-11-21 Thread via cfe-commits

https://github.com/smanna12 created 
https://github.com/llvm/llvm-project/pull/117176

This commit addresses several null pointer issues identified by static analysis 
by replacing dyn_cast<> with cast<> and getAs<> with castAs<> in various parts 
of the Clang codebase. The cast and castAs method is used to ensure that the 
type is correctly cast, which helps prevent potential null pointer dereferences.

Changes:
1. ASTContext.cpp:
   Replaced dyn_cast with cast to ensure that the type is correctly cast to 
AttributedType.

2. SemaFunctionEffects.cpp:
 Replaced getAs with castAs to ensure that the type is correctly cast to 
FunctionProtoType.

3. SemaHLSL.cpp:
  Replaced getAs with castAs to ensure that the type is correctly cast to 
VectorType.

>From 1b6b411291b4d7cfd830d43609eaddc65b0f2c56 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Thu, 21 Nov 2024 07:25:11 -0800
Subject: [PATCH] [Clang] Prevent potential null pointer dereferences

---
 clang/lib/AST/ASTContext.cpp   | 2 +-
 clang/lib/Sema/SemaFunctionEffects.cpp | 2 +-
 clang/lib/Sema/SemaHLSL.cpp| 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 14fbadbc35ae5d..23df7878a3bf29 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3558,7 +3558,7 @@ ASTContext::adjustType(QualType Orig,
llvm::function_ref Adjust) const {
   switch (Orig->getTypeClass()) {
   case Type::Attributed: {
-const auto *AT = dyn_cast(Orig);
+const auto *AT = cast(Orig);
 return getAttributedType(AT->getAttrKind(),
  adjustType(AT->getModifiedType(), Adjust),
  adjustType(AT->getEquivalentType(), Adjust),
diff --git a/clang/lib/Sema/SemaFunctionEffects.cpp 
b/clang/lib/Sema/SemaFunctionEffects.cpp
index 6fe4d2353a2282..c5c1e3fb41a2ff 100644
--- a/clang/lib/Sema/SemaFunctionEffects.cpp
+++ b/clang/lib/Sema/SemaFunctionEffects.cpp
@@ -627,7 +627,7 @@ class Analyzer {
   IsNoexcept = isNoexcept(FD);
 } else if (auto *BD = dyn_cast(D)) {
   if (auto *TSI = BD->getSignatureAsWritten()) {
-auto *FPT = TSI->getType()->getAs();
+auto *FPT = TSI->getType()->castAs();
 IsNoexcept = FPT->isNothrow() || BD->hasAttr();
   }
 }
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index f4fc0f2ddc27a6..a1adc66ddb9ce9 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1908,9 +1908,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 // ensure both args have 3 elements
 int NumElementsArg1 =
-TheCall->getArg(0)->getType()->getAs()->getNumElements();
+TheCall->getArg(0)->getType()->casAs()->getNumElements();
 int NumElementsArg2 =
-TheCall->getArg(1)->getType()->getAs()->getNumElements();
+TheCall->getArg(1)->getType()->castAs()->getNumElements();
 
 if (NumElementsArg1 != 3) {
   int LessOrMore = NumElementsArg1 > 3 ? 1 : 0;

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits