diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-01-31 22:27:38 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-01-31 22:27:38 +0000 |
commit | e9d12b6c50c1e9b05443db099e21026c5991a93b (patch) | |
tree | a750984a3b4a4624cc6dd6a27fcaf030ea010db0 /lib/Sema/Sema.cpp | |
parent | 6997aae42800d95a1189a6186af438feb19ecc54 (diff) |
Add VarDecl::isThisDeclarationADefinition(), which properly encapsulates the logic for when a variable declaration is a (possibly tentativ) definition. Add a few functions building on this, and shift C tentative definition handling over to this new functionality. This shift also kills the Sema::TentativeDefinitions map and instead simply stores all declarations in the renamed list. The correct handling for multiple tentative definitions is instead shifted to the final walk of the list.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94968 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 171101bb96..c0e7572cdd 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -15,6 +15,7 @@ #include "Sema.h" #include "TargetAttributesSema.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/APFloat.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" @@ -472,12 +473,14 @@ void Sema::ActOnEndOfTranslationUnit() { // translation unit contains a file scope declaration of that // identifier, with the composite type as of the end of the // translation unit, with an initializer equal to 0. - for (unsigned i = 0, e = TentativeDefinitionList.size(); i != e; ++i) { - VarDecl *VD = TentativeDefinitions.lookup(TentativeDefinitionList[i]); - - // If the tentative definition was completed, it will be in the list, but - // not the map. - if (VD == 0 || VD->isInvalidDecl() || !VD->isTentativeDefinition(Context)) + llvm::SmallSet<VarDecl *, 32> Seen; + for (unsigned i = 0, e = TentativeDefinitions.size(); i != e; ++i) { + VarDecl *VD = TentativeDefinitions[i]->getActingDefinition(); + + // If the tentative definition was completed, getActingDefinition() returns + // null. If we've already seen this variable before, insert()'s second + // return value is false. + if (VD == 0 || VD->isInvalidDecl() || !Seen.insert(VD)) continue; if (const IncompleteArrayType *ArrayT |