]> granicus.if.org Git - clang/commitdiff
[Frontend] Mark some ASTUnit methods as const. NFC.
authorVedant Kumar <vsk@apple.com>
Tue, 25 Jul 2017 19:53:27 +0000 (19:53 +0000)
committerVedant Kumar <vsk@apple.com>
Tue, 25 Jul 2017 19:53:27 +0000 (19:53 +0000)
Patch by Hamza Sood!

Differential Revision: https://reviews.llvm.org/D35729

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309013 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/ASTUnit.h
lib/Frontend/ASTUnit.cpp

index 1ac4f07a3549a206235cab9fbd0881c22678d8f3..5d04dcd19119a91dd0442c948947efb788f3a88f 100644 (file)
@@ -448,7 +448,7 @@ public:
 
   IntrusiveRefCntPtr<ASTReader> getASTReader() const;
 
-  StringRef getOriginalSourceFileName() {
+  StringRef getOriginalSourceFileName() const {
     return OriginalSourceFile;
   }
 
@@ -524,26 +524,26 @@ public:
   /// \brief If \p Loc is a loaded location from the preamble, returns
   /// the corresponding local location of the main file, otherwise it returns
   /// \p Loc.
-  SourceLocation mapLocationFromPreamble(SourceLocation Loc);
+  SourceLocation mapLocationFromPreamble(SourceLocation Loc) const;
 
   /// \brief If \p Loc is a local location of the main file but inside the
   /// preamble chunk, returns the corresponding loaded location from the
   /// preamble, otherwise it returns \p Loc.
-  SourceLocation mapLocationToPreamble(SourceLocation Loc);
+  SourceLocation mapLocationToPreamble(SourceLocation Loc) const;
 
-  bool isInPreambleFileID(SourceLocation Loc);
-  bool isInMainFileID(SourceLocation Loc);
-  SourceLocation getStartOfMainFileID();
-  SourceLocation getEndOfPreambleFileID();
+  bool isInPreambleFileID(SourceLocation Loc) const;
+  bool isInMainFileID(SourceLocation Loc) const;
+  SourceLocation getStartOfMainFileID() const;
+  SourceLocation getEndOfPreambleFileID() const;
 
   /// \see mapLocationFromPreamble.
-  SourceRange mapRangeFromPreamble(SourceRange R) {
+  SourceRange mapRangeFromPreamble(SourceRange R) const {
     return SourceRange(mapLocationFromPreamble(R.getBegin()),
                        mapLocationFromPreamble(R.getEnd()));
   }
 
   /// \see mapLocationToPreamble.
-  SourceRange mapRangeToPreamble(SourceRange R) {
+  SourceRange mapRangeToPreamble(SourceRange R) const {
     return SourceRange(mapLocationToPreamble(R.getBegin()),
                        mapLocationToPreamble(R.getEnd()));
   }
@@ -607,7 +607,7 @@ public:
 
   /// \brief Returns true if the ASTUnit was constructed from a serialized
   /// module file.
-  bool isModuleFile();
+  bool isModuleFile() const;
 
   std::unique_ptr<llvm::MemoryBuffer>
   getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);
index 1094e6d089a65d32efbf803d27691c1b694dd4a4..07f847ca944b9e4720dcc01ded9933e157e04cc1 100644 (file)
@@ -2395,7 +2395,7 @@ SourceLocation ASTUnit::getLocation(const FileEntry *File,
 /// \brief If \arg Loc is a loaded location from the preamble, returns
 /// the corresponding local location of the main file, otherwise it returns
 /// \arg Loc.
-SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
     PreambleID = SourceMgr->getPreambleFileID();
@@ -2416,7 +2416,7 @@ SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) {
 /// \brief If \arg Loc is a local location of the main file but inside the
 /// preamble chunk, returns the corresponding loaded location from the
 /// preamble, otherwise it returns \arg Loc.
-SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
     PreambleID = SourceMgr->getPreambleFileID();
@@ -2434,7 +2434,7 @@ SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) {
   return Loc;
 }
 
-bool ASTUnit::isInPreambleFileID(SourceLocation Loc) {
+bool ASTUnit::isInPreambleFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
     FID = SourceMgr->getPreambleFileID();
@@ -2445,7 +2445,7 @@ bool ASTUnit::isInPreambleFileID(SourceLocation Loc) {
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-bool ASTUnit::isInMainFileID(SourceLocation Loc) {
+bool ASTUnit::isInMainFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
     FID = SourceMgr->getMainFileID();
@@ -2456,7 +2456,7 @@ bool ASTUnit::isInMainFileID(SourceLocation Loc) {
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-SourceLocation ASTUnit::getEndOfPreambleFileID() {
+SourceLocation ASTUnit::getEndOfPreambleFileID() const {
   FileID FID;
   if (SourceMgr)
     FID = SourceMgr->getPreambleFileID();
@@ -2467,7 +2467,7 @@ SourceLocation ASTUnit::getEndOfPreambleFileID() {
   return SourceMgr->getLocForEndOfFile(FID);
 }
 
-SourceLocation ASTUnit::getStartOfMainFileID() {
+SourceLocation ASTUnit::getStartOfMainFileID() const {
   FileID FID;
   if (SourceMgr)
     FID = SourceMgr->getMainFileID();
@@ -2543,7 +2543,7 @@ const FileEntry *ASTUnit::getPCHFile() {
   return nullptr;
 }
 
-bool ASTUnit::isModuleFile() {
+bool ASTUnit::isModuleFile() const {
   return isMainFileAST() && getLangOpts().isCompilingModule();
 }