diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 16 | ||||
| -rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 6 | ||||
| -rw-r--r-- | clang/tools/libclang/CIndexCodeCompletion.cpp | 18 | 
4 files changed, 20 insertions, 26 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index 73d6e7f7b2b..43b203a334e 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -14,10 +14,10 @@  #include "llvm/ADT/OwningPtr.h"  #include "llvm/ADT/STLExtras.h"  #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/Atomic.h"  #include "llvm/Support/MemoryBuffer.h"  #include "llvm/Support/Path.h"  #include "llvm/Support/YAMLParser.h" +#include <atomic>  using namespace clang;  using namespace clang::vfs; @@ -828,8 +828,8 @@ vfs::getVFSFromYAML(MemoryBuffer *Buffer, SourceMgr::DiagHandlerTy DiagHandler,  }  UniqueID vfs::getNextVirtualUniqueID() { -  static volatile sys::cas_flag UID = 0; -  sys::cas_flag ID = llvm::sys::AtomicIncrement(&UID); +  static std::atomic<unsigned> UID; +  unsigned ID = ++UID;    // The following assumes that uint64_t max will never collide with a real    // dev_t value from the OS.    return UniqueID(std::numeric_limits<uint64_t>::max(), ID); diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 913bbc77dd3..cbdfa33453f 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -36,7 +36,6 @@  #include "llvm/ADT/ArrayRef.h"  #include "llvm/ADT/StringExtras.h"  #include "llvm/ADT/StringSet.h" -#include "llvm/Support/Atomic.h"  #include "llvm/Support/CrashRecoveryContext.h"  #include "llvm/Support/Host.h"  #include "llvm/Support/MemoryBuffer.h" @@ -45,6 +44,7 @@  #include "llvm/Support/Path.h"  #include "llvm/Support/Timer.h"  #include "llvm/Support/raw_ostream.h" +#include <atomic>  #include <cstdio>  #include <cstdlib>  #include <sys/stat.h> @@ -211,7 +211,7 @@ const unsigned DefaultPreambleRebuildInterval = 5;  /// \brief Tracks the number of ASTUnit objects that are currently active.  ///  /// Used for debugging purposes only. -static llvm::sys::cas_flag ActiveASTUnitObjects; +static std::atomic<unsigned> ActiveASTUnitObjects;  ASTUnit::ASTUnit(bool _MainFileIsAST)    : Reader(0), HadModuleLoaderFatalFailure(false), @@ -228,10 +228,8 @@ ASTUnit::ASTUnit(bool _MainFileIsAST)      PreambleTopLevelHashValue(0),      CurrentTopLevelHashValue(0),      UnsafeToFree(false) {  -  if (getenv("LIBCLANG_OBJTRACKING")) { -    llvm::sys::AtomicIncrement(&ActiveASTUnitObjects); -    fprintf(stderr, "+++ %d translation units\n", (int)ActiveASTUnitObjects); -  }     +  if (getenv("LIBCLANG_OBJTRACKING")) +    fprintf(stderr, "+++ %u translation units\n", ++ActiveASTUnitObjects);  }  ASTUnit::~ASTUnit() { @@ -264,10 +262,8 @@ ASTUnit::~ASTUnit() {    ClearCachedCompletionResults();   -  if (getenv("LIBCLANG_OBJTRACKING")) { -    llvm::sys::AtomicDecrement(&ActiveASTUnitObjects); -    fprintf(stderr, "--- %d translation units\n", (int)ActiveASTUnitObjects); -  }     +  if (getenv("LIBCLANG_OBJTRACKING")) +    fprintf(stderr, "--- %u translation units\n", --ActiveASTUnitObjects);  }  void ASTUnit::setPreprocessor(Preprocessor *pp) { PP = pp; } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index c2571d716a6..85aae236b8a 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -28,13 +28,13 @@  #include "llvm/Option/ArgList.h"  #include "llvm/Option/OptTable.h"  #include "llvm/Option/Option.h" -#include "llvm/Support/Atomic.h"  #include "llvm/Support/ErrorHandling.h"  #include "llvm/Support/FileSystem.h"  #include "llvm/Support/Host.h"  #include "llvm/Support/Path.h"  #include "llvm/Support/Process.h"  #include "llvm/Support/system_error.h" +#include <atomic>  #include <sys/stat.h>  using namespace clang; @@ -1883,8 +1883,8 @@ void BuryPointer(const void *Ptr) {    // is what we want in such case.    static const size_t kGraveYardMaxSize = 16;    LLVM_ATTRIBUTE_UNUSED static const void *GraveYard[kGraveYardMaxSize]; -  static llvm::sys::cas_flag GraveYardSize; -  llvm::sys::cas_flag Idx = llvm::sys::AtomicIncrement(&GraveYardSize) - 1; +  static std::atomic<unsigned> GraveYardSize; +  unsigned Idx = GraveYardSize++;    if (Idx >= kGraveYardMaxSize)      return;    GraveYard[Idx] = Ptr; diff --git a/clang/tools/libclang/CIndexCodeCompletion.cpp b/clang/tools/libclang/CIndexCodeCompletion.cpp index ca4960cc265..e13e3e18a25 100644 --- a/clang/tools/libclang/CIndexCodeCompletion.cpp +++ b/clang/tools/libclang/CIndexCodeCompletion.cpp @@ -30,13 +30,13 @@  #include "clang/Sema/Sema.h"  #include "llvm/ADT/SmallString.h"  #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/Atomic.h"  #include "llvm/Support/CrashRecoveryContext.h"  #include "llvm/Support/FileSystem.h"  #include "llvm/Support/MemoryBuffer.h"  #include "llvm/Support/Program.h"  #include "llvm/Support/Timer.h"  #include "llvm/Support/raw_ostream.h" +#include <atomic>  #include <cstdio>  #include <cstdlib>  #include <string> @@ -315,7 +315,7 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults {  /// currently active.  ///  /// Used for debugging purposes only. -static llvm::sys::cas_flag CodeCompletionResultObjects; +static std::atomic<unsigned> CodeCompletionResultObjects;  AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults(                                        const FileSystemOptions& FileSystemOpts) @@ -332,10 +332,9 @@ AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults(      ContainerKind(CXCursor_InvalidCode),      ContainerIsIncomplete(1)  {  -  if (getenv("LIBCLANG_OBJTRACKING")) { -    llvm::sys::AtomicIncrement(&CodeCompletionResultObjects); -    fprintf(stderr, "+++ %d completion results\n", CodeCompletionResultObjects); -  }     +  if (getenv("LIBCLANG_OBJTRACKING")) +    fprintf(stderr, "+++ %u completion results\n", +            ++CodeCompletionResultObjects);  }  AllocatedCXCodeCompleteResults::~AllocatedCXCodeCompleteResults() { @@ -346,10 +345,9 @@ AllocatedCXCodeCompleteResults::~AllocatedCXCodeCompleteResults() {    for (unsigned I = 0, N = TemporaryBuffers.size(); I != N; ++I)      delete TemporaryBuffers[I]; -  if (getenv("LIBCLANG_OBJTRACKING")) { -    llvm::sys::AtomicDecrement(&CodeCompletionResultObjects); -    fprintf(stderr, "--- %d completion results\n", CodeCompletionResultObjects); -  }     +  if (getenv("LIBCLANG_OBJTRACKING")) +    fprintf(stderr, "--- %u completion results\n", +            --CodeCompletionResultObjects);  }  } // end extern "C"  | 

