[clang-tools-extra] r178167 - cpp11-migrate segfaults transforming map<string, int>::iterator
Jordan Rose
jordan_rose at apple.com
Thu Mar 28 10:25:19 PDT 2013
I see, and my mistake for just reading the commit message and not the code! Thanks for the clarification.
On Mar 28, 2013, at 10:18 , "Bernal, Ariel J" <ariel.j.bernal at intel.com> wrote:
> Yes that's what it is supposed to do.
> My mistake, in the commit message, I meant ignore expr with cleanups instead of "skip".
>
> -----Original Message-----
> From: Jordan Rose [mailto:jordan_rose at apple.com]
> Sent: Thursday, March 28, 2013 12:51 PM
> To: Bernal, Ariel J
> Cc: cfe-commits at cs.uiuc.edu
> Subject: Re: [clang-tools-extra] r178167 - cpp11-migrate segfaults transforming map<string, int>::iterator
>
> Isn't the correct solution to look through ExprWithCleanups, since that won't change the type of the returned value anyway?
>
>
> On Mar 27, 2013, at 11:49 , Ariel J. Bernal <ariel.j.bernal at intel.com> wrote:
>
>> Author: ajbernal
>> Date: Wed Mar 27 13:49:31 2013
>> New Revision: 178167
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=178167&view=rev
>> Log:
>> cpp11-migrate segfaults transforming map<string,int>::iterator
>>
>> cpp11-migrate segfaults when -use-auto tries to resolve initializing
>> expression resulting in an expression with cleanups.
>>
>> - Skip expressions with cleanups from the initializer
>> - Added test case
>>
>> Fixes PR15550
>>
>>
>> Modified:
>> clang-tools-extra/trunk/cpp11-migrate/UseAuto/UseAutoActions.cpp
>> clang-tools-extra/trunk/test/cpp11-migrate/UseAuto/Inputs/test_std_container.h
>> clang-tools-extra/trunk/test/cpp11-migrate/UseAuto/iterator.cpp
>>
>> Modified:
>> clang-tools-extra/trunk/cpp11-migrate/UseAuto/UseAutoActions.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migr
>> ate/UseAuto/UseAutoActions.cpp?rev=178167&r1=178166&r2=178167&view=dif
>> f
>> ======================================================================
>> ========
>> --- clang-tools-extra/trunk/cpp11-migrate/UseAuto/UseAutoActions.cpp
>> (original)
>> +++ clang-tools-extra/trunk/cpp11-migrate/UseAuto/UseAutoActions.cpp
>> +++ Wed Mar 27 13:49:31 2013
>> @@ -28,7 +28,14 @@ void UseAutoFixer::run(const MatchFinder
>> if (!SM.isFromMainFile(D->getLocStart()))
>> return;
>>
>> - const CXXConstructExpr *Construct =
>> cast<CXXConstructExpr>(D->getInit());
>> + const Expr *ExprInit = D->getInit();
>> +
>> + // Skip expressions with cleanups from the initializer expression.
>> + if (const ExprWithCleanups *E = dyn_cast<ExprWithCleanups>(ExprInit))
>> + ExprInit = E->getSubExpr();
>> +
>> + const CXXConstructExpr *Construct =
>> + cast<CXXConstructExpr>(ExprInit);
>> +
>> assert(Construct->getNumArgs() == 1u &&
>> "Expected constructor with single argument");
>>
>>
>> Modified:
>> clang-tools-extra/trunk/test/cpp11-migrate/UseAuto/Inputs/test_std_con
>> tainer.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/cpp11
>> -migrate/UseAuto/Inputs/test_std_container.h?rev=178167&r1=178166&r2=1
>> 78167&view=diff
>> ======================================================================
>> ========
>> ---
>> clang-tools-extra/trunk/test/cpp11-migrate/UseAuto/Inputs/test_std_con
>> tainer.h (original)
>> +++ clang-tools-extra/trunk/test/cpp11-migrate/UseAuto/Inputs/test_std
>> +++ _container.h Wed Mar 27 13:49:31 2013
>> @@ -107,6 +107,9 @@ public:
>>
>> const_reverse_iterator rbegin() const { return const_reverse_iterator(); }
>> const_reverse_iterator rend() const { return
>> const_reverse_iterator(); }
>> +
>> + template <typename K>
>> + iterator find(const K &Key) { return iterator(); }
>> };
>>
>> #if USE_INLINE_NAMESPACE
>>
>> Modified:
>> clang-tools-extra/trunk/test/cpp11-migrate/UseAuto/iterator.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/cpp11
>> -migrate/UseAuto/iterator.cpp?rev=178167&r1=178166&r2=178167&view=diff
>> ======================================================================
>> ========
>> --- clang-tools-extra/trunk/test/cpp11-migrate/UseAuto/iterator.cpp
>> (original)
>> +++ clang-tools-extra/trunk/test/cpp11-migrate/UseAuto/iterator.cpp
>> +++ Wed Mar 27 13:49:31 2013
>> @@ -148,5 +148,13 @@ int main(int argc, char **argv) {
>> // CHECK: auto && I2 = Vec.begin();
>> }
>>
>> + // Passing a string as an argument to introduce a temporary object
>> + // that will create an expression with cleanups. Bugzilla: 15550 {
>> + std::unordered_map<int> MapFind;
>> + std::unordered_map<int>::iterator I = MapFind.find("foo");
>> + // CHECK: auto I = MapFind.find("foo"); }
>> +
>> return 0;
>> }
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list