diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 47 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenAction.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Index/SimpleFormatContext.h | 3 |
4 files changed, 25 insertions, 33 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index d2d556288d6..5d36f6c8a04 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -55,8 +55,8 @@ llvm::MemoryBuffer::BufferKind ContentCache::getMemoryBufferKind() const { // Should be unreachable, but keep for sanity. if (!Buffer.getPointer()) return llvm::MemoryBuffer::MemoryBuffer_Malloc; - - const llvm::MemoryBuffer *buf = Buffer.getPointer(); + + llvm::MemoryBuffer *buf = Buffer.getPointer(); return buf->getBufferKind(); } @@ -69,8 +69,7 @@ unsigned ContentCache::getSize() const { : (unsigned) ContentsEntry->getSize(); } -void ContentCache::replaceBuffer(const llvm::MemoryBuffer *B, - bool DoNotFree) { +void ContentCache::replaceBuffer(llvm::MemoryBuffer *B, bool DoNotFree) { if (B && B == Buffer.getPointer()) { assert(0 && "Replacing with the same buffer"); Buffer.setInt(DoNotFree? DoNotFreeFlag : 0); @@ -83,10 +82,10 @@ void ContentCache::replaceBuffer(const llvm::MemoryBuffer *B, Buffer.setInt(DoNotFree? DoNotFreeFlag : 0); } -const llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag, - const SourceManager &SM, - SourceLocation Loc, - bool *Invalid) const { +llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag, + const SourceManager &SM, + SourceLocation Loc, + bool *Invalid) const { // Lazily create the Buffer for ContentCaches that wrap files. If we already // computed it, just return what we have. if (Buffer.getPointer() || !ContentsEntry) { @@ -462,8 +461,8 @@ SourceManager::getOrCreateContentCache(const FileEntry *FileEnt, /// createMemBufferContentCache - Create a new ContentCache for the specified /// memory buffer. This does no caching. -const ContentCache* -SourceManager::createMemBufferContentCache(const MemoryBuffer *Buffer) { +const ContentCache * +SourceManager::createMemBufferContentCache(llvm::MemoryBuffer *Buffer) { // Add a new ContentCache to the MemBufferInfos list and return it. ContentCache *Entry = ContentCacheAlloc.Allocate<ContentCache>(); new (Entry) ContentCache(); @@ -505,7 +504,7 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries, /// \brief As part of recovering from missing or changed content, produce a /// fake, non-empty buffer. -const llvm::MemoryBuffer *SourceManager::getFakeBufferForRecovery() const { +llvm::MemoryBuffer *SourceManager::getFakeBufferForRecovery() const { if (!FakeBufferForRecovery) FakeBufferForRecovery = llvm::MemoryBuffer::getMemBuffer("<<<INVALID BUFFER>>"); @@ -644,16 +643,15 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo &Info, return SourceLocation::getMacroLoc(NextLocalOffset - (TokLength + 1)); } -const llvm::MemoryBuffer * -SourceManager::getMemoryBufferForFile(const FileEntry *File, - bool *Invalid) { +llvm::MemoryBuffer *SourceManager::getMemoryBufferForFile(const FileEntry *File, + bool *Invalid) { const SrcMgr::ContentCache *IR = getOrCreateContentCache(File); assert(IR && "getOrCreateContentCache() cannot return NULL"); return IR->getBuffer(Diag, *this, SourceLocation(), Invalid); } void SourceManager::overrideFileContents(const FileEntry *SourceFile, - const llvm::MemoryBuffer *Buffer, + llvm::MemoryBuffer *Buffer, bool DoNotFree) { const SrcMgr::ContentCache *IR = getOrCreateContentCache(SourceFile); assert(IR && "getOrCreateContentCache() cannot return NULL"); @@ -696,10 +694,9 @@ StringRef SourceManager::getBufferData(FileID FID, bool *Invalid) const { *Invalid = true; return "<<<<<INVALID SOURCE LOCATION>>>>>"; } - - const llvm::MemoryBuffer *Buf - = SLoc.getFile().getContentCache()->getBuffer(Diag, *this, SourceLocation(), - &MyInvalid); + + llvm::MemoryBuffer *Buf = SLoc.getFile().getContentCache()->getBuffer( + Diag, *this, SourceLocation(), &MyInvalid); if (Invalid) *Invalid = MyInvalid; @@ -1117,9 +1114,8 @@ const char *SourceManager::getCharacterData(SourceLocation SL, return "<<<<INVALID BUFFER>>>>"; } - const llvm::MemoryBuffer *Buffer - = Entry.getFile().getContentCache() - ->getBuffer(Diag, *this, SourceLocation(), &CharDataInvalid); + llvm::MemoryBuffer *Buffer = Entry.getFile().getContentCache()->getBuffer( + Diag, *this, SourceLocation(), &CharDataInvalid); if (Invalid) *Invalid = CharDataInvalid; return Buffer->getBufferStart() + (CharDataInvalid? 0 : LocInfo.second); @@ -1131,7 +1127,7 @@ const char *SourceManager::getCharacterData(SourceLocation SL, unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos, bool *Invalid) const { bool MyInvalid = false; - const llvm::MemoryBuffer *MemBuf = getBuffer(FID, &MyInvalid); + llvm::MemoryBuffer *MemBuf = getBuffer(FID, &MyInvalid); if (Invalid) *Invalid = MyInvalid; @@ -1205,8 +1201,7 @@ static void ComputeLineNumbers(DiagnosticsEngine &Diag, ContentCache *FI, llvm::BumpPtrAllocator &Alloc, const SourceManager &SM, bool &Invalid) { // Note that calling 'getBuffer()' may lazily page in the file. - const MemoryBuffer *Buffer = FI->getBuffer(Diag, SM, SourceLocation(), - &Invalid); + MemoryBuffer *Buffer = FI->getBuffer(Diag, SM, SourceLocation(), &Invalid); if (Invalid) return; @@ -1763,7 +1758,7 @@ SourceLocation SourceManager::translateLineCol(FileID FID, return FileLoc.getLocWithOffset(Size); } - const llvm::MemoryBuffer *Buffer = Content->getBuffer(Diag, *this); + llvm::MemoryBuffer *Buffer = Content->getBuffer(Diag, *this); unsigned FilePos = Content->SourceLineCache[Line - 1]; const char *Buf = Buffer->getBufferStart() + FilePos; unsigned BufLength = Buffer->getBufferSize() - FilePos; diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 18fa0fad921..3342aa12c86 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -641,14 +641,12 @@ void CodeGenAction::ExecuteAction() { bool Invalid; SourceManager &SM = CI.getSourceManager(); - const llvm::MemoryBuffer *MainFile = SM.getBuffer(SM.getMainFileID(), - &Invalid); + llvm::MemoryBuffer *MainFile = SM.getBuffer(SM.getMainFileID(), &Invalid); if (Invalid) return; llvm::SMDiagnostic Err; - TheModule.reset( - ParseIR(const_cast<MemoryBuffer *>(MainFile), Err, *VMContext)); + TheModule.reset(ParseIR(MainFile, Err, *VMContext)); if (!TheModule) { // Translate from the diagnostic info to the SourceManager location. SourceLocation Loc = SM.translateFileLineCol( diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 03a2c229d0b..b5efb14dc2e 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -884,7 +884,7 @@ static void compileModuleImpl(CompilerInstance &ImportingInstance, FrontendOpts.Inputs.push_back( FrontendInputFile("__inferred_module.map", IK)); - const llvm::MemoryBuffer *ModuleMapBuffer = + llvm::MemoryBuffer *ModuleMapBuffer = llvm::MemoryBuffer::getMemBuffer(InferredModuleMapContent); ModuleMapFile = Instance.getFileManager().getVirtualFile( "__inferred_module.map", InferredModuleMapContent.size(), 0); diff --git a/clang/lib/Index/SimpleFormatContext.h b/clang/lib/Index/SimpleFormatContext.h index 147323a7105..de1665f3b63 100644 --- a/clang/lib/Index/SimpleFormatContext.h +++ b/clang/lib/Index/SimpleFormatContext.h @@ -47,8 +47,7 @@ public: ~SimpleFormatContext() { } FileID createInMemoryFile(StringRef Name, StringRef Content) { - const llvm::MemoryBuffer *Source = - llvm::MemoryBuffer::getMemBuffer(Content); + llvm::MemoryBuffer *Source = llvm::MemoryBuffer::getMemBuffer(Content); const FileEntry *Entry = Files.getVirtualFile(Name, Source->getBufferSize(), 0); Sources.overrideFileContents(Entry, Source); |

