[llvm-commits] [ASan/Win] Eliminate a couple of FIXMEs, add NORETURN to CheckFailed/UNIMPLEMENTED (issue 5754102)

timurrrr at google.com timurrrr at google.com
Tue Mar 13 07:01:19 PDT 2012


Reviewers: glider,

Message:
Hi Alexander,

Can you please review this patch?

Thanks,
Timur

Description:
Eliminate a couple of FIXMEs, add NORETURN to CheckFailed/UNIMPLEMENTED

Please review this at http://codereview.appspot.com/5754102/

Affected files:
   M lib/asan/asan_internal.h
   M lib/asan/asan_win.cc


Index: lib/asan/asan_internal.h
diff --git a/lib/asan/asan_internal.h b/lib/asan/asan_internal.h
index  
42e8829f3bb74eabc7d017d596cc1ad80bc65256..dfc5af2149299274537459cef2039102da322861  
100644
--- a/lib/asan/asan_internal.h
+++ b/lib/asan/asan_internal.h
@@ -38,6 +38,7 @@ extern "C" void* _ReturnAddress(void);
  # define ALIAS(x)   // TODO(timurrrr): do we need this on Windows?
  # define ALIGNED(x) __declspec(align(x))
  # define NOINLINE __declspec(noinline)
+# define NORETURN __declspec(noreturn)

  # define ASAN_INTERFACE_ATTRIBUTE  // TODO(timurrrr): do we need this on  
Win?
  #else  // defined(_WIN32)
@@ -46,6 +47,7 @@ extern "C" void* _ReturnAddress(void);
  # define ALIAS(x) __attribute__((alias(x)))
  # define ALIGNED(x) __attribute__((aligned(x)))
  # define NOINLINE __attribute__((noinline))
+# define NORETURN __attribute__((noreturn))

  # define ASAN_INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
  #endif  // defined(_WIN32)
@@ -145,7 +147,8 @@ class AsanThread;
  struct AsanStackTrace;

  // asan_rtl.cc
-void CheckFailed(const char *cond, const char *file, int line);
+void NORETURN CheckFailed(const char *cond, const char *file, int line);
+
  void ShowStatsAndAbort();

  // asan_globals.cc
Index: lib/asan/asan_win.cc
diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc
index  
53d6777b669b71683e5d413a0b9ddbe52cd214f0..4222baab798af4890735816843c5ecccfef61048  
100644
--- a/lib/asan/asan_win.cc
+++ b/lib/asan/asan_win.cc
@@ -15,7 +15,6 @@
  #include <windows.h>

  #include <dbghelp.h>
-#include <stdio.h>  // FIXME: get rid of this.
  #include <stdlib.h>

  #include <new>  // FIXME: temporarily needed for placement new in AsanLock.
@@ -72,17 +71,14 @@ size_t AsanWrite(int fd, const void *buf, size_t count)  
{
  // code unreachable on Windows. We should clean this up.
  int AsanOpenReadonly(const char* filename) {
    UNIMPLEMENTED();
-  return -1;
  }

  size_t AsanRead(int fd, void *buf, size_t count) {
    UNIMPLEMENTED();
-  return -1;
  }

  int AsanClose(int fd) {
    UNIMPLEMENTED();
-  return -1;
  }

  // ---------------------- Stacktraces, symbols, etc. ---------------- {{{1
@@ -204,7 +200,6 @@ void AsanLock::Unlock() {
  // ---------------------- TSD ---------------- {{{1
  static bool tsd_key_inited = false;

-// FIXME: is __declspec enough?
  static __declspec(thread) void *fake_tsd = NULL;

  void AsanTSDInit(void (*destructor)(void *tsd)) {
@@ -240,7 +235,12 @@ int AtomicInc(int *a) {
  }

  const char* AsanGetEnv(const char* name) {
-  // FIXME: implement.
+  // Note: this implementation is not re-entrant but we only call this  
function
+  // from one place now.
+  static char env_buffer[32767] = {};
+  DWORD rv = GetEnvironmentVariableA(name, env_buffer, sizeof(env_buffer));
+  if (rv > 0 && rv < sizeof(env_buffer))
+    return env_buffer;
    return NULL;
  }






More information about the llvm-commits mailing list