Skip to content

Commit

Permalink
feat: update llvm 17.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiNahida committed Jan 24, 2024
1 parent 88865df commit 94d8cd7
Show file tree
Hide file tree
Showing 16 changed files with 9,342 additions and 2,634 deletions.
46 changes: 46 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Left
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: true
PadOperators: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowAllArgumentsOnNextLine: false
AlignOperands: AlignAfterOperator
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AllowShortLambdasOnASingleLine: All
AllowShortBlocksOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
BreakBeforeBinaryOperators: NonAssignment
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerIndentWidth: 0
IndentWidth: 4
Language: Cpp
MaxEmptyLinesToKeep: 2
PackConstructorInitializers: CurrentLine
PointerAlignment: Left
TabWidth: 4
UseTab: Never
SortIncludes: CaseSensitive
4 changes: 4 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Diagnostics:
Suppress: ["-Wmicrosoft-enum-forward-reference", "-Wc++11-narrowing"]
CompileFlags:
Add: ["-ferror-limit=0", "-D__FUNCTION__=\"dummy\"", "-D_CRT_USE_BUILTIN_OFFSETOF"]
28 changes: 12 additions & 16 deletions include/demangler/Demangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <cstddef>
#include <string>
#include <string_view>

namespace demangler {
/// This is a llvm local version of __cxa_demangle. Other than the name and
Expand All @@ -28,8 +29,10 @@ enum : int {
demangle_success = 0,
};

char* itaniumDemangle(const char* mangled_name, char* buf, size_t* n,
int* status);
/// Returns a non-NULL pointer to a NUL-terminated C style string
/// that should be explicitly freed, if successful. Otherwise, may return
/// nullptr if mangled_name is not a valid mangling or is nullptr.
char* itaniumDemangle(std::string_view mangled_name);

enum MSDemangleFlags {
MSDF_None = 0,
Expand All @@ -46,31 +49,24 @@ enum MSDemangleFlags {
/// success, or nullptr on error.
/// If n_read is non-null and demangling was successful, it receives how many
/// bytes of the input string were consumed.
/// buf can point to a *n_buf bytes large buffer where the demangled name is
/// stored. If the buffer is too small, it is grown with realloc(). If buf is
/// nullptr, then this malloc()s memory for the result.
/// *n_buf stores the size of buf on input if buf is non-nullptr, and it
/// receives the size of the demangled string on output if n_buf is not nullptr.
/// status receives one of the demangle_ enum entries above if it's not nullptr.
/// Flags controls various details of the demangled representation.
char* microsoftDemangle(const char* mangled_name, size_t* n_read, char* buf,
size_t* n_buf, int* status,
MSDemangleFlags Flags = MSDF_None);
char* microsoftDemangle(std::string_view mangled_name, size_t* n_read, int* status, MSDemangleFlags Flags = MSDF_None);

// Demangles a Rust v0 mangled symbol.
char* rustDemangle(const char* MangledName);
char* rustDemangle(std::string_view MangledName);

// Demangles a D mangled symbol.
char* dlangDemangle(const char* MangledName);
char* dlangDemangle(std::string_view MangledName);

/// Attempt to demangle a string using different demangling schemes.
/// The function uses heuristics to determine which demangling scheme to use.
/// \param MangledName - reference to string to demangle.
/// \returns - the demangled string, or a copy of the input string if no
/// demangling occurred.
std::string demangle(const std::string& MangledName);
std::string demangle(std::string_view MangledName);

bool nonMicrosoftDemangle(const char* MangledName, std::string& Result);
bool nonMicrosoftDemangle(std::string_view MangledName, std::string& Result);

/// "Partial" demangler. This supports demangling a string into an AST
/// (typically an intermediate stage in itaniumDemangle) and querying certain
Expand All @@ -87,7 +83,7 @@ struct ItaniumPartialDemangler {
bool partialDemangle(const char* MangledName);

/// Just print the entire mangled name into Buf. Buf and N behave like the
/// second and third parameters to itaniumDemangle.
/// second and third parameters to __cxa_demangle.
char* finishDemangle(char* Buf, size_t* N) const;

/// Get the base name of a function. This doesn't include trailing template
Expand Down Expand Up @@ -128,6 +124,6 @@ struct ItaniumPartialDemangler {
void* RootNode;
void* Context;
};
} // namespace llvm
} // namespace demangler

#endif
15 changes: 7 additions & 8 deletions include/demangler/DemangleConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@

#ifndef DEMANGLE_GNUC_PREREQ
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
#define DEMANGLE_GNUC_PREREQ(maj, min, patch) \
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \
((maj) << 20) + ((min) << 10) + (patch))
#define DEMANGLE_GNUC_PREREQ(maj, min, patch) \
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= ((maj) << 20) + ((min) << 10) + (patch))
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
#define DEMANGLE_GNUC_PREREQ(maj, min, patch) \
#define DEMANGLE_GNUC_PREREQ(maj, min, patch) \
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10))
#else
#define DEMANGLE_GNUC_PREREQ(maj, min, patch) 0
Expand Down Expand Up @@ -86,11 +85,11 @@
#define DEMANGLE_FALLTHROUGH
#endif

#define DEMANGLE_NAMESPACE_BEGIN \
namespace demangler { \
#define DEMANGLE_NAMESPACE_BEGIN \
namespace demangler { \
namespace itanium_demangle {
#define DEMANGLE_NAMESPACE_END \
} \
#define DEMANGLE_NAMESPACE_END \
} \
}

#endif
Loading

0 comments on commit 94d8cd7

Please sign in to comment.