1 //===--- InterpShared.cpp ---------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "InterpShared.h" 10 #include "clang/AST/Attr.h" 11 #include "llvm/ADT/BitVector.h" 12 13 namespace clang { 14 namespace interp { 15 16 llvm::BitVector collectNonNullArgs(const FunctionDecl *F, 17 const llvm::ArrayRef<const Expr *> &Args) { 18 llvm::BitVector NonNullArgs; 19 if (!F) 20 return NonNullArgs; 21 22 assert(F); 23 NonNullArgs.resize(Args.size()); 24 25 for (const auto *Attr : F->specific_attrs<NonNullAttr>()) { 26 if (!Attr->args_size()) { 27 NonNullArgs.set(); 28 break; 29 } else 30 for (auto Idx : Attr->args()) { 31 unsigned ASTIdx = Idx.getASTIndex(); 32 if (ASTIdx >= Args.size()) 33 continue; 34 NonNullArgs[ASTIdx] = true; 35 } 36 } 37 38 return NonNullArgs; 39 } 40 41 } // namespace interp 42 } // namespace clang 43