43 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "InterpShared.h"10#include "clang/AST/Attr.h"11#include "llvm/ADT/BitVector.h"12 13namespace clang {14namespace interp {15 16llvm::BitVector collectNonNullArgs(const FunctionDecl *F,17 ArrayRef<const Expr *> Args) {18 llvm::BitVector NonNullArgs;19 20 assert(F);21 assert(F->hasAttr<NonNullAttr>());22 NonNullArgs.resize(Args.size());23 24 for (const auto *Attr : F->specific_attrs<NonNullAttr>()) {25 if (!Attr->args_size()) {26 NonNullArgs.set();27 break;28 }29 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 interp42} // namespace clang43