diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e1e9f3c6b17b..d29cc687de3b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5907,22 +5907,19 @@ void CodeGenModule::generateIntelFPGAAnnotation( } } -/** - * Adds global Intel FPGA annotations for a given variable declaration. - * This function handles both simple global variables and fields within - * structs that are annotated with Intel FPGA attributes. For structs, - * it recursively visits all fields and base classes to collect annotations. - * - * @param VD The variable declaration to annotate. - * @param GV The LLVM GlobalValue corresponding to the variable declaration. - */ +/// Adds global Intel FPGA annotations for a given variable declaration. +/// This function handles both simple global variables and fields within +/// structs that are annotated with Intel FPGA attributes. For structs, +/// it recursively visits all fields and base classes to collect annotations. +/// \param VD The variable declaration to annotate. +/// \param GV The LLVM GlobalValue corresponding to the variable declaration. void CodeGenModule::addGlobalIntelFPGAAnnotation(const VarDecl *VD, llvm::GlobalValue *GV) { SmallString<256> AnnotStr; // Handle annotations for fields within a device_global struct. if (getLangOpts().IntelFPGA && VD->getType()->isRecordType()) { - auto RT = VD->getType()->getAs(); + auto RT = VD->getType()->castAs(); auto Gen = [&AnnotStr, this](const RecordType *Ty, auto &&Gen) -> void { const CXXRecordDecl *RD = cast(Ty->getDecl()); @@ -5939,11 +5936,11 @@ void CodeGenModule::addGlobalIntelFPGAAnnotation(const VarDecl *VD, } // Iterate over the base classes of the struct. - for (const auto Base : RD->bases()) { + for (const auto &Base : RD->bases()) { QualType BaseTy = Base.getType(); - if (const auto *BRT = BaseTy->getAs()) - Gen(BRT, Gen); + const auto *BRT = BaseTy->castAs(); + Gen(BRT, Gen); } }; Gen(RT, Gen);