[llvm-branch-commits] [cfe-branch] r151688 - in /cfe/branches/tooling: ./ include/clang/AST/ include/clang/Basic/ include/clang/Sema/ include/clang/StaticAnalyzer/Core/BugReporter/ lib/AST/ lib/Parse/ lib/Sema/ lib/StaticAnalyzer/Core/ test/CodeGen/ test/Index/ test/Misc/ test/PCH/ test/Sema/ test/SemaCXX/
Manuel Klimek
klimek at google.com
Tue Feb 28 17:23:35 PST 2012
Author: klimek
Date: Tue Feb 28 19:23:35 2012
New Revision: 151688
URL: http://llvm.org/viewvc/llvm-project?rev=151688&view=rev
Log:
Merging mainline.
Added:
cfe/branches/tooling/test/Index/index-decls.m
- copied unchanged from r151673, cfe/trunk/test/Index/index-decls.m
cfe/branches/tooling/test/PCH/cocoa.m
- copied unchanged from r151673, cfe/trunk/test/PCH/cocoa.m
Removed:
cfe/branches/tooling/test/CodeGen/decl-in-prototype.c
cfe/branches/tooling/test/Sema/decl-in-prototype.c
Modified:
cfe/branches/tooling/ (props changed)
cfe/branches/tooling/include/clang/AST/Decl.h
cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/tooling/include/clang/Sema/Scope.h
cfe/branches/tooling/include/clang/Sema/Sema.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/branches/tooling/lib/AST/Decl.cpp
cfe/branches/tooling/lib/AST/DumpXML.cpp
cfe/branches/tooling/lib/Parse/ParseDecl.cpp
cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp
cfe/branches/tooling/lib/Sema/Scope.cpp
cfe/branches/tooling/lib/Sema/Sema.cpp
cfe/branches/tooling/lib/Sema/SemaDecl.cpp
cfe/branches/tooling/lib/Sema/SemaOverload.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/branches/tooling/test/Misc/warning-flags.c
cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp
cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp (props changed)
Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 28 19:23:35 2012
@@ -1,3 +1,3 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-151662
+/cfe/trunk:146581-151673
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/tooling/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Decl.h?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Decl.h (original)
+++ cfe/branches/tooling/include/clang/AST/Decl.h Tue Feb 28 19:23:35 2012
@@ -1431,11 +1431,6 @@
/// no formals.
ParmVarDecl **ParamInfo;
- /// DeclsInPrototypeScope - Array of pointers to NamedDecls for
- /// decls defined in the function prototype that are not parameters. E.g.
- /// 'enum Y' in 'void f(enum Y {AA} x) {}'.
- llvm::ArrayRef<NamedDecl*> DeclsInPrototypeScope;
-
LazyDeclStmtPtr Body;
// FIXME: This can be packed into the bitfields in Decl.
@@ -1801,11 +1796,6 @@
setParams(getASTContext(), NewParamInfo);
}
- const llvm::ArrayRef<NamedDecl*> &getDeclsInPrototypeScope() const {
- return DeclsInPrototypeScope;
- }
- void setDeclsInPrototypeScope(llvm::ArrayRef<NamedDecl *> NewDecls);
-
/// getMinRequiredArguments - Returns the minimum number of arguments
/// needed to call this function. This may be fewer than the number of
/// function parameters, if some of the parameters have default
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td Tue Feb 28 19:23:35 2012
@@ -244,7 +244,6 @@
def VexingParse : DiagGroup<"vexing-parse">;
def VLA : DiagGroup<"vla">;
def VolatileRegisterVar : DiagGroup<"volatile-register-var">;
-def Visibility : DiagGroup<"visibility">;
// GCC calls -Wdeprecated-writable-strings -Wwrite-strings.
def GCCWriteStrings : DiagGroup<"write-strings" , [DeprecatedWritableStr]>;
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb 28 19:23:35 2012
@@ -132,11 +132,7 @@
def warn_unused_exception_param : Warning<"unused exception parameter %0">,
InGroup<UnusedExceptionParameter>, DefaultIgnore;
def warn_decl_in_param_list : Warning<
- "declaration of %0 will not be visible outside of this function">,
- InGroup<Visibility>;
-def warn_redefinition_in_param_list : Warning<
- "redefinition of %0 will not be visible outside of this function">,
- InGroup<Visibility>;
+ "declaration of %0 will not be visible outside of this function">;
def warn_empty_parens_are_function_decl : Warning<
"empty parentheses interpreted as a function declaration">,
InGroup<VexingParse>;
Modified: cfe/branches/tooling/include/clang/Sema/Scope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Scope.h?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Scope.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Scope.h Tue Feb 28 19:23:35 2012
@@ -297,10 +297,6 @@
/// \brief Determine whether this scope is a C++ 'try' block.
bool isTryScope() const { return getFlags() & Scope::TryScope; }
- /// containedInPrototypeScope - Return true if this or a parent scope
- /// is a FunctionPrototypeScope.
- bool containedInPrototypeScope() const;
-
typedef UsingDirectivesTy::iterator udir_iterator;
typedef UsingDirectivesTy::const_iterator const_udir_iterator;
Modified: cfe/branches/tooling/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Sema.h?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Sema.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Sema.h Tue Feb 28 19:23:35 2012
@@ -902,13 +902,6 @@
// Symbol table / Decl tracking callbacks: SemaDecl.cpp.
//
- /// List of decls defined in a function prototype. This contains EnumConstants
- /// that incorrectly end up in translation unit scope because there is no
- /// function to pin them on. ActOnFunctionDeclarator reads this list and patches
- /// them into the FunctionDecl.
- std::vector<NamedDecl*> DeclsInPrototypeScope;
- bool InFunctionDeclarator;
-
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = 0);
void DiagnoseUseOfUnimplementedSelectors();
@@ -1055,7 +1048,6 @@
// Returns true if the variable declaration is a redeclaration
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
void CheckCompleteVariableDeclaration(VarDecl *var);
- void ActOnStartFunctionDeclarator();
NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
TypeSourceInfo *TInfo,
LookupResult &Previous,
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h Tue Feb 28 19:23:35 2012
@@ -132,11 +132,17 @@
ID.AddPointer(&x);
}
+
virtual PathDiagnosticPiece *VisitNode(const ExplodedNode *N,
const ExplodedNode *Prev,
BugReporterContext &BRC,
BugReport &BR);
+ PathDiagnosticPiece *VisitNodeImpl(const ExplodedNode *N,
+ const ExplodedNode *Prev,
+ BugReporterContext &BRC,
+ BugReport &BR);
+
PathDiagnosticPiece *VisitTerminator(const Stmt *Term,
const ExplodedNode *N,
const CFGBlock *srcBlk,
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h Tue Feb 28 19:23:35 2012
@@ -68,6 +68,10 @@
virtual bool supportsLogicalOpControlFlow() const { return false; }
virtual bool supportsAllBlockEdges() const { return false; }
virtual bool useVerboseDescription() const { return true; }
+
+ /// Return true if the PathDiagnosticConsumer supports individual
+ /// PathDiagnostics that span multiple files.
+ virtual bool supportsCrossFileDiagnostics() const { return false; }
protected:
bool flushed;
@@ -353,14 +357,18 @@
};
class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
-
+ bool IsPrunable;
public:
PathDiagnosticEventPiece(const PathDiagnosticLocation &pos,
StringRef s, bool addPosRange = true)
- : PathDiagnosticSpotPiece(pos, s, Event, addPosRange) {}
+ : PathDiagnosticSpotPiece(pos, s, Event, addPosRange),
+ IsPrunable(false) {}
~PathDiagnosticEventPiece();
+ void setPrunable(bool isPrunable) { IsPrunable = isPrunable; }
+ bool isPrunable() const { return IsPrunable; }
+
static inline bool classof(const PathDiagnosticPiece *P) {
return P->getKind() == Event;
}
@@ -527,7 +535,7 @@
void pushActivePath(PathPieces *p) { pathStack.push_back(p); }
void popActivePath() { if (!pathStack.empty()) pathStack.pop_back(); }
-
+
PathDiagnostic();
PathDiagnostic(StringRef bugtype, StringRef desc,
StringRef category);
Modified: cfe/branches/tooling/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Decl.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Decl.cpp (original)
+++ cfe/branches/tooling/lib/AST/Decl.cpp Tue Feb 28 19:23:35 2012
@@ -1847,16 +1847,6 @@
}
}
-void FunctionDecl::setDeclsInPrototypeScope(llvm::ArrayRef<NamedDecl *> NewDecls) {
- assert(DeclsInPrototypeScope.empty() && "Already has prototype decls!");
-
- if (!NewDecls.empty()) {
- NamedDecl **A = new (getASTContext()) NamedDecl*[NewDecls.size()];
- std::copy(NewDecls.begin(), NewDecls.end(), A);
- DeclsInPrototypeScope = llvm::ArrayRef<NamedDecl*>(A, NewDecls.size());
- }
-}
-
/// getMinRequiredArguments - Returns the minimum number of arguments
/// needed to call this function. This may be fewer than the number of
/// function parameters, if some of the parameters have default
Modified: cfe/branches/tooling/lib/AST/DumpXML.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DumpXML.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DumpXML.cpp (original)
+++ cfe/branches/tooling/lib/AST/DumpXML.cpp Tue Feb 28 19:23:35 2012
@@ -497,10 +497,6 @@
for (FunctionDecl::param_iterator
I = D->param_begin(), E = D->param_end(); I != E; ++I)
dispatch(*I);
- for (llvm::ArrayRef<NamedDecl*>::iterator
- I = D->getDeclsInPrototypeScope().begin(), E = D->getDeclsInPrototypeScope().end();
- I != E; ++I)
- dispatch(*I);
if (D->doesThisDeclarationHaveABody())
dispatch(D->getBody());
}
Modified: cfe/branches/tooling/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDecl.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDecl.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDecl.cpp Tue Feb 28 19:23:35 2012
@@ -4226,8 +4226,6 @@
ExprResult NoexceptExpr;
ParsedType TrailingReturnType;
- Actions.ActOnStartFunctionDeclarator();
-
SourceLocation EndLoc;
if (isFunctionDeclaratorIdentifierList()) {
if (RequiresArg)
Modified: cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp Tue Feb 28 19:23:35 2012
@@ -113,7 +113,7 @@
bool ExplicitInstantiationOrSpecialization) const {
Ctx = Ctx->getRedeclContext();
- if (Ctx->isFunctionOrMethod() || S->isFunctionPrototypeScope()) {
+ if (Ctx->isFunctionOrMethod()) {
// Ignore the scopes associated within transparent declaration contexts.
while (S->getEntity() &&
((DeclContext *)S->getEntity())->isTransparentContext())
Modified: cfe/branches/tooling/lib/Sema/Scope.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/Scope.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/Scope.cpp (original)
+++ cfe/branches/tooling/lib/Sema/Scope.cpp Tue Feb 28 19:23:35 2012
@@ -59,13 +59,3 @@
Entity = 0;
ErrorTrap.reset();
}
-
-bool Scope::containedInPrototypeScope() const {
- const Scope *S = this;
- while (S) {
- if (S->isFunctionPrototypeScope())
- return true;
- S = S->getParent();
- }
- return false;
-}
Modified: cfe/branches/tooling/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/Sema.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/Sema.cpp (original)
+++ cfe/branches/tooling/lib/Sema/Sema.cpp Tue Feb 28 19:23:35 2012
@@ -94,7 +94,7 @@
ObjCShouldCallSuperDealloc(false),
ObjCShouldCallSuperFinalize(false),
TUKind(TUKind),
- NumSFINAEErrors(0), InFunctionDeclarator(false), SuppressAccessChecking(false),
+ NumSFINAEErrors(0), SuppressAccessChecking(false),
AccessCheckingSFINAE(false), InNonInstantiationSFINAEContext(false),
NonInstantiationEntries(0), ArgumentPackSubstitutionIndex(-1),
CurrentInstantiationScope(0), TyposCorrected(0),
Modified: cfe/branches/tooling/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDecl.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDecl.cpp Tue Feb 28 19:23:35 2012
@@ -1249,10 +1249,6 @@
}
}
-void Sema::ActOnStartFunctionDeclarator() {
- InFunctionDeclarator = true;
-}
-
/// \brief Look for an Objective-C class in the translation unit.
///
/// \param Id The name of the Objective-C class we're looking for. If
@@ -4814,8 +4810,6 @@
assert(R.getTypePtr()->isFunctionType());
- InFunctionDeclarator = false;
-
// TODO: consider using NameInfo for diagnostic.
DeclarationNameInfo NameInfo = GetNameForDeclarator(D);
DeclarationName Name = NameInfo.getName();
@@ -5247,15 +5241,6 @@
// Finally, we know we have the right number of parameters, install them.
NewFD->setParams(Params);
- // Find all anonymous symbols defined during the declaration of this function
- // and add to NewFD. This lets us track decls such 'enum Y' in:
- //
- // void f(enum Y {AA} x) {}
- //
- // which would otherwise incorrectly end up in the translation unit scope.
- NewFD->setDeclsInPrototypeScope(DeclsInPrototypeScope);
- DeclsInPrototypeScope.clear();
-
// Process the non-inheritable attributes on this declaration.
ProcessDeclAttributes(S, NewFD, D,
/*NonInheritable=*/true, /*Inheritable=*/false);
@@ -7240,43 +7225,6 @@
}
}
- // If we had any tags defined in the function prototype,
- // introduce them into the function scope.
- if (FnBodyScope) {
- for (llvm::ArrayRef<NamedDecl*>::iterator I = FD->getDeclsInPrototypeScope().begin(),
- E = FD->getDeclsInPrototypeScope().end(); I != E; ++I) {
- NamedDecl *D = *I;
-
- // Some of these decls (like enums) may have been pinned to the translation unit
- // for lack of a real context earlier. If so, remove from the translation unit
- // and reattach to the current context.
- if (D->getLexicalDeclContext() == Context.getTranslationUnitDecl()) {
- // Is the decl actually in the context?
- for (DeclContext::decl_iterator DI = Context.getTranslationUnitDecl()->decls_begin(),
- DE = Context.getTranslationUnitDecl()->decls_end(); DI != DE; ++DI) {
- if (*DI == D) {
- Context.getTranslationUnitDecl()->removeDecl(D);
- break;
- }
- }
- // Either way, reassign the lexical decl context to our FunctionDecl.
- D->setLexicalDeclContext(CurContext);
- }
-
- // If the decl has a non-null name, make accessible in the current scope.
- if (!D->getName().empty())
- PushOnScopeChains(D, FnBodyScope, /*AddToContext=*/false);
-
- // Similarly, dive into enums and fish their constants out, making them
- // accessible in this scope.
- if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
- for (EnumDecl::enumerator_iterator EI = ED->enumerator_begin(),
- EE = ED->enumerator_end(); EI != EE; ++EI)
- PushOnScopeChains(*EI, FnBodyScope, /*AddToContext=*/false);
- }
- }
- }
-
// Checking attributes of current function definition
// dllimport attribute.
DLLImportAttr *DA = FD->getAttr<DLLImportAttr>();
@@ -8229,12 +8177,7 @@
!isa<CXXRecordDecl>(Def) ||
cast<CXXRecordDecl>(Def)->getTemplateSpecializationKind()
== TSK_ExplicitSpecialization) {
- // A redeclaration in function prototype scope in C isn't
- // visible elsewhere, so merely issue a warning.
- if (!getLangOptions().CPlusPlus && S->containedInPrototypeScope())
- Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
- else
- Diag(NameLoc, diag::err_redefinition) << Name;
+ Diag(NameLoc, diag::err_redefinition) << Name;
Diag(Def->getLocation(), diag::note_previous_definition);
// If this is a redefinition, recover by making this
// struct be anonymous, which will make any later
@@ -8516,12 +8459,6 @@
II->isStr("FILE"))
Context.setFILEDecl(New);
- // If we were in function prototype scope (and not in C++ mode), add this
- // tag to the list of decls to inject into the function definition scope.
- if (S->isFunctionPrototypeScope() && !getLangOptions().CPlusPlus &&
- InFunctionDeclarator && Name)
- DeclsInPrototypeScope.push_back(New);
-
OwnedDecl = true;
return New;
}
@@ -10205,12 +10142,6 @@
Enum->completeDefinition(BestType, BestPromotionType,
NumPositiveBits, NumNegativeBits);
-
- // If we're declaring a function, ensure this decl isn't forgotten about -
- // it needs to go into the function scope.
- if (InFunctionDeclarator)
- DeclsInPrototypeScope.push_back(Enum);
-
}
Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr,
Modified: cfe/branches/tooling/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaOverload.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaOverload.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaOverload.cpp Tue Feb 28 19:23:35 2012
@@ -4404,6 +4404,7 @@
Result.setStandard();
Result.Standard.setAsIdentityConversion();
}
+ Result.setListInitializationSequence();
return Result;
}
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporter.cpp Tue Feb 28 19:23:35 2012
@@ -111,6 +111,51 @@
}
//===----------------------------------------------------------------------===//
+// Diagnostic cleanup.
+//===----------------------------------------------------------------------===//
+
+/// Recursively scan through a path and prune out calls and macros pieces
+/// that aren't needed. Return true if afterwards the path contains
+/// "interesting stuff" which means it should be pruned from the parent path.
+static bool RemoveUneededCalls(PathPieces &pieces) {
+ bool containsSomethingInteresting = false;
+ const unsigned N = pieces.size();
+
+ for (unsigned i = 0 ; i < N ; ++i) {
+ // Remove the front piece from the path. If it is still something we
+ // want to keep once we are done, we will push it back on the end.
+ IntrusiveRefCntPtr<PathDiagnosticPiece> piece(pieces.front());
+ pieces.pop_front();
+
+ if (PathDiagnosticCallPiece *call =
+ dyn_cast<PathDiagnosticCallPiece>(piece)) {
+ // Recursively clean out the subclass. Keep this call around if
+ // it contains any informative diagnostics.
+ if (!RemoveUneededCalls(call->path))
+ continue;
+ containsSomethingInteresting = true;
+ }
+ else if (PathDiagnosticMacroPiece *macro =
+ dyn_cast<PathDiagnosticMacroPiece>(piece)) {
+ if (!RemoveUneededCalls(macro->subPieces))
+ continue;
+ containsSomethingInteresting = true;
+ }
+ else if (PathDiagnosticEventPiece *event =
+ dyn_cast<PathDiagnosticEventPiece>(piece)) {
+ // We never throw away an event, but we do throw it away wholesale
+ // as part of a path if we throw the entire path away.
+ if (!event->isPrunable())
+ containsSomethingInteresting = true;
+ }
+
+ pieces.push_back(piece);
+ }
+
+ return containsSomethingInteresting;
+}
+
+//===----------------------------------------------------------------------===//
// PathDiagnosticBuilder and its associated routines and helper objects.
//===----------------------------------------------------------------------===//
@@ -1749,6 +1794,11 @@
GenerateMinimalPathDiagnostic(PD, PDB, N);
break;
}
+
+ // Finally, prune the diagnostic path of uninteresting stuff.
+ bool hasSomethingInteresting = RemoveUneededCalls(PD.getMutablePieces());
+ assert(hasSomethingInteresting);
+ (void) hasSomethingInteresting;
}
void BugReporter::Register(BugType *BT) {
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Tue Feb 28 19:23:35 2012
@@ -436,6 +436,17 @@
const ExplodedNode *Prev,
BugReporterContext &BRC,
BugReport &BR) {
+ PathDiagnosticPiece *piece = VisitNodeImpl(N, Prev, BRC, BR);
+ if (PathDiagnosticEventPiece *ev =
+ dyn_cast_or_null<PathDiagnosticEventPiece>(piece))
+ ev->setPrunable(true);
+ return piece;
+}
+
+PathDiagnosticPiece *ConditionBRVisitor::VisitNodeImpl(const ExplodedNode *N,
+ const ExplodedNode *Prev,
+ BugReporterContext &BRC,
+ BugReport &BR) {
const ProgramPoint &progPoint = N->getLocation();
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Tue Feb 28 19:23:35 2012
@@ -145,35 +145,14 @@
// First flatten out the entire path to make it easier to use.
PathPieces path;
flattenPath(path, D.path);
-
- const SourceManager &SMgr = (*path.begin())->getLocation().getManager();
- FileID FID;
- // Verify that the entire path is from the same FileID.
- for (PathPieces::const_iterator I = path.begin(), E = path.end();
- I != E; ++I) {
- FullSourceLoc L = (*I)->getLocation().asLocation().getExpansionLoc();
-
- if (FID.isInvalid()) {
- FID = SMgr.getFileID(L);
- } else if (SMgr.getFileID(L) != FID)
- return; // FIXME: Emit a warning?
-
- // Check the source ranges.
- for (PathDiagnosticPiece::range_iterator RI = (*I)->ranges_begin(),
- RE = (*I)->ranges_end();
- RI != RE; ++RI) {
- SourceLocation L = SMgr.getExpansionLoc(RI->getBegin());
- if (!L.isFileID() || SMgr.getFileID(L) != FID)
- return; // FIXME: Emit a warning?
- L = SMgr.getExpansionLoc(RI->getEnd());
- if (!L.isFileID() || SMgr.getFileID(L) != FID)
- return; // FIXME: Emit a warning?
- }
- }
-
- if (FID.isInvalid())
- return; // FIXME: Emit a warning?
+ // The path as already been prechecked that all parts of the path are
+ // from the same file and that it is non-empty.
+ const SourceManager &SMgr = (*path.begin())->getLocation().getManager();
+ assert(!path.empty());
+ FileID FID =
+ (*path.begin())->getLocation().asLocation().getExpansionLoc().getFileID();
+ assert(!FID.isInvalid());
// Create a new rewriter to generate HTML.
Rewriter R(const_cast<SourceManager&>(SMgr), PP.getLangOptions());
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Tue Feb 28 19:23:35 2012
@@ -13,6 +13,7 @@
#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
+#include "clang/Basic/SourceManager.h"
#include "clang/AST/Expr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
@@ -76,19 +77,49 @@
}
void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) {
- if (!D)
- return;
+ llvm::OwningPtr<PathDiagnostic> OwningD(D);
- if (D->path.empty()) {
- delete D;
+ if (!D || D->path.empty())
return;
- }
// We need to flatten the locations (convert Stmt* to locations) because
// the referenced statements may be freed by the time the diagnostics
// are emitted.
D->flattenLocations();
+ // If the PathDiagnosticConsumer does not support diagnostics that
+ // cross file boundaries, prune out such diagnostics now.
+ if (!supportsCrossFileDiagnostics()) {
+ // Verify that the entire path is from the same FileID.
+ FileID FID;
+ const SourceManager &SMgr = (*D->path.begin())->getLocation().getManager();
+
+ for (PathPieces::const_iterator I = D->path.begin(), E = D->path.end();
+ I != E; ++I) {
+ FullSourceLoc L = (*I)->getLocation().asLocation().getExpansionLoc();
+
+ if (FID.isInvalid()) {
+ FID = SMgr.getFileID(L);
+ } else if (SMgr.getFileID(L) != FID)
+ return; // FIXME: Emit a warning?
+
+ // Check the source ranges.
+ for (PathDiagnosticPiece::range_iterator RI = (*I)->ranges_begin(),
+ RE = (*I)->ranges_end();
+ RI != RE; ++RI) {
+ SourceLocation L = SMgr.getExpansionLoc(RI->getBegin());
+ if (!L.isFileID() || SMgr.getFileID(L) != FID)
+ return; // FIXME: Emit a warning?
+ L = SMgr.getExpansionLoc(RI->getEnd());
+ if (!L.isFileID() || SMgr.getFileID(L) != FID)
+ return; // FIXME: Emit a warning?
+ }
+ }
+
+ if (FID.isInvalid())
+ return; // FIXME: Emit a warning?
+ }
+
// Profile the node to see if we already have something matching it
llvm::FoldingSetNodeID profile;
D->Profile(profile);
@@ -110,16 +141,14 @@
shouldKeepOriginal = false;
}
- if (shouldKeepOriginal) {
- delete D;
+ if (shouldKeepOriginal)
return;
- }
}
Diags.RemoveNode(orig);
delete orig;
}
- Diags.InsertNode(D);
+ Diags.InsertNode(OwningD.take());
}
Removed: cfe/branches/tooling/test/CodeGen/decl-in-prototype.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/decl-in-prototype.c?rev=151687&view=auto
==============================================================================
--- cfe/branches/tooling/test/CodeGen/decl-in-prototype.c (original)
+++ cfe/branches/tooling/test/CodeGen/decl-in-prototype.c (removed)
@@ -1,15 +0,0 @@
-// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
-
-const int AA = 5;
-
-// CHECK: define i32 @f1
-int f1(enum {AA,BB} E) {
- // CHECK: ret i32 1
- return BB;
-}
-
-// CHECK: define i32 @f2
-int f2(enum {AA=7,BB} E) {
- // CHECK: ret i32 7
- return AA;
-}
Modified: cfe/branches/tooling/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/warning-flags.c?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/warning-flags.c (original)
+++ cfe/branches/tooling/test/Misc/warning-flags.c Tue Feb 28 19:23:35 2012
@@ -17,7 +17,7 @@
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (256):
+CHECK: Warnings without flags (257):
CHECK-NEXT: ext_anonymous_struct_union_qualified
CHECK-NEXT: ext_binary_literal
CHECK-NEXT: ext_cast_fn_obj
@@ -137,6 +137,7 @@
CHECK-NEXT: warn_conv_to_self_not_used
CHECK-NEXT: warn_conv_to_void_not_used
CHECK-NEXT: warn_cxx0x_right_shift_in_template_arg
+CHECK-NEXT: warn_decl_in_param_list
CHECK-NEXT: warn_delete_array_type
CHECK-NEXT: warn_division_by_zero
CHECK-NEXT: warn_double_const_requires_fp64
Removed: cfe/branches/tooling/test/Sema/decl-in-prototype.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/decl-in-prototype.c?rev=151687&view=auto
==============================================================================
--- cfe/branches/tooling/test/Sema/decl-in-prototype.c (original)
+++ cfe/branches/tooling/test/Sema/decl-in-prototype.c (removed)
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1_only -verify %s
-
-const int AA = 5;
-
-int f1(enum {AA,BB} E) {
- return BB;
-}
-
-int f2(enum {AA=7,BB} E) {
- return AA;
-}
-
-struct a {
-};
-
-int f3(struct a { } *); // expected-warning {{will not be visible outside of this function}}
-
-struct A { struct b { int j; } t; }; // expected-note {{previous definition is here}}
-
-int f4(struct A { struct b { int j; } t; } *); // expected-warning {{declaration of 'struct A' will not be visible outside of this function}} expected-warning {{redefinition of 'b' will not be visible outside of this function}}
-
-struct aA {
- struct ab { // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
- int j;
- } b;
-};
-
-int f5(struct aA { struct ab { int j; } b; struct ab { char glorx; } glorx; } *); // expected-warning {{declaration of 'struct aA' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}}
-
-void f6(struct z {int b;} c) { // expected-warning {{declaration of 'struct z' will not be visible outside of this function}}
- struct z d;
- d.b = 4;
-}
Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp?rev=151688&r1=151687&r2=151688&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-initializer-scalars.cpp Tue Feb 28 19:23:35 2012
@@ -3,6 +3,38 @@
struct one { char c[1]; };
struct two { char c[2]; };
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
namespace integral {
void initialization() {
@@ -65,3 +97,13 @@
new int({0}); // expected-error {{cannot initialize}}
}
}
+
+namespace PR12118 {
+ void test() {
+ one f(std::initializer_list<int>);
+ two f(int);
+
+ // to initializer_list is preferred
+ static_assert(sizeof(f({0})) == sizeof(one), "bad overload");
+ }
+}
Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 28 19:23:35 2012
@@ -1,2 +1,2 @@
/cfe/branches/type-system-rewrite/test/SemaCXX/warn-unreachable.cpp:134693-134817
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-151662
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-151673
More information about the llvm-branch-commits
mailing list