Fix for The Add Override transform crashes if Google Test is #included
Bernal, Ariel J
ariel.j.bernal at intel.com
Mon Apr 29 11:53:14 PDT 2013
This patch fixes PR15827, add override options was not checking if the method declaration was in the main file.
diff --git a/cpp11-migrate/AddOverride/AddOverrideActions.cpp b/cpp11-migrate/AddOverride/AddOverrideActions.cpp
index a40f673..3d1f1ff 100644
--- a/cpp11-migrate/AddOverride/AddOverrideActions.cpp
+++ b/cpp11-migrate/AddOverride/AddOverrideActions.cpp
@@ -30,10 +30,14 @@ void AddOverrideFixer::run(const MatchFinder::MatchResult &Result) {
SourceManager &SM = *Result.SourceManager;
const CXXMethodDecl *M = Result.Nodes.getDeclAs<CXXMethodDecl>(MethodId);
assert(M && "Bad Callback. No node provided");
+ // Check that the method declaration in the main file
+ if (!SM.isFromMainFile(M->getLocStart()))
+ return;
+
// First check that there isn't already an override attribute.
if (!M->hasAttr<OverrideAttr>()) {
if (M->getLocStart().isFileID()) {
SourceLocation StartLoc;
if (M->hasInlineBody()) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130429/165b963c/attachment.html>
More information about the cfe-commits
mailing list