clang  19.0.0git
OptReportHandler.h
Go to the documentation of this file.
1 //===------------------------ OptReportHandler.h ----------------*- 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 /// \file
10 /// Defines clang::SyclOptReportHandler class.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_BASIC_OPTREPORTHANDLER_H
15 #define LLVM_CLANG_BASIC_OPTREPORTHANDLER_H
16 
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/StringRef.h"
20 
21 namespace clang {
22 
23 class FunctionDecl;
24 
26 private:
27  struct OptReportInfo {
28  std::string KernelArgDescName; // Kernel argument name itself, or the name
29  // of the parent class if the kernel argument
30  // is a decomposed member.
31  std::string KernelArgType;
32  SourceLocation KernelArgLoc;
33  unsigned KernelArgSize;
34  std::string KernelArgDesc;
35  std::string KernelArgDecomposedField;
36 
37  OptReportInfo(std::string ArgDescName, std::string ArgType,
38  SourceLocation ArgLoc, unsigned ArgSize, std::string ArgDesc,
39  std::string ArgDecomposedField)
40  : KernelArgDescName(std::move(ArgDescName)),
41  KernelArgType(std::move(ArgType)), KernelArgLoc(ArgLoc),
42  KernelArgSize(ArgSize), KernelArgDesc(std::move(ArgDesc)),
43  KernelArgDecomposedField(std::move(ArgDecomposedField)) {}
44  };
45  llvm::DenseMap<const FunctionDecl *, SmallVector<OptReportInfo>> Map;
46 
47 public:
48  void AddKernelArgs(const FunctionDecl *FD, StringRef ArgDescName,
49  StringRef ArgType, SourceLocation ArgLoc, unsigned ArgSize,
50  StringRef ArgDesc, StringRef ArgDecomposedField) {
51  Map[FD].emplace_back(ArgDescName.data(), ArgType.data(), ArgLoc, ArgSize,
52  ArgDesc.data(), ArgDecomposedField.data());
53  }
55  auto It = Map.find(FD);
56  assert(It != Map.end());
57  return It->second;
58  }
59  bool HasOptReportInfo(const FunctionDecl *FD) const {
60  return Map.find(FD) != Map.end();
61  }
62 };
63 
64 } // namespace clang
65 
66 #endif // LLVM_CLANG_BASIC_OPTREPORTHANDLER_H
Defines the clang::SourceLocation class and associated facilities.
Represents a function declaration or definition.
Definition: Decl.h:1972
Encodes a location in the source.
SmallVector< OptReportInfo > & GetInfo(const FunctionDecl *FD)
void AddKernelArgs(const FunctionDecl *FD, StringRef ArgDescName, StringRef ArgType, SourceLocation ArgLoc, unsigned ArgSize, StringRef ArgDesc, StringRef ArgDecomposedField)
bool HasOptReportInfo(const FunctionDecl *FD) const
The JSON file list parser is used to communicate input to InstallAPI.