From 109ae73ec71a1d27358510ce049b59637b4a6b40 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 3 Dec 2009 17:05:59 +0000 Subject: [PATCH] Minor cleanup to the code-completion-point logic suggested by Chris. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90459 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/Preprocessor.h | 2 +- lib/Basic/SourceManager.cpp | 3 +-- lib/Lex/Preprocessor.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 939444167b..cd202e5899 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -507,7 +507,7 @@ public: /// \brief Determine if this source location refers into the file /// for which we are performing code completion. - bool isCodeCompletionFile(SourceLocation FileLoc); + bool isCodeCompletionFile(SourceLocation FileLoc) const; /// Diag - Forwarding function for diagnostics. This emits a diagnostic at /// the specified Token's location, translating the token's start diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 8cc7a8438d..a3e72e8b40 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -47,8 +47,7 @@ unsigned ContentCache::getSize() const { } void ContentCache::replaceBuffer(const llvm::MemoryBuffer *B) { - if (B == Buffer) - return; + assert(B != Buffer); delete Buffer; Buffer = B; diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index c757820494..229826af5d 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -240,7 +240,7 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, return false; } -bool Preprocessor::isCodeCompletionFile(SourceLocation FileLoc) { +bool Preprocessor::isCodeCompletionFile(SourceLocation FileLoc) const { return CodeCompletionFile && FileLoc.isFileID() && SourceMgr.getFileEntryForID(SourceMgr.getFileID(FileLoc)) == CodeCompletionFile;