Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

Commit 6f8b633

Browse files
committed
[compiler-rt] Silence warnings when building with Clang ToT
Fixes several warnings such as: ``` C:\git\llvm-project\compiler-rt\lib\profile\InstrProfilingFile.c(760,18): warning: cast from 'const char *' to 'void *' drops const qualifier [-Wcast-qual] 760 | free((void *)lprofCurFilename.FilenamePat); | ^ 3 warnings generated. ```
1 parent 935c652 commit 6f8b633

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,10 +702,15 @@ static void resetFilenameToDefault(void) {
702702
#ifdef __GNUC__
703703
#pragma GCC diagnostic push
704704
#pragma GCC diagnostic ignored "-Wcast-qual"
705+
#elif defined(__clang__)
706+
#pragma clang diagnostic push
707+
#pragma clang diagnostic ignored "-Wcast-qual"
705708
#endif
706709
free((void *)lprofCurFilename.FilenamePat);
707710
#ifdef __GNUC__
708711
#pragma GCC diagnostic pop
712+
#elif defined(__clang__)
713+
#pragma clang diagnostic pop
709714
#endif
710715
}
711716
memset(&lprofCurFilename, 0, sizeof(lprofCurFilename));
@@ -751,6 +756,9 @@ static int parseFilenamePattern(const char *FilenamePat,
751756
#ifdef __GNUC__
752757
#pragma GCC diagnostic push
753758
#pragma GCC diagnostic ignored "-Wcast-qual"
759+
#elif defined(__clang__)
760+
#pragma clang diagnostic push
761+
#pragma clang diagnostic ignored "-Wcast-qual"
754762
#endif
755763
/* Clean up cached prefix and filename. */
756764
if (lprofCurFilename.ProfilePathPrefix)
@@ -761,6 +769,8 @@ static int parseFilenamePattern(const char *FilenamePat,
761769
}
762770
#ifdef __GNUC__
763771
#pragma GCC diagnostic pop
772+
#elif defined(__clang__)
773+
#pragma clang diagnostic pop
764774
#endif
765775

766776
memset(&lprofCurFilename, 0, sizeof(lprofCurFilename));

compiler-rt/lib/profile/InstrProfilingMerge.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ uint64_t lprofGetLoadModuleSignature(void) {
4141
#ifdef __GNUC__
4242
#pragma GCC diagnostic push
4343
#pragma GCC diagnostic ignored "-Wcast-qual"
44+
#elif defined(__clang__)
45+
#pragma clang diagnostic push
46+
#pragma clang diagnostic ignored "-Wcast-qual"
4447
#endif
4548

4649
/* Returns 1 if profile is not structurally compatible. */
@@ -234,4 +237,6 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
234237

235238
#ifdef __GNUC__
236239
#pragma GCC diagnostic pop
240+
#elif defined(__clang__)
241+
#pragma clang diagnostic pop
237242
#endif

compiler-rt/lib/profile/InstrProfilingValue.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,15 @@ __llvm_profile_set_num_value_sites(__llvm_profile_data *Data,
6262
#ifdef __GNUC__
6363
#pragma GCC diagnostic push
6464
#pragma GCC diagnostic ignored "-Wcast-qual"
65+
#elif defined(__clang__)
66+
#pragma clang diagnostic push
67+
#pragma clang diagnostic ignored "-Wcast-qual"
6568
#endif
6669
*((uint16_t *)&Data->NumValueSites[ValueKind]) = NumValueSites;
6770
#ifdef __GNUC__
6871
#pragma GCC diagnostic pop
72+
#elif defined(__clang__)
73+
#pragma clang diagnostic pop
6974
#endif
7075
}
7176

0 commit comments

Comments
 (0)