forked from GPUOpen-Drivers/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged master:169c83208f3 into amd-gfx:b84e3982f0d
Local branch amd-gfx b84e398 Merged master:1cf6f210a2e into amd-gfx:042be23e3d9 Remote branch master 169c832 [ldb/Reproducers] Add YamlRecorder and MultiProvider
- Loading branch information
Showing
87 changed files
with
1,585 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// UNSUPPORTED: s390x | ||
// RUN: %clang_cl /c /Z7 /Fo%t.obj -- %s | ||
// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s | ||
// RUN: %clang_cl /c /Z7 /Fo%t.obj -fdebug-compilation-dir . -- %s | ||
// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE | ||
|
||
int main() { return 42; } | ||
|
||
// CHECK: Types (.debug$T) | ||
// CHECK: ============================================================ | ||
// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: [[PWDVAL:.+]] | ||
// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]] | ||
// CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: | ||
// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: [[TOOLVAL:.+[\\/]clang.*]] | ||
// CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: "-cc1 | ||
// CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}] | ||
// CHECK: 0x[[PWD]]: `[[PWDVAL]]` | ||
// CHECK: 0x[[TOOL]]: `[[TOOLVAL]]` | ||
// CHECK: 0x[[FILEPATH]]: `[[FILEPATHVAL]]` | ||
// CHECK: 0x[[ZIPDB]]: `` | ||
// CHECK: 0x[[CMDLINE]]: `"-cc1 | ||
|
||
// RELATIVE: Types (.debug$T) | ||
// RELATIVE: ============================================================ | ||
// RELATIVE: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}] | ||
// RELATIVE: 0x{{.+}}: `.` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//===-- Implementation of strchr ------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "src/string/strchr.h" | ||
#include "src/string/strlen.h" | ||
|
||
#include "src/__support/common.h" | ||
|
||
namespace __llvm_libc { | ||
|
||
// TODO: Look at performance benefits of comparing words. | ||
char *LLVM_LIBC_ENTRYPOINT(strchr)(const char *src, int c) { | ||
unsigned char *str = | ||
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(src)); | ||
const unsigned char ch = c; | ||
for (; *str && *str != ch; ++str) | ||
; | ||
return *str == ch ? reinterpret_cast<char *>(str) : nullptr; | ||
} | ||
|
||
} // namespace __llvm_libc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===-- Implementation header for strchr ------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SRC_STRING_STRCHR_H | ||
#define LLVM_LIBC_SRC_STRING_STRCHR_H | ||
|
||
namespace __llvm_libc { | ||
|
||
char *strchr(const char *src, int c); | ||
|
||
} // namespace __llvm_libc | ||
|
||
#endif // LLVM_LIBC_SRC_STRING_STRCHR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
//===-- Unittests for strchr ----------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "src/string/strchr.h" | ||
#include "utils/UnitTest/Test.h" | ||
|
||
TEST(StrChrTest, FindsFirstCharacter) { | ||
const char *src = "abcde"; | ||
const char *src_copy = src; | ||
|
||
// Should return original string since 'a' is the first character. | ||
ASSERT_STREQ(__llvm_libc::strchr(src, 'a'), "abcde"); | ||
// Source string should not change. | ||
ASSERT_STREQ(src, src_copy); | ||
} | ||
|
||
TEST(StrChrTest, FindsMiddleCharacter) { | ||
const char *src = "abcde"; | ||
const char *src_copy = src; | ||
|
||
// Should return characters after (and including) 'c'. | ||
ASSERT_STREQ(__llvm_libc::strchr(src, 'c'), "cde"); | ||
// Source string should not change. | ||
ASSERT_STREQ(src, src_copy); | ||
} | ||
|
||
TEST(StrChrTest, FindsLastCharacterThatIsNotNullTerminator) { | ||
const char *src = "abcde"; | ||
const char *src_copy = src; | ||
|
||
// Should return 'e' and null-terminator. | ||
ASSERT_STREQ(__llvm_libc::strchr(src, 'e'), "e"); | ||
// Source string should not change. | ||
ASSERT_STREQ(src, src_copy); | ||
} | ||
|
||
TEST(StrChrTest, FindsNullTerminator) { | ||
const char *src = "abcde"; | ||
const char *src_copy = src; | ||
|
||
// Should return null terminator. | ||
ASSERT_STREQ(__llvm_libc::strchr(src, '\0'), ""); | ||
// Source string should not change. | ||
ASSERT_STREQ(src, src_copy); | ||
} | ||
|
||
TEST(StrChrTest, CharacterNotWithinStringShouldReturnNullptr) { | ||
// Since 'z' is not within the string, should return nullptr. | ||
ASSERT_STREQ(__llvm_libc::strchr("123?", 'z'), nullptr); | ||
} | ||
|
||
TEST(StrChrTest, TheSourceShouldNotChange) { | ||
const char *src = "abcde"; | ||
const char *src_copy = src; | ||
// When the character is found, the source string should not change. | ||
__llvm_libc::strchr(src, 'd'); | ||
ASSERT_STREQ(src, src_copy); | ||
// Same case for when the character is not found. | ||
__llvm_libc::strchr(src, 'z'); | ||
ASSERT_STREQ(src, src_copy); | ||
// Same case for when looking for nullptr. | ||
__llvm_libc::strchr(src, '\0'); | ||
ASSERT_STREQ(src, src_copy); | ||
} | ||
|
||
TEST(StrChrTest, ShouldFindFirstOfDuplicates) { | ||
// '1' is duplicated in the string, but it should find the first copy. | ||
ASSERT_STREQ(__llvm_libc::strchr("abc1def1ghi", '1'), "1def1ghi"); | ||
|
||
const char *dups = "XXXXX"; | ||
// Should return original string since 'X' is the first character. | ||
ASSERT_STREQ(__llvm_libc::strchr(dups, 'X'), dups); | ||
} | ||
|
||
TEST(StrChrTest, EmptyStringShouldOnlyMatchNullTerminator) { | ||
// Null terminator should match. | ||
ASSERT_STREQ(__llvm_libc::strchr("", '\0'), ""); | ||
// All other characters should not match. | ||
ASSERT_STREQ(__llvm_libc::strchr("", 'Z'), nullptr); | ||
ASSERT_STREQ(__llvm_libc::strchr("", '3'), nullptr); | ||
ASSERT_STREQ(__llvm_libc::strchr("", '*'), nullptr); | ||
} |
Oops, something went wrong.