[compiler-rt] r353787 - [sanitizer] Don't compile GetPathAssumingFileIsRelativeToExec on Fuchsia
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 11 17:36:08 PST 2019
Author: phosek
Date: Mon Feb 11 17:36:08 2019
New Revision: 353787
URL: http://llvm.org/viewvc/llvm-project?rev=353787&view=rev
Log:
[sanitizer] Don't compile GetPathAssumingFileIsRelativeToExec on Fuchsia
This avoids the unused function warning during compilation.
Differential Revision: https://reviews.llvm.org/D58082
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc?rev=353787&r1=353786&r2=353787&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc Mon Feb 11 17:36:08 2019
@@ -30,6 +30,7 @@ SuppressionContext::SuppressionContext(c
internal_memset(has_suppression_type_, 0, suppression_types_num_);
}
+#if !SANITIZER_FUCHSIA
static bool GetPathAssumingFileIsRelativeToExec(const char *file_path,
/*out*/char *new_file_path,
uptr new_file_path_size) {
@@ -46,20 +47,30 @@ static bool GetPathAssumingFileIsRelativ
return false;
}
+static const char *FindFile(const char *file_path,
+ /*out*/char *new_file_path,
+ uptr new_file_path_size) {
+ // If we cannot find the file, check if its location is relative to
+ // the location of the executable.
+ if (!FileExists(file_path) && !IsAbsolutePath(file_path) &&
+ GetPathAssumingFileIsRelativeToExec(file_path, new_file_path,
+ new_file_path_size)) {
+ return new_file_path;
+ }
+ return file_path;
+}
+#else
+static const char *FindFile(const char *file_path, char *, uptr) {
+ return file_path;
+}
+#endif
+
void SuppressionContext::ParseFromFile(const char *filename) {
if (filename[0] == '\0')
return;
-#if !SANITIZER_FUCHSIA
- // If we cannot find the file, check if its location is relative to
- // the location of the executable.
InternalScopedString new_file_path(kMaxPathLength);
- if (!FileExists(filename) && !IsAbsolutePath(filename) &&
- GetPathAssumingFileIsRelativeToExec(filename, new_file_path.data(),
- new_file_path.size())) {
- filename = new_file_path.data();
- }
-#endif // !SANITIZER_FUCHSIA
+ filename = FindFile(filename, new_file_path.data(), new_file_path.size());
// Read the file.
VPrintf(1, "%s: reading suppressions file at %s\n",
More information about the llvm-commits
mailing list