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

Commit 2ce430a

Browse files
committed
[clang][tools] Silence const cast warning when building with Clang ToT
This fixes: ``` [4960/7446] Building C object tools\clang\tools\c-index-test\CMakeFiles\c-index-test.dir\c-index-test.c.obj C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(49,19): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] 49 | return((char*)path); | ^ C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(239,18): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] 239 | free((char *)unsaved_files[i].Filename); | ^ C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(240,18): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] 240 | free((char *)unsaved_files[i].Contents); | ^ ```
1 parent 6736cc6 commit 2ce430a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

clang/tools/c-index-test/c-index-test.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ char *basename(const char* path)
4646
else if (base2)
4747
return(base2 + 1);
4848

49-
return((char*)path);
49+
#ifdef __clang__
50+
#pragma clang diagnostic push
51+
#pragma clang diagnostic ignored "-Wcast-qual"
52+
#endif
53+
return ((char *)path);
54+
#ifdef __clang__
55+
#pragma clang diagnostic pop
56+
#endif
5057
}
5158
char *dirname(char* path)
5259
{
@@ -235,11 +242,16 @@ void free_remapped_files(struct CXUnsavedFile *unsaved_files,
235242
#ifdef __GNUC__
236243
#pragma GCC diagnostic push
237244
#pragma GCC diagnostic ignored "-Wcast-qual"
245+
#elif defined(__clang__)
246+
#pragma clang diagnostic push
247+
#pragma clang diagnostic ignored "-Wcast-qual"
238248
#endif
239249
free((char *)unsaved_files[i].Filename);
240250
free((char *)unsaved_files[i].Contents);
241251
#ifdef __GNUC__
242252
#pragma GCC diagnostic pop
253+
#elif defined(__clang__)
254+
#pragma clang diagnostic pop
243255
#endif
244256
}
245257
free(unsaved_files);

0 commit comments

Comments
 (0)