1 | /** |
2 | * Copyright (c) Glow Contributors. See CONTRIBUTORS file. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | #include "glow/Support/Debug.h" |
18 | |
19 | #include "llvm/Support/CommandLine.h" |
20 | |
21 | #include <string> |
22 | |
23 | using namespace glow; |
24 | |
25 | static std::string DebugOnlyType; |
26 | |
27 | /// -debug-glow - Command line option to enable DEBUG_GLOW statements. |
28 | static llvm::cl::opt<bool, true> |
29 | DebugGlow("debug-glow" , llvm::cl::desc("Enable debug output" ), |
30 | llvm::cl::Hidden, llvm::cl::location(DebugFlag)); |
31 | |
32 | /// -debug-glow-only - Command line option to enable debug output for specific |
33 | /// debug types. Multiple comma-separated debug types names can be provided. |
34 | static llvm::cl::list<std::string> |
35 | DebugGlowOnly("debug-glow-only" , |
36 | llvm::cl::desc("Enable specific types of debug output" ), |
37 | llvm::cl::CommaSeparated, llvm::cl::Hidden); |
38 | |
39 | namespace glow { |
40 | |
41 | /// Exported boolean set by -debug-glow option. |
42 | bool DebugFlag = false; |
43 | |
44 | #ifndef NDEBUG |
45 | bool isCurrentDebugType(const char *type) { |
46 | return std::find(DebugGlowOnly.begin(), DebugGlowOnly.end(), type) != |
47 | DebugGlowOnly.end(); |
48 | } |
49 | #endif |
50 | |
51 | } // namespace glow |
52 | |