| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | #include "clang/Tooling/Core/Diagnostic.h" |
| 14 | #include "clang/Basic/SourceManager.h" |
| 15 | |
| 16 | namespace clang { |
| 17 | namespace tooling { |
| 18 | |
| 19 | DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message) |
| 20 | : Message(Message), FileOffset(0) {} |
| 21 | |
| 22 | DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message, |
| 23 | const SourceManager &Sources, |
| 24 | SourceLocation Loc) |
| 25 | : Message(Message), FileOffset(0) { |
| 26 | assert(Loc.isValid() && Loc.isFileID()); |
| 27 | FilePath = Sources.getFilename(Loc); |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | if (!FilePath.empty()) |
| 33 | FileOffset = Sources.getFileOffset(Loc); |
| 34 | } |
| 35 | |
| 36 | Diagnostic::Diagnostic(llvm::StringRef DiagnosticName, |
| 37 | Diagnostic::Level DiagLevel, StringRef BuildDirectory) |
| 38 | : DiagnosticName(DiagnosticName), DiagLevel(DiagLevel), |
| 39 | BuildDirectory(BuildDirectory) {} |
| 40 | |
| 41 | Diagnostic::Diagnostic(llvm::StringRef DiagnosticName, |
| 42 | const DiagnosticMessage &Message, |
| 43 | const llvm::StringMap<Replacements> &Fix, |
| 44 | const SmallVector<DiagnosticMessage, 1> &Notes, |
| 45 | Level DiagLevel, llvm::StringRef BuildDirectory) |
| 46 | : DiagnosticName(DiagnosticName), Message(Message), Fix(Fix), Notes(Notes), |
| 47 | DiagLevel(DiagLevel), BuildDirectory(BuildDirectory) {} |
| 48 | |
| 49 | } |
| 50 | } |
| 51 | |