summaryrefslogtreecommitdiffstats
path: root/include/clang/Sema/ScopeInfo.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-02-17 07:39:24 +0000
committerChris Lattner <sabre@nondot.org>2011-02-17 07:39:24 +0000
commitad8dcf4a9df0e24051dc31bf9e6f3cd138a34298 (patch)
treed937c0c2c2c7d6a5a9ed8efbd45903e4314cba94 /include/clang/Sema/ScopeInfo.h
parent1aa3d81c6e63959ef149489eca42b1520c521af4 (diff)
Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt. There is a 1-1 correspondence between the two, but this simplifies a bunch of code by itself. This is because labels are the only place where we previously had references to random other statements, causing grief for AST serialization and other stuff. This does cause one regression (attr(unused) doesn't silence unused label warnings) which I'll address next. This does fix some minor bugs: 1. "The only valid attribute " diagnostic was capitalized. 2. Various diagnostics printed as ''labelname'' instead of 'labelname' 3. This reduces duplication of label checking between functions and blocks. Review appreciated, particularly for the cindex and template bits. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/ScopeInfo.h')
-rw-r--r--include/clang/Sema/ScopeInfo.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h
index edd1432d8e..c9d38715ec 100644
--- a/include/clang/Sema/ScopeInfo.h
+++ b/include/clang/Sema/ScopeInfo.h
@@ -23,7 +23,7 @@ namespace clang {
class BlockDecl;
class IdentifierInfo;
-class LabelStmt;
+class LabelDecl;
class ReturnStmt;
class Scope;
class SwitchStmt;
@@ -52,10 +52,10 @@ public:
/// \brief Used to determine if errors occurred in this function or block.
DiagnosticErrorTrap ErrorTrap;
- /// LabelMap - This is a mapping from label identifiers to the LabelStmt for
- /// it (which acts like the label decl in some ways). Forward referenced
- /// labels have a LabelStmt created for them with a null location & SubStmt.
- llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
+ /// LabelMap - This is a mapping from label identifiers to the LabelDecl for
+ /// it. Forward referenced labels have a LabelDecl created for them with a
+ /// null statement.
+ llvm::DenseMap<IdentifierInfo*, LabelDecl*> LabelMap;
/// SwitchStack - This is the current set of active switch statements in the
/// block.
@@ -92,6 +92,11 @@ public:
virtual ~FunctionScopeInfo();
+ /// checkLabelUse - This checks to see if any labels are used without being
+ /// defined, emiting errors and returning true if any are found. This also
+ /// warns about unused labels.
+ bool checkLabelUse(Stmt *Body, Sema &S);
+
/// \brief Clear out the information in this function scope, making it
/// suitable for reuse.
void Clear();