Debian Codegraph @

clang/lib/AST/ByteCode/InterpShared.cpp

raw
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 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 interp
42 } // namespace clang