| 1 | //===-- LVSourceLanguage.cpp ----------------------------------------------===// |
|---|---|
| 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 | // This file implements LVSourceLanguage. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h" |
| 14 | #include "llvm/DebugInfo/CodeView/EnumTables.h" |
| 15 | #include "llvm/Support/ScopedPrinter.h" |
| 16 | |
| 17 | using namespace llvm; |
| 18 | using namespace llvm::logicalview; |
| 19 | |
| 20 | StringRef LVSourceLanguage::getName() const { |
| 21 | if (!isValid()) |
| 22 | return {}; |
| 23 | switch (getTag()) { |
| 24 | case LVSourceLanguage::TagDwarf: |
| 25 | return llvm::dwarf::LanguageString(Language: getLang()); |
| 26 | case LVSourceLanguage::TagCodeView: { |
| 27 | static auto LangNames = llvm::codeview::getSourceLanguageNames(); |
| 28 | return LangNames[getLang()].Name; |
| 29 | } |
| 30 | default: |
| 31 | llvm_unreachable("Unsupported language"); |
| 32 | } |
| 33 | } |
| 34 |