[cfe-commits] r156145 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTReaderDecl.cpp test/PCH/objc_methods.h

Chris Lattner clattner at apple.com
Thu May 3 20:32:57 PDT 2012


On May 3, 2012, at 6:49 PM, Argyrios Kyrtzidis wrote:

> Author: akirtzidis
> Date: Thu May  3 20:49:36 2012
> New Revision: 156145
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=156145&view=rev
> Log:
> [PCH] Really, pinky swear, fix for PR12689

DenseMap?

-Chris

> 
> rdar://11353109
> 
> Modified:
>    cfe/trunk/include/clang/Serialization/ASTReader.h
>    cfe/trunk/lib/Serialization/ASTReader.cpp
>    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>    cfe/trunk/test/PCH/objc_methods.h
> 
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=156145&r1=156144&r2=156145&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu May  3 20:49:36 2012
> @@ -597,6 +597,8 @@
>   /// switch statement can refer to them.
>   std::map<unsigned, SwitchCase *> SwitchCaseStmts;
> 
> +  std::map<unsigned, SwitchCase *> *CurrSwitchCaseStmts;
> +
>   /// \brief The number of stat() calls that hit/missed the stat
>   /// cache.
>   unsigned NumStatHits, NumStatMisses;
> 
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=156145&r1=156144&r2=156145&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu May  3 20:49:36 2012
> @@ -6248,18 +6248,19 @@
> /// \brief Record that the given ID maps to the given switch-case
> /// statement.
> void ASTReader::RecordSwitchCaseID(SwitchCase *SC, unsigned ID) {
> -  assert(SwitchCaseStmts[ID] == 0 && "Already have a SwitchCase with this ID");
> -  SwitchCaseStmts[ID] = SC;
> +  assert((*CurrSwitchCaseStmts)[ID] == 0 &&
> +         "Already have a SwitchCase with this ID");
> +  (*CurrSwitchCaseStmts)[ID] = SC;
> }
> 
> /// \brief Retrieve the switch-case statement with the given ID.
> SwitchCase *ASTReader::getSwitchCaseWithID(unsigned ID) {
> -  assert(SwitchCaseStmts[ID] != 0 && "No SwitchCase with this ID");
> -  return SwitchCaseStmts[ID];
> +  assert((*CurrSwitchCaseStmts)[ID] != 0 && "No SwitchCase with this ID");
> +  return (*CurrSwitchCaseStmts)[ID];
> }
> 
> void ASTReader::ClearSwitchCaseIDs() {
> -  SwitchCaseStmts.clear();
> +  CurrSwitchCaseStmts->clear();
> }
> 
> void ASTReader::finishPendingActions() {
> @@ -6374,7 +6375,8 @@
>     DisableValidation(DisableValidation),
>     DisableStatCache(DisableStatCache),
>     AllowASTWithCompilerErrors(AllowASTWithCompilerErrors), 
> -    CurrentGeneration(0), NumStatHits(0), NumStatMisses(0), 
> +    CurrentGeneration(0), CurrSwitchCaseStmts(&SwitchCaseStmts),
> +    NumStatHits(0), NumStatMisses(0), 
>     NumSLocEntriesRead(0), TotalNumSLocEntries(0), 
>     NumStatementsRead(0), TotalNumStatements(0), NumMacrosRead(0), 
>     TotalNumMacros(0), NumSelectorsRead(0), NumMethodPoolEntriesRead(0), 
> 
> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=156145&r1=156144&r2=156145&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu May  3 20:49:36 2012
> @@ -25,6 +25,7 @@
> #include "clang/AST/DeclCXX.h"
> #include "clang/AST/DeclTemplate.h"
> #include "clang/AST/Expr.h"
> +#include "llvm/Support/SaveAndRestore.h"
> using namespace clang;
> using namespace clang::serialization;
> 
> @@ -629,8 +630,10 @@
>   if (Record[Idx++]) {
>     // In practice, this won't be executed (since method definitions
>     // don't occur in header files).
> -    // Switch case IDs are per method body.
> -    Reader.ClearSwitchCaseIDs();
> +    // Switch case IDs for this method body.
> +    std::map<unsigned, SwitchCase *> SwitchCaseStmtsForObjCMethod;
> +    SaveAndRestore<std::map<unsigned, SwitchCase *> *>
> +      SCFOM(Reader.CurrSwitchCaseStmts, &SwitchCaseStmtsForObjCMethod);
>     MD->setBody(Reader.ReadStmt(F));
>     MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
>     MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
> 
> Modified: cfe/trunk/test/PCH/objc_methods.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/objc_methods.h?rev=156145&r1=156144&r2=156145&view=diff
> ==============================================================================
> --- cfe/trunk/test/PCH/objc_methods.h (original)
> +++ cfe/trunk/test/PCH/objc_methods.h Thu May  3 20:49:36 2012
> @@ -25,3 +25,17 @@
>   }
> }
> @end
> +
> + at interface PR12689_2
> + at end
> +
> + at implementation PR12689_2
> +-(void)mugi:(int)x {
> +    switch(x) {
> +        case 23: [self bonk:x]; break;
> +        case 82: break;
> +    }
> +}
> +-(void)bonk:(int)x {
> +}
> + at end
> 
> 
> _______________________________________________
> 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