[cfe-commits] r39336 - in /cfe/cfe/trunk: AST/SemaDecl.cpp Lex/IdentifierTable.cpp Lex/Preprocessor.cpp Sema/SemaDecl.cpp include/clang/Lex/IdentifierTable.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:43:16 PDT 2007
Author: sabre
Date: Wed Jul 11 11:43:16 2007
New Revision: 39336
URL: http://llvm.org/viewvc/llvm-project?rev=39336&view=rev
Log:
switch to using iterators instead of stringmap visitors.
Modified:
cfe/cfe/trunk/AST/SemaDecl.cpp
cfe/cfe/trunk/Lex/IdentifierTable.cpp
cfe/cfe/trunk/Lex/Preprocessor.cpp
cfe/cfe/trunk/Sema/SemaDecl.cpp
cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h
Modified: cfe/cfe/trunk/AST/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaDecl.cpp?rev=39336&r1=39335&r2=39336&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/AST/SemaDecl.cpp Wed Jul 11 11:43:16 2007
@@ -386,6 +386,7 @@
const char *Dummy;
DeclSpec DS;
bool Error = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, Dummy);
+ Error = Error; // Silence warning.
assert(!Error && "Error setting up implicit decl!");
Declarator D(DS, Declarator::BlockContext);
D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, 0, 0, Loc));
Modified: cfe/cfe/trunk/Lex/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/IdentifierTable.cpp?rev=39336&r1=39335&r2=39336&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/IdentifierTable.cpp (original)
+++ cfe/cfe/trunk/Lex/IdentifierTable.cpp Wed Jul 11 11:43:16 2007
@@ -148,21 +148,6 @@
// Stats Implementation
//===----------------------------------------------------------------------===//
-class StatsVisitor : public StringMapVisitor {
- unsigned &IDLenTotal;
- unsigned &MaxIDLen;
-public:
- StatsVisitor(unsigned &idLenTotal, unsigned &maxIDLen)
- : IDLenTotal(idLenTotal), MaxIDLen(maxIDLen) {}
- void Visit(const char *Key, StringMapEntryBase *Value) const {
- unsigned IdLen = Value->getKeyLength();
- IDLenTotal += IdLen;
- if (MaxIDLen < IdLen)
- MaxIDLen = IdLen;
- }
-};
-
-
/// PrintStats - Print statistics about how well the identifier table is doing
/// at hashing identifiers.
void IdentifierTable::PrintStats() const {
@@ -173,8 +158,13 @@
unsigned MaxIdentifierLength = 0;
// TODO: Figure out maximum times an identifier had to probe for -stats.
- HashTable.VisitEntries(StatsVisitor(AverageIdentifierSize,
- MaxIdentifierLength));
+ for (StringMap<IdentifierInfo, BumpPtrAllocator>::const_iterator
+ I = HashTable.begin(), E = HashTable.end(); I != E; ++I) {
+ unsigned IdLen = I->getKeyLength();
+ AverageIdentifierSize += IdLen;
+ if (MaxIdentifierLength < IdLen)
+ MaxIdentifierLength = IdLen;
+ }
std::cerr << "\n*** Identifier Table Stats:\n";
std::cerr << "# Identifiers: " << NumIdentifiers << "\n";
Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=39336&r1=39335&r2=39336&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:43:16 2007
@@ -886,20 +886,6 @@
}
}
-namespace {
-struct UnusedIdentifierReporter : public StringMapVisitor {
- Preprocessor &PP;
- UnusedIdentifierReporter(Preprocessor &pp) : PP(pp) {}
-
- void Visit(const char *Key, StringMapEntryBase *Value) const {
- IdentifierInfo &II =
- static_cast<StringMapEntry<IdentifierInfo>*>(Value)->getValue();
- if (II.getMacroInfo() && !II.getMacroInfo()->isUsed())
- PP.Diag(II.getMacroInfo()->getDefinitionLoc(), diag::pp_macro_not_used);
- }
-};
-}
-
//===----------------------------------------------------------------------===//
// Lexer Event Handling.
//===----------------------------------------------------------------------===//
@@ -1035,8 +1021,14 @@
// This is the end of the top-level file. If the diag::pp_macro_not_used
// diagnostic is enabled, walk all of the identifiers, looking for macros that
// have not been used.
- if (Diags.getDiagnosticLevel(diag::pp_macro_not_used) != Diagnostic::Ignored)
- Identifiers.VisitIdentifiers(UnusedIdentifierReporter(*this));
+ if (Diags.getDiagnosticLevel(diag::pp_macro_not_used) != Diagnostic::Ignored){
+ for (IdentifierTable::iterator I = Identifiers.begin(),
+ E = Identifiers.end(); I != E; ++I) {
+ const IdentifierInfo &II = I->getValue();
+ if (II.getMacroInfo() && !II.getMacroInfo()->isUsed())
+ Diag(II.getMacroInfo()->getDefinitionLoc(), diag::pp_macro_not_used);
+ }
+ }
return true;
}
Modified: cfe/cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaDecl.cpp?rev=39336&r1=39335&r2=39336&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaDecl.cpp Wed Jul 11 11:43:16 2007
@@ -386,6 +386,7 @@
const char *Dummy;
DeclSpec DS;
bool Error = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, Dummy);
+ Error = Error; // Silence warning.
assert(!Error && "Error setting up implicit decl!");
Declarator D(DS, Declarator::BlockContext);
D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, 0, 0, Loc));
Modified: cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h?rev=39336&r1=39335&r2=39336&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h Wed Jul 11 11:43:16 2007
@@ -132,7 +132,8 @@
class IdentifierTable {
// Shark shows that using MallocAllocator is *much* slower than using this
// BumpPtrAllocator!
- StringMap<IdentifierInfo, BumpPtrAllocator> HashTable;
+ typedef StringMap<IdentifierInfo, BumpPtrAllocator> HashTableTy;
+ HashTableTy HashTable;
public:
/// IdentifierTable ctor - Create the identifier table, populating it with
/// info about the language keywords for the language specified by LangOpts.
@@ -153,11 +154,11 @@
return get(NameBytes, NameBytes+Name.size());
}
- /// VisitIdentifiers - This method walks through all of the identifiers,
- /// invoking IV->VisitIdentifier for each of them.
- void VisitIdentifiers(const StringMapVisitor &IV) {
- HashTable.VisitEntries(IV);
- }
+ typedef HashTableTy::const_iterator iterator;
+ typedef HashTableTy::const_iterator const_iterator;
+
+ iterator begin() const { return HashTable.begin(); }
+ iterator end() const { return HashTable.end(); }
/// PrintStats - Print some statistics to stderr that indicate how well the
/// hashing is doing.
More information about the cfe-commits
mailing list