File indexing completed on 2024-05-19 05:42:01
0001 // ct_lvtclp_diagnostic_consumer.h -*-C++-*- 0002 0003 /* 0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk> 0005 // SPDX-License-Identifier: Apache-2.0 0006 // 0007 // Licensed under the Apache License, Version 2.0 (the "License"); 0008 // you may not use this file except in compliance with the License. 0009 // You may obtain a copy of the License at 0010 // 0011 // http://www.apache.org/licenses/LICENSE-2.0 0012 // 0013 // Unless required by applicable law or agreed to in writing, software 0014 // distributed under the License is distributed on an "AS IS" BASIS, 0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0016 // See the License for the specific language governing permissions and 0017 // limitations under the License. 0018 */ 0019 0020 #ifndef INCLUDED_CT_LVTCLP_DIAGNOSTICS_CONSUMER 0021 #define INCLUDED_CT_LVTCLP_DIAGNOSTICS_CONSUMER 0022 0023 //@PURPOSE: Get the errros from clang and processes them. 0024 // 0025 //@CLASSES: DiagnosticConsumer: Tells clang how it should emit error messages. 0026 // 0027 //@SEE_ALSO: clang::DiagnosticConsumer 0028 0029 #include <lvtclp_export.h> 0030 0031 #include <clang/Basic/Diagnostic.h> 0032 #include <filesystem> 0033 #include <functional> 0034 #include <memory> 0035 #include <string> 0036 0037 namespace Codethink::lvtmdb { 0038 class ObjectStore; 0039 } 0040 0041 namespace Codethink::lvtclp { 0042 0043 // ============================= 0044 // class DiagnosticConsumer 0045 // ============================= 0046 0047 class LVTCLP_EXPORT DiagnosticConsumer : public clang::DiagnosticConsumer { 0048 // Class that tells clang how it should emit error messages. 0049 public: 0050 explicit DiagnosticConsumer(lvtmdb::ObjectStore& memDb, std::function<void(std::string, long)> messageCallback); 0051 ~DiagnosticConsumer() override; 0052 void HandleDiagnostic(clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic& Info) override; 0053 0054 private: 0055 struct Private; 0056 std::unique_ptr<Private> d; 0057 }; 0058 0059 } // namespace Codethink::lvtclp 0060 0061 #endif