[PATCH] D35729: [Frontend] - Mark some ASTUnit methods as const
This revision was automatically updated to reflect the committed changes. Closed by commit rL309013: [Frontend] Mark some ASTUnit methods as const. NFC. (authored by vedantk). Changed prior to commit: https://reviews.llvm.org/D35729?vs=107689&id=108138#toc Repository: rL LLVM https://reviews.llvm.org/D35729 Files: cfe/trunk/include/clang/Frontend/ASTUnit.h cfe/trunk/lib/Frontend/ASTUnit.cpp Index: cfe/trunk/include/clang/Frontend/ASTUnit.h === --- cfe/trunk/include/clang/Frontend/ASTUnit.h +++ cfe/trunk/include/clang/Frontend/ASTUnit.h @@ -448,7 +448,7 @@ IntrusiveRefCntPtr getASTReader() const; - StringRef getOriginalSourceFileName() { + StringRef getOriginalSourceFileName() const { return OriginalSourceFile; } @@ -524,26 +524,26 @@ /// \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 @@ /// \brief Returns true if the ASTUnit was constructed from a serialized /// module file. - bool isModuleFile(); + bool isModuleFile() const; std::unique_ptr getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr); Index: cfe/trunk/lib/Frontend/ASTUnit.cpp === --- cfe/trunk/lib/Frontend/ASTUnit.cpp +++ cfe/trunk/lib/Frontend/ASTUnit.cpp @@ -2395,7 +2395,7 @@ /// \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 @@ /// \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 @@ return Loc; } -bool ASTUnit::isInPreambleFileID(SourceLocation Loc) { +bool ASTUnit::isInPreambleFileID(SourceLocation Loc) const { FileID FID; if (SourceMgr) FID = SourceMgr->getPreambleFileID(); @@ -2445,7 +2445,7 @@ 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 @@ return SourceMgr->isInFileID(Loc, FID); } -SourceLocation ASTUnit::getEndOfPreambleFileID() { +SourceLocation ASTUnit::getEndOfPreambleFileID() const { FileID FID; if (SourceMgr) FID = SourceMgr->getPreambleFileID(); @@ -2467,7 +2467,7 @@ return SourceMgr->getLocForEndOfFile(FID); } -SourceLocation ASTUnit::getStartOfMainFileID() { +SourceLocation ASTUnit::getStartOfMainFileID() const { FileID FID; if (SourceMgr) FID = SourceMgr->getMainFileID(); @@ -2543,7 +2543,7 @@ return nullptr; } -bool ASTUnit::isModuleFile() { +bool ASTUnit::isModuleFile() const { return isMainFileAST() && getLangOpts().isCompilingModule(); } ___ cfe-commits mailing list cfe-commits@lists.
[PATCH] D35729: [Frontend] - Mark some ASTUnit methods as const
hamzasood added a comment. Could someone commit this for me? I don't have access. https://reviews.llvm.org/D35729 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35729: [Frontend] - Mark some ASTUnit methods as const
vsk accepted this revision. vsk added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D35729 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35729: [Frontend] - Mark some ASTUnit methods as const
hamzasood created this revision. While using the libtooling API, I ran into problems when using a const ASTUnit. There were a few functions I needed to use that don't seem to modify anything, but they weren't marked as const so I couldn't use them. This patch marks those methods (and a few others) as const. https://reviews.llvm.org/D35729 Files: include/clang/Frontend/ASTUnit.h lib/Frontend/ASTUnit.cpp Index: lib/Frontend/ASTUnit.cpp === --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -2395,7 +2395,7 @@ /// \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 @@ /// \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 @@ return Loc; } -bool ASTUnit::isInPreambleFileID(SourceLocation Loc) { +bool ASTUnit::isInPreambleFileID(SourceLocation Loc) const { FileID FID; if (SourceMgr) FID = SourceMgr->getPreambleFileID(); @@ -2445,7 +2445,7 @@ 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 @@ return SourceMgr->isInFileID(Loc, FID); } -SourceLocation ASTUnit::getEndOfPreambleFileID() { +SourceLocation ASTUnit::getEndOfPreambleFileID() const { FileID FID; if (SourceMgr) FID = SourceMgr->getPreambleFileID(); @@ -2467,7 +2467,7 @@ return SourceMgr->getLocForEndOfFile(FID); } -SourceLocation ASTUnit::getStartOfMainFileID() { +SourceLocation ASTUnit::getStartOfMainFileID() const { FileID FID; if (SourceMgr) FID = SourceMgr->getMainFileID(); @@ -2543,7 +2543,7 @@ return nullptr; } -bool ASTUnit::isModuleFile() { +bool ASTUnit::isModuleFile() const { return isMainFileAST() && getLangOpts().isCompilingModule(); } Index: include/clang/Frontend/ASTUnit.h === --- include/clang/Frontend/ASTUnit.h +++ include/clang/Frontend/ASTUnit.h @@ -448,7 +448,7 @@ IntrusiveRefCntPtr getASTReader() const; - StringRef getOriginalSourceFileName() { + StringRef getOriginalSourceFileName() const { return OriginalSourceFile; } @@ -524,26 +524,26 @@ /// \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 @@ /// \brief Returns true if the ASTUnit was constructed from a serialized /// module file. - bool isModuleFile(); + bool isModuleFile() const; std::unique_ptr getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/lis