Files
swift-mirror/unittests/Basic/DemangleTest.cpp
Davide Italiano dbe5ee77b8 [Demangler] Implement isObjCSymbol().
This function can be queried to find out whether the passed
mangled name is an Objective-C symbol. This will be used
in the debugger to replace an hardcoded check that would
break if the mangling prefix changed.

<rdar://problem/44467875>
2018-09-18 11:32:16 -07:00

33 lines
1.2 KiB
C++

//===--- DemangleTest.cpp -------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#include "swift/Demangling/Demangle.h"
#include "gtest/gtest.h"
using namespace swift::Demangle;
TEST(Demangle, DemangleWrappers) {
EXPECT_EQ("", demangleSymbolAsString(llvm::StringRef("")));
std::string MangledName = "_TtV1a1b\\\t\n\r\"\'\x1f\x20\x7e\x7f";
MangledName += '\0';
EXPECT_EQ("a.b with unmangled suffix \"\\\\\\t\\n\\r\\\"'\\x1F ~\\x7F\\0\"",
demangleSymbolAsString(MangledName));
}
TEST(Demangle, IsObjCSymbol) {
EXPECT_EQ("type metadata accessor for __C.NSNumber",
demangleSymbolAsString(llvm::StringRef("_$SSo8NSNumberCMa")));
EXPECT_EQ(true, isObjCSymbol(llvm::StringRef("_$SSo8NSNumberCMa")));
EXPECT_EQ(false,
isObjCSymbol(llvm::StringRef("_$S3pat7inlinedSo8NSNumberCvp")));
}