diff options
| author | John McCall <rjmccall@apple.com> | 2010-04-29 00:35:03 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-04-29 00:35:03 +0000 |
| commit | 80e58cd3e942f821c0c78d43ce93f8ecc39e30ea (patch) | |
| tree | 9ba86109427fa7501d2d137136636aa14f7b9b5e /clang/lib/Sema/Sema.h | |
| parent | d17020676106cd77cd35d263c5549b605dad0225 (diff) | |
| download | bcm5719-llvm-80e58cd3e942f821c0c78d43ce93f8ecc39e30ea.tar.gz bcm5719-llvm-80e58cd3e942f821c0c78d43ce93f8ecc39e30ea.zip | |
Properly switch into the declaring scope of a template when performing
template argument deduction or (more importantly) the final substitution
required by such deduction. Makes access control magically work in these
cases.
Fixes PR6967.
llvm-svn: 102572
Diffstat (limited to 'clang/lib/Sema/Sema.h')
| -rw-r--r-- | clang/lib/Sema/Sema.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index f6af46eca9a..02a86cd94db 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -233,6 +233,30 @@ public: /// CurContext - This is the current declaration context of parsing. DeclContext *CurContext; + /// A RAII object to temporarily push a declaration context. + class ContextRAII { + private: + Sema &S; + DeclContext *SavedContext; + + public: + ContextRAII(Sema &S, DeclContext *ContextToPush) + : S(S), SavedContext(S.CurContext) { + assert(ContextToPush && "pushing null context"); + S.CurContext = ContextToPush; + } + + void pop() { + if (!SavedContext) return; + S.CurContext = SavedContext; + SavedContext = 0; + } + + ~ContextRAII() { + pop(); + } + }; + /// PackContext - Manages the stack for #pragma pack. An alignment /// of 0 indicates default alignment. void *PackContext; // Really a "PragmaPackStack*" |

