Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D15411#307274, @aaron.ballman wrote:

> In http://reviews.llvm.org/D15411#307030, @alexfh wrote:
>
> > BTW, Richard, is the possibility of assignment of an integer to a 
> > std::string a bug in the standard?
>
>
> This is the result of:
>
>   basic_string& operator=(charT c);
>   Returns: *this = basic_string(1,c).
>
>
> So I believe it is by design.


I see how the current behavior can be explained by the standard, however I'm 
not sure this was the intention of the standard to specifically allow this 
behavior.

And if it's unintended (and I'd say undesired), the standard could also be 
changed to enforce a mechanism to disallow assignment of std::string from other 
integer types (e.g. a templated deleted operator= enable_if'd for all integral 
types except for charT, or something like that).

Maybe it wouldn't be reasonable for some reason, but it's worth trying ;)


http://reviews.llvm.org/D15411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/StringIntegerAssignmentCheck.cpp:45
@@ +44,3 @@
+
+  auto Diag = diag(Loc, "probably missing to_string operation");
+  if (!Loc.isMacroID() && getLangOpts().CPlusPlus11) {

I'd expand the message with an explanation of what actually happens here. Also 
it's not clear what the "to_string operation" refers to. And one more thing I 
missed, is other character types.

So I'd go with something similar to: "an integer is interpreted as a character 
code when assigning it to a string; if this is intended, cast the integer to 
'%0'; if you want a string representation, use 
%select{std::to_string()|std::to_wstring()|appropriate conversion facility}1", 
where %0 should be substituted with `char`/`wchar_t`/whatever the specific 
character type is.

(and please add tests for other character types)


http://reviews.llvm.org/D15411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255267 - [Modules] Fix regression when an elaborated-type-specifier mentions a hidden tag

2015-12-10 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Dec 10 11:28:51 2015
New Revision: 255267

URL: http://llvm.org/viewvc/llvm-project?rev=255267=rev
Log:
[Modules] Fix regression when an elaborated-type-specifier mentions a hidden tag

This makes non-C++ languages find the same decl as C++ does to
workaround a regression introduced in r252960.

rdar://problem/23784203

Added:
cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h
cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=255267=255266=255267=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Dec 10 11:28:51 2015
@@ -12121,10 +12121,12 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
 
 // In C++, we need to do a redeclaration lookup to properly
 // diagnose some problems.
-if (getLangOpts().CPlusPlus) {
-  Previous.setRedeclarationKind(ForRedeclaration);
-  LookupQualifiedName(Previous, SearchDC);
-}
+// FIXME: this lookup is also used (with and without C++) to find a hidden
+// declaration so that we don't get ambiguity errors when using a type
+// declared by an elaborated-type-specifier.  In C that is not correct and
+// we should instead merge compatible types found by lookup.
+Previous.setRedeclarationKind(ForRedeclaration);
+LookupQualifiedName(Previous, SearchDC);
   }
 
   // If we have a known previous declaration to use, then use it.

Added: cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h?rev=255267=auto
==
--- cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h (added)
+++ cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h Thu Dec 10 11:28:51 
2015
@@ -0,0 +1,3 @@
+struct S1;
+struct S2 { int x; };
+struct S3 { int x; };

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=255267=255266=255267=diff
==
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Thu Dec 10 11:28:51 2015
@@ -386,3 +386,10 @@ module TypedefTag {
 header "typedef-tag-hidden.h"
   }
 }
+
+module ElaboratedTypeStructs {
+  module Empty {}
+  module Structs {
+header "elaborated-type-structs.h"
+  }
+}

Added: cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m?rev=255267=auto
==
--- cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m 
(added)
+++ cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m Thu 
Dec 10 11:28:51 2015
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I 
%S/Inputs %s -verify
+
+@import ElaboratedTypeStructs.Empty; // The structs are now hidden.
+struct S1 *x;
+struct S2 *y;
+// FIXME: compatible definition should not be an error.
+struct S2 { int x; }; // expected-error {{redefinition}}
+struct S3 *z;
+// Incompatible definition.
+struct S3 { float y; }; // expected-error {{redefinition}}
+// expected-note@elaborated-type-structs.h:* 2 {{previous definition is here}}
+
+@import ElaboratedTypeStructs.Structs;
+
+void useS1(struct S1 *x);
+void useS2(struct S2 *x);
+void useS2(struct S2 *x);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15366: [Clang] Use autos in lib/AST/ASTImporter.cpp

2015-12-10 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: lib/AST/ASTImporter.cpp:5855
@@ -5888,3 +5854,3 @@
   }
-  else if (ObjCProtocolDecl *PD = dyn_cast(D)) {
+  else if (auto *PD = dyn_cast(D)) {
 if (!PD->getDefinition())

aaron.ballman wrote:
> Can you fix the formatting here while you're at it? (Same below.)
Sorry, I do see problem. Could you please elaborate more?


Repository:
  rL LLVM

http://reviews.llvm.org/D15366



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255288 - [Sema] Replace pointer-to-map with a map. NFC.

2015-12-10 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Dec 10 13:25:21 2015
New Revision: 255288

URL: http://llvm.org/viewvc/llvm-project?rev=255288=rev
Log:
[Sema] Replace pointer-to-map with a map. NFC.


Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=255288=255287=255288=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Thu Dec 10 13:25:21 2015
@@ -1339,20 +1339,16 @@ class UninitValsDiagReporter : public Un
   // the same as insertion order. This is needed to obtain a deterministic
   // order of diagnostics when calling flushDiagnostics().
   typedef llvm::MapVector UsesMap;
-  UsesMap *uses;
+  UsesMap uses;
   
 public:
-  UninitValsDiagReporter(Sema ) : S(S), uses(nullptr) {}
+  UninitValsDiagReporter(Sema ) : S(S) {}
   ~UninitValsDiagReporter() override { flushDiagnostics(); }
 
   MappedType (const VarDecl *vd) {
-if (!uses)
-  uses = new UsesMap();
-
-MappedType  = (*uses)[vd];
+MappedType  = uses[vd];
 if (!V.getPointer())
   V.setPointer(new UsesVec());
-
 return V;
   }
 
@@ -1366,10 +1362,7 @@ public:
   }
   
   void flushDiagnostics() {
-if (!uses)
-  return;
-
-for (const auto  : *uses) {
+for (const auto  : uses) {
   const VarDecl *vd = P.first;
   const MappedType  = P.second;
 
@@ -1410,7 +1403,8 @@ public:
   // Release the uses vector.
   delete vec;
 }
-delete uses;
+
+uses.clear();
   }
 
 private:


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15030: [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

With the fix for Alex's last comment, LGTM!


http://reviews.llvm.org/D15030



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/StringIntegerAssignmentCheck.cpp:19
@@ +18,3 @@
+namespace {
+AST_MATCHER(QualType, isAnyCharacter) { return Node->isAnyCharacterType(); }
+} // namespace

I think this would be reasonable to add to ASTMatchers.h, but with the name 
isAnyCharacterType.


Comment at: clang-tidy/misc/StringIntegerAssignmentCheck.cpp:44
@@ +43,3 @@
+  SourceLocation Loc = Argument->getLocStart();
+
+  auto Diag = diag(Loc, "probably missing to_string operation");

Would it make sense to allow = 0 or += 0 for null terminators? Requiring '\0' 
isn't the end of the world, but I think 0 is pretty common for that particular 
case.


Comment at: clang-tidy/misc/StringIntegerAssignmentCheck.cpp:46
@@ +45,3 @@
+  auto Diag = diag(Loc, "probably missing to_string operation");
+  if (!Loc.isMacroID() && getLangOpts().CPlusPlus11) {
+Diag << FixItHint::CreateInsertion(Loc, "std::to_string(")

I don't think to_string() is required for all cases. For instance:
```
s += 12; // --> s += "12";
s = 32; // --> s = ' '; or s = "32";
s = 4; // --> s = '4'; or s = "4";
s += some_integer; // --> s += std::to_string(some_integer);
```
This is also currently doing the wrong thing for std::wstring objects, or 
std::basic_string, etc.


Comment at: clang-tidy/misc/StringIntegerAssignmentCheck.h:18
@@ +17,3 @@
+
+/// Finds instances where integer is assigned to a string.
+///

"where an integer" instead of "where integer".


Comment at: docs/clang-tidy/checks/misc-string-integer-assignment.rst:9
@@ +8,3 @@
+
+The source of the problem is that, the numeric types can be implicity casted 
to most of the
+character types. It possible to assign integers to ``basic_string``.

Can remove the comma.


Comment at: docs/clang-tidy/checks/misc-string-integer-assignment.rst:10
@@ +9,3 @@
+The source of the problem is that, the numeric types can be implicity casted 
to most of the
+character types. It possible to assign integers to ``basic_string``.
+

"It is possible to assign an integer"


Comment at: test/clang-tidy/misc-string-integer-assignment.cpp:39
@@ +38,2 @@
+  s += (char)6;
+}

I would also like to see some tests for std::wstring.


http://reviews.llvm.org/D15411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15388: [Clang] Use autos in lib/AST/Expr.cpp

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: lib/AST/Expr.cpp:67
@@ -65,3 +66,3 @@
 E = CE->getSubExpr();
-CXXRecordDecl *Derived
+auto *Derived
   = cast(E->getType()->getAs()->getDecl());

Again, I don't think it is an improvement when the deduced type is on a 
different line (here and elsewhere).


Comment at: lib/AST/Expr.cpp:1956
@@ -1967,1 +1955,3 @@
+for (const auto  : InitExprs) {
+  if (Stmt *S = I) {
 Beg = S->getLocStart();

Is this line still required? I thought InitExprs was already a vector of Stmt 
objects. I think it should be a const auto * instead of const auto & as well.


Comment at: lib/AST/Expr.cpp:3715
@@ -3741,3 +3714,3 @@
   assert(D.Kind == Designator::ArrayDesignator && "Requires array designator");
-  Stmt *const *SubExprs = reinterpret_cast(this + 1);
+  auto SubExprs = reinterpret_cast(this + 1);
   return cast(*(SubExprs + D.ArrayOrRange.Index + 1));

Hmmm, I'm not certain this is an improvement. It lacks the information that 
SubExprs is a pointer to a pointer, and it lacks the constness information. I 
would revert this one (and the next two).


Repository:
  rL LLVM

http://reviews.llvm.org/D15388



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15366: [Clang] Use autos in lib/AST/ASTImporter.cpp

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: lib/AST/ASTImporter.cpp:1676
@@ -1690,3 +1675,3 @@
 QualType ASTNodeImporter::VisitTypedefType(const TypedefType *T) {
-  TypedefNameDecl *ToDecl
+  const auto *ToDecl
  = 
dyn_cast_or_null(Importer.Import(T->getDecl()));

I don't think it is an improvement when the deduced type is written on the 
subsequent line (here and elsewhere). I wonder if that's something we can teach 
clang-format. e.g.,
```
const auto *ToDecl = dyn_cast_or_null(
  Importer.Import(T->getDecl()));
```
would be an improvement, but only in the case where the declaration type needs 
to be deduced.


Comment at: lib/AST/ASTImporter.cpp:5855
@@ -5888,3 +5854,3 @@
   }
-  else if (ObjCProtocolDecl *PD = dyn_cast(D)) {
+  else if (auto *PD = dyn_cast(D)) {
 if (!PD->getDefinition())

Can you fix the formatting here while you're at it? (Same below.)


Repository:
  rL LLVM

http://reviews.llvm.org/D15366



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15400: [Clang] Use autos in lib/AST/Type.cpp

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: lib/AST/Type.cpp:2016
@@ -2019,3 +2015,3 @@
   case Type::Record:
-if (CXXRecordDecl *ClassDecl
+if (const auto *ClassDecl
   = 
dyn_cast(cast(CanonicalType)->getDecl()))

Not certain this is an improvement due to the type information being on a 
different line.


Repository:
  rL LLVM

http://reviews.llvm.org/D15400



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15388: [Clang] Use autos in lib/AST/Expr.cpp

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: lib/AST/Expr.cpp:3715
@@ -3741,3 +3714,3 @@
   assert(D.Kind == Designator::ArrayDesignator && "Requires array designator");
-  Stmt *const *SubExprs = reinterpret_cast(this + 1);
+  auto SubExprs = reinterpret_cast(this + 1);
   return cast(*(SubExprs + D.ArrayOrRange.Index + 1));

Eugene.Zelenko wrote:
> aaron.ballman wrote:
> > Hmmm, I'm not certain this is an improvement. It lacks the information that 
> > SubExprs is a pointer to a pointer, and it lacks the constness information. 
> > I would revert this one (and the next two).
> But all of this is mentioned in reinterpret_cast.
It is, but our usual rule is to put the cv-qualifiers and &/* as part of the 
auto signature so that the type properties are easier to identify, which is 
what makes this one kind of challenging. Since Stmt is the same length as auto, 
I think leaving it as-is may be less confusing.


Repository:
  rL LLVM

http://reviews.llvm.org/D15388



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255281 - Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.

2015-12-10 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Dec 10 12:52:50 2015
New Revision: 255281

URL: http://llvm.org/viewvc/llvm-project?rev=255281=rev
Log:
Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) 
for all the platforms except PS4.
For PS4, generate explicit import for anonymous namespaces and mark it by 
DW_AT_artificial attribute.

Differential Revision: http://reviews.llvm.org/D12624


Added:
cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Dec 10 12:52:50 2015
@@ -166,6 +166,10 @@ CODEGENOPT(DebugColumnInfo, 1, 0) ///< W
 CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should 
contain
///< external references to a PCH or module.
 
+CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info should 
+   ///< contain explicit imports for 
+   ///< anonymous namespaces
+
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
 /// The user specified number of registers to be used for integral arguments,

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 10 12:52:50 2015
@@ -2337,8 +2337,8 @@ private:
 
   void DiagnoseUnexpectedNamespace(NamedDecl *Context);
 
-  Decl *ParseNamespace(unsigned Context, SourceLocation ,
-   SourceLocation InlineLoc = SourceLocation());
+  DeclGroupPtrTy ParseNamespace(unsigned Context, SourceLocation ,
+SourceLocation InlineLoc = SourceLocation());
   void ParseInnerNamespace(std::vector& IdentLoc,
std::vector& Ident,
std::vector& NamespaceLoc,

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 10 12:52:50 2015
@@ -4093,7 +4093,8 @@ public:
SourceLocation IdentLoc,
IdentifierInfo *Ident,
SourceLocation LBrace,
-   AttributeList *AttrList);
+   AttributeList *AttrList,
+   UsingDirectiveDecl * );
   void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
 
   NamespaceDecl *getStdNamespace() const;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=255281=255280=255281=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 10 12:52:50 2015
@@ -3408,10 +3408,14 @@ llvm::DIScope *CGDebugInfo::getCurrentCo
 void CGDebugInfo::EmitUsingDirective(const UsingDirectiveDecl ) {
   if (CGM.getCodeGenOpts().getDebugInfo() < CodeGenOptions::LimitedDebugInfo)
 return;
-  DBuilder.createImportedModule(
-  getCurrentContextDescriptor(cast(UD.getDeclContext())),
-  getOrCreateNameSpace(UD.getNominatedNamespace()),
-  getLineNumber(UD.getLocation()));
+  const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
+  if (!NSDecl->isAnonymousNamespace() || 
+  CGM.getCodeGenOpts().DebugExplicitImport) { 
+DBuilder.createImportedModule(
+getCurrentContextDescriptor(cast(UD.getDeclContext())),
+getOrCreateNameSpace(NSDecl),
+getLineNumber(UD.getLocation()));
+  }
 }
 
 void CGDebugInfo::EmitUsingDecl(const UsingDecl ) {

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=255281=255280=255281=diff

Re: [PATCH] D15388: [Clang] Use autos in lib/AST/Expr.cpp

2015-12-10 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: lib/AST/Expr.cpp:1956
@@ -1967,1 +1955,3 @@
+for (const auto  : InitExprs) {
+  if (Stmt *S = I) {
 Beg = S->getLocStart();

aaron.ballman wrote:
> Is this line still required? I thought InitExprs was already a vector of Stmt 
> objects. I think it should be a const auto * instead of const auto & as well.
Will fix in commit.


Comment at: lib/AST/Expr.cpp:3715
@@ -3741,3 +3714,3 @@
   assert(D.Kind == Designator::ArrayDesignator && "Requires array designator");
-  Stmt *const *SubExprs = reinterpret_cast(this + 1);
+  auto SubExprs = reinterpret_cast(this + 1);
   return cast(*(SubExprs + D.ArrayOrRange.Index + 1));

aaron.ballman wrote:
> Hmmm, I'm not certain this is an improvement. It lacks the information that 
> SubExprs is a pointer to a pointer, and it lacks the constness information. I 
> would revert this one (and the next two).
But all of this is mentioned in reinterpret_cast.


Repository:
  rL LLVM

http://reviews.llvm.org/D15388



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255231 - Add parentheses to suppress a -Wparentheses warning.

2015-12-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Dec 10 02:49:55 2015
New Revision: 255231

URL: http://llvm.org/viewvc/llvm-project?rev=255231=rev
Log:
Add parentheses to suppress a -Wparentheses warning.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=255231=255230=255231=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Dec 10 02:49:55 2015
@@ -3246,8 +3246,8 @@ DeduceFromInitializerList(Sema , Templ
   // Deduction only needs to be done for dependent types.
   if (ElTy->isDependentType()) {
 for (Expr *E : ILE->inits()) {
-  if (Result = DeduceTemplateArgumentByListElement(S, TemplateParams, ElTy,
-   E, Info, Deduced, TDF))
+  if ((Result = DeduceTemplateArgumentByListElement(S, TemplateParams, 
ElTy,
+E, Info, Deduced, 
TDF)))
 return true;
 }
   }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15410: AnalysisConsumer: use canonical decl for both lookup and store of visited decls

2015-12-10 Thread Aleksei Sidorin via cfe-commits
a.sidorin created this revision.
a.sidorin added reviewers: zaks.anna, xazax.hun, dcoughlin.
a.sidorin added a subscriber: cfe-commits.
a.sidorin set the repository for this revision to rL LLVM.

Due to redeclarations, the function may have different declarations used in 
CallExpr and in the definition. However, we need to use a unique declaration 
for both store and lookup in VisitedCallees. This patch fixes issues with 
analysis in topological order. A simple test is included.

Repository:
  rL LLVM

http://reviews.llvm.org/D15410

Files:
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/inlining/analysis-order.c

Index: test/Analysis/inlining/analysis-order.c
===
--- /dev/null
+++ test/Analysis/inlining/analysis-order.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions 
-analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK: analysis-order.c test1
+// CHECK: analysis-order.c test2
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -483,7 +483,7 @@
 
 // Skip the functions which have been processed already or previously
 // inlined.
-if (shouldSkipFunction(D, Visited, VisitedAsTopLevel))
+if (shouldSkipFunction(D->getCanonicalDecl(), Visited, VisitedAsTopLevel))
   continue;
 
 // Analyze the function.
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -462,7 +462,7 @@
 
   // Mark the decl as visited.
   if (VisitedCallees)
-VisitedCallees->insert(D);
+VisitedCallees->insert(D->getCanonicalDecl());
 
   return true;
 }


Index: test/Analysis/inlining/analysis-order.c
===
--- /dev/null
+++ test/Analysis/inlining/analysis-order.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions -analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK: analysis-order.c test1
+// CHECK: analysis-order.c test2
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -483,7 +483,7 @@
 
 // Skip the functions which have been processed already or previously
 // inlined.
-if (shouldSkipFunction(D, Visited, VisitedAsTopLevel))
+if (shouldSkipFunction(D->getCanonicalDecl(), Visited, VisitedAsTopLevel))
   continue;
 
 // Analyze the function.
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -462,7 +462,7 @@
 
   // Mark the decl as visited.
   if (VisitedCallees)
-VisitedCallees->insert(D);
+VisitedCallees->insert(D->getCanonicalDecl());
 
   return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12726: [analyzer] A fix for symbolic element region index lifetime.

2015-12-10 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255236: [analyzer] Fix symbolic element index lifetime. 
(authored by dergachev).

Changed prior to commit:
  http://reviews.llvm.org/D12726?vs=37267=42400#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12726

Files:
  cfe/trunk/docs/analyzer/DebugChecks.rst
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
  cfe/trunk/test/Analysis/return-ptr-range.cpp
  cfe/trunk/test/Analysis/symbol-reaper.c

Index: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
@@ -171,10 +171,6 @@
   // Copy the binding to the new map.
   EBMapRef = EBMapRef.add(BlkExpr, X);
 
-  // If the block expr's value is a memory region, then mark that region.
-  if (Optional R = X.getAs())
-SymReaper.markLive(R->getRegion());
-
   // Mark all symbols in the block expr's value live.
   RSScaner.scan(X);
   continue;
Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2348,8 +2348,12 @@
   if (const SymbolicRegion *SymR = dyn_cast(baseR))
 SymReaper.markLive(SymR->getSymbol());
 
-  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I)
+  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I) {
+// Element index of a binding key is live.
+SymReaper.markElementIndicesLive(I.getKey().getRegion());
+
 VisitBinding(I.getData());
+  }
 }
 
 void removeDeadBindingsWorker::VisitBinding(SVal V) {
@@ -2370,6 +2374,7 @@
   // If V is a region, then add it to the worklist.
   if (const MemRegion *R = V.getAsRegion()) {
 AddToWorkList(R);
+SymReaper.markLive(R);
 
 // All regions captured by a block are also live.
 if (const BlockDataRegion *BR = dyn_cast(R)) {
Index: cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -391,6 +391,18 @@
 
 void SymbolReaper::markLive(const MemRegion *region) {
   RegionRoots.insert(region);
+  markElementIndicesLive(region);
+}
+
+void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
+  for (auto SR = dyn_cast(region); SR;
+   SR = dyn_cast(SR->getSuperRegion())) {
+if (auto ER = dyn_cast(SR)) {
+  SVal Idx = ER->getIndex();
+  for (auto SI = Idx.symbol_begin(), SE = Idx.symbol_end(); SI != SE; ++SI)
+markLive(*SI);
+}
+  }
 }
 
 void SymbolReaper::markInUse(SymbolRef sym) {
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
@@ -17,22 +17,26 @@
 using namespace ento;
 
 namespace {
-class ExprInspectionChecker : public Checker< eval::Call > {
+class ExprInspectionChecker : public Checker {
   mutable std::unique_ptr BT;
 
   void analyzerEval(const CallExpr *CE, CheckerContext ) const;
   void analyzerCheckInlined(const CallExpr *CE, CheckerContext ) const;
   void analyzerWarnIfReached(const CallExpr *CE, CheckerContext ) const;
   void analyzerCrash(const CallExpr *CE, CheckerContext ) const;
+  void analyzerWarnOnDeadSymbol(const CallExpr *CE, CheckerContext ) const;
 
   typedef void (ExprInspectionChecker::*FnCheck)(const CallExpr *,
  CheckerContext ) const;
 
 public:
   bool evalCall(const CallExpr *CE, CheckerContext ) const;
+  void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
 };
 }
 
+REGISTER_SET_WITH_PROGRAMSTATE(MarkedSymbols, const void *)
+
 bool ExprInspectionChecker::evalCall(const CallExpr *CE,
  CheckerContext ) const {
   // These checks should have no effect on the surrounding environment
@@ -42,7 +46,10 @@
 .Case("clang_analyzer_checkInlined",
   ::analyzerCheckInlined)
 .Case("clang_analyzer_crash", ::analyzerCrash)
-.Case("clang_analyzer_warnIfReached", ::analyzerWarnIfReached)
+.Case("clang_analyzer_warnIfReached",
+  ::analyzerWarnIfReached)
+.Case("clang_analyzer_warnOnDeadSymbol",
+  ::analyzerWarnOnDeadSymbol)
 .Default(nullptr);
 
   if (!Handler)
@@ -137,6 +144,41 @@
   

Re: [PATCH] D15087: [PATCH] Add CERT license clarification

2015-12-10 Thread Chandler Carruth via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

Danny's OK is enough for me. LGTM


http://reviews.llvm.org/D15087



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255232 - [Sema] Use UnaryOperatorKind and BinaryOperatorKind in parameter lists instead of just unsigned. Removes a few explicit casts. NFC

2015-12-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Dec 10 02:51:49 2015
New Revision: 255232

URL: http://llvm.org/viewvc/llvm-project?rev=255232=rev
Log:
[Sema] Use UnaryOperatorKind and BinaryOperatorKind in parameter lists instead 
of just unsigned. Removes a few explicit casts. NFC

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255232=255231=255232=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 10 02:51:49 2015
@@ -2554,12 +2554,12 @@ public:
   ExprResult *Result);
 
   ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
- unsigned Opc,
+ UnaryOperatorKind Opc,
  const UnresolvedSetImpl ,
  Expr *input);
 
   ExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
-   unsigned Opc,
+   BinaryOperatorKind Opc,
const UnresolvedSetImpl ,
Expr *LHS, Expr *RHS);
 
@@ -8447,22 +8447,23 @@ public:
 ExprResult , ExprResult , SourceLocation Loc,
 bool IsCompAssign = false);
   QualType CheckAdditionOperands( // C99 6.5.6
-ExprResult , ExprResult , SourceLocation Loc, unsigned Opc,
-QualType* CompLHSTy = nullptr);
+ExprResult , ExprResult , SourceLocation Loc,
+BinaryOperatorKind Opc, QualType* CompLHSTy = nullptr);
   QualType CheckSubtractionOperands( // C99 6.5.6
 ExprResult , ExprResult , SourceLocation Loc,
 QualType* CompLHSTy = nullptr);
   QualType CheckShiftOperands( // C99 6.5.7
-ExprResult , ExprResult , SourceLocation Loc, unsigned Opc,
-bool IsCompAssign = false);
+ExprResult , ExprResult , SourceLocation Loc,
+BinaryOperatorKind Opc, bool IsCompAssign = false);
   QualType CheckCompareOperands( // C99 6.5.8/9
-ExprResult , ExprResult , SourceLocation Loc, unsigned OpaqueOpc,
-bool isRelational);
+ExprResult , ExprResult , SourceLocation Loc,
+BinaryOperatorKind Opc, bool isRelational);
   QualType CheckBitwiseOperands( // C99 6.5.[10...12]
 ExprResult , ExprResult , SourceLocation Loc,
 bool IsCompAssign = false);
   QualType CheckLogicalOperands( // C99 6.5.[13,14]
-ExprResult , ExprResult , SourceLocation Loc, unsigned Opc);
+ExprResult , ExprResult , SourceLocation Loc,
+BinaryOperatorKind Opc);
   // CheckAssignmentOperands is used for both simple and compound assignment.
   // For simple assignment, pass both expressions and a null converted type.
   // For compound assignment, pass both expressions and the converted type.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=255232=255231=255232=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Dec 10 02:51:49 2015
@@ -7921,9 +7921,10 @@ static void diagnosePointerIncompatibili
 << RHSExpr->getSourceRange();
 }
 
-QualType Sema::CheckAdditionOperands( // C99 6.5.6
-ExprResult , ExprResult , SourceLocation Loc, unsigned Opc,
-QualType* CompLHSTy) {
+// C99 6.5.6
+QualType Sema::CheckAdditionOperands(ExprResult , ExprResult ,
+ SourceLocation Loc, BinaryOperatorKind 
Opc,
+ QualType* CompLHSTy) {
   checkArithmeticNull(*this, LHS, RHS, Loc, /*isCompare=*/false);
 
   if (LHS.get()->getType()->isVectorType() ||
@@ -8099,7 +8100,7 @@ static bool isScopedEnumerationType(Qual
 }
 
 static void DiagnoseBadShiftValues(Sema& S, ExprResult , ExprResult ,
-   SourceLocation Loc, unsigned Opc,
+   SourceLocation Loc, BinaryOperatorKind Opc,
QualType LHSType) {
   // OpenCL 6.3j: shift values are effectively % word size of LHS (more 
defined),
   // so skip remaining warnings as we don't want to modify values within Sema.
@@ -8242,7 +8243,7 @@ static QualType checkOpenCLVectorShift(S
 
 // C99 6.5.7
 QualType Sema::CheckShiftOperands(ExprResult , ExprResult ,
-  SourceLocation Loc, unsigned Opc,
+  SourceLocation Loc, BinaryOperatorKind Opc,
   bool IsCompAssign) {
   checkArithmeticNull(*this, LHS, RHS, Loc, /*isCompare=*/false);
 
@@ -8561,7 +8562,7 @@ static void diagnoseObjCLiteralCompariso
 static void diagnoseLogicalNotOnLHSofComparison(Sema , ExprResult ,
   

Re: [PATCH] D14274: Add alloc_size attribute to clang

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/Attr.td:714
@@ +713,3 @@
+  let Spellings = [GCC<"alloc_size">];
+  let Subjects = SubjectList<[Function]>;
+  let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];

Should this be using HasFunctionProto instead of Function?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2144
@@ -2143,1 +2143,3 @@
 def err_attribute_pointers_only : Error;
+def warn_attribute_integers_only : Warning<
+  "%0 attribute only applies to integer arguments">,

This warning diagnostic is not used.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2145
@@ +2144,3 @@
+def warn_attribute_integers_only : Warning<
+  "%0 attribute only applies to integer arguments">,
+  InGroup;

This text is a bit misleading based on the diagnostic. The attribute doesn't 
apply to the integer argument. The attribute argument should refer to an 
integer parameter of the function declaration. I think the diagnostic should 
reflect that. Perhaps:

%0 attribute argument may only refer to a function parameter of integer type

and the diagnostic loc can point to the attribute argument in question. (If 
that's not possible, it would be good to add a %1 to identify which of the two 
possible attribute arguments is at fault.)


Comment at: lib/AST/ExprConstant.cpp:117
@@ +116,3 @@
+  }
+  /// Attempts to unwrap a CallExpr (with an alloc_size attribute) from an 
Expr.
+  /// This will look through a single cast.

Add a newline to separate the functions (here and elsewhere).


Comment at: lib/AST/ExprConstant.cpp:128
@@ +127,3 @@
+// probably be a cast of some kind. Ignore it.
+if (auto *Cast = dyn_cast(E))
+  E = Cast->getSubExpr()->IgnoreParens();

const auto *, here and elsewhere. Whenever you have auto, we want all the 
cv-qualifiers as well as */& information along with the auto.


Comment at: lib/AST/ExprConstant.cpp:144
@@ +143,3 @@
+  /// array in its designator.
+  static bool baseRequiresUnsizedArrayInDesignator(APValue::LValueBase Base) {
+return isBaseAnAllocSizeCall(Base);

Is this function going to expand to be more than just a forward to another? If 
not, we should remove it.


Comment at: lib/AST/ExprConstant.cpp:156
@@ -119,1 +155,3 @@
+// arrays that lack size info.
+assert(!baseRequiresUnsizedArrayInDesignator(Base));
 unsigned MostDerivedLength = 0;

Would be good to have '&& "explanation of assert"' as well (here and elsewhere).


Comment at: lib/AST/ExprConstant.cpp:264
@@ +263,3 @@
+/// Determined whether the most derived subobject is an array without a
+/// known bound
+bool isMostDerivedAnUnsizedArray() const {

Missing a period.


Comment at: lib/AST/ExprConstant.cpp:269
@@ +268,3 @@
+
+uint64_t getMostDerivedArraySize() const {
+  assert(!isMostDerivedAnUnsizedArray());

Missing function documentation.


Comment at: lib/AST/ExprConstant.cpp:357
@@ +356,3 @@
+// Can't verify -- trust that the user is doing the right thing (or if
+// not, trust that the caller will catch the bad behavior)
+Entries.back().ArrayIndex += N;

Missing period.


Comment at: lib/AST/ExprConstant.cpp:1109
@@ -1022,1 +1108,3 @@
 void set(APValue::LValueBase B, unsigned I = 0, bool BInvalid = false) {
+#ifndef NDEBUG
+  // We only allow a few types of invalid bases. Enforce that here.

Is there a reason this assert only fires in !NDEBUG mode? Is it too expensive 
to enable for any assert build?


Comment at: lib/Sema/SemaDeclAttr.cpp:721
@@ +720,3 @@
+  if (FuncParamNo < 1 || FuncParamNo > FPT->getNumParams()) {
+auto SrcLoc = Attr.getArgAsExpr(AttrArgNo)->getLocStart();
+auto UserArgNo = AttrArgNo + 1;

Please do not use auto unless the type is explicitly spelled out in the 
initializer (here and elsewhere).


Comment at: lib/Sema/SemaDeclAttr.cpp:728
@@ +727,3 @@
+
+  if (!FPT->getParamType(FuncParamNo - 1)->isIntegerType()) {
+auto SrcLoc = Attr.getArgAsExpr(AttrArgNo)->getLocStart();

Are character types and Boolean types also okay?


Comment at: lib/Sema/SemaDeclAttr.cpp:764
@@ +763,3 @@
+  auto *FD = dyn_cast(D);
+  if (FD == nullptr || !FD->hasPrototype()) {
+S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)

If you use HasFunctionProto in Attr.td, none of this is required. If you can't 
use HasFunctionProto, then there's still no need to check FD because that's 
handled by the common attribute code.


Comment at: lib/Sema/SemaDeclAttr.cpp:766
@@ +765,3 @@
+S.Diag(Attr.getLoc(), 

Re: [PATCH] D9600: Add scan-build python implementation

2015-12-10 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist marked an inline comment as done.


Comment at: tools/scan-build-py/bin/analyze-c++:2
@@ +1,3 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# The LLVM Compiler Infrastructure

zaks.anna wrote:
> Where/How is analyze-c++ used?
this is the compiler wrapper which runs the real compiler + the static 
analyzer. (you guys were call it interposition mode) there is 'analyze-c++' and 
'analyze-cc' for C++ and C compilers. it is used from the 
libscanbuild.analyze.main method.


http://reviews.llvm.org/D9600



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15432: [libcxx] Move member function definition before it's explicit template instantiation declaration in to satisfy GCC.

2015-12-10 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, rsmith, eugenis.
EricWF added subscribers: cfe-commits, rsmith.

GCC fail's to compile a number of  tests because three valarray 
member functions cannot be inlined at various points throughout the header. 
This is an error because these functions are marked __always_inline__. Moving 
the definition of these member functions to directly before the extern template 
declaration solves the problem.

An example failure can be found here: 
http://ds2.efcs.ca:8080/builders/gcc-builder/builds/36/steps/test.libcxx-cxx11/logs/FAIL%3A%20libc%2B%2B%3A%3Amultiply.pass.cpp

@rsmith Would you be able to weigh in here. I'm concerned that we might be in 
"ill formed: no diagnostic required" territory.  Do you think GCC's behavior is 
reasonable?





http://reviews.llvm.org/D15432

Files:
  include/valarray

Index: include/valarray
===
--- include/valarray
+++ include/valarray
@@ -819,6 +819,7 @@
 valarray(const gslice_array& __ga);
 valarray(const mask_array& __ma);
 valarray(const indirect_array& __ia);
+
 _LIBCPP_INLINE_VISIBILITY
 ~valarray();
 
@@ -1058,10 +1059,63 @@
 end(const valarray<_Up>& __v);
 };
 
+template 
+void
+valarray<_Tp>::resize(size_t __n, value_type __x)
+{
+if (__begin_ != nullptr)
+{
+while (__end_ != __begin_)
+(--__end_)->~value_type();
+_VSTD::__deallocate(__begin_);
+__begin_ = __end_ = nullptr;
+}
+if (__n)
+{
+__begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try
+{
+#endif  // _LIBCPP_NO_EXCEPTIONS
+for (; __n; --__n, ++__end_)
+::new (__end_) value_type(__x);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+}
+catch (...)
+{
+resize(0);
+throw;
+}
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+}
+
+
+template 
+inline
+valarray<_Tp>::valarray(size_t __n)
+: __begin_(0),
+  __end_(0)
+{
+resize(__n);
+}
+
+template 
+inline
+valarray<_Tp>::~valarray()
+{
+resize(0);
+}
+
+// The definition for these three functions must appear before they are used and
+// before these extern template declarations.
+// Otherwise GCC will fail to inline the definition which is an error because
+// the functions are declared always inline.
 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray::valarray(size_t))
 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray::~valarray())
 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray::resize(size_t, size_t))
 
+
 template 
 struct _UnaryOp<_Op, valarray<_Tp> >
 {
@@ -2747,14 +2801,6 @@
 
 // valarray
 
-template 
-inline
-valarray<_Tp>::valarray(size_t __n)
-: __begin_(0),
-  __end_(0)
-{
-resize(__n);
-}
 
 template 
 inline
@@ -2971,12 +3017,6 @@
 }
 }
 
-template 
-inline
-valarray<_Tp>::~valarray()
-{
-resize(0);
-}
 
 template 
 valarray<_Tp>&
@@ -3689,37 +3729,6 @@
 return __r;
 }
 
-template 
-void
-valarray<_Tp>::resize(size_t __n, value_type __x)
-{
-if (__begin_ != nullptr)
-{
-while (__end_ != __begin_)
-(--__end_)->~value_type();
-_VSTD::__deallocate(__begin_);
-__begin_ = __end_ = nullptr;
-}
-if (__n)
-{
-__begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type)));
-#ifndef _LIBCPP_NO_EXCEPTIONS
-try
-{
-#endif  // _LIBCPP_NO_EXCEPTIONS
-for (; __n; --__n, ++__end_)
-::new (__end_) value_type(__x);
-#ifndef _LIBCPP_NO_EXCEPTIONS
-}
-catch (...)
-{
-resize(0);
-throw;
-}
-#endif  // _LIBCPP_NO_EXCEPTIONS
-}
-}
-
 template
 inline _LIBCPP_INLINE_VISIBILITY
 void
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255297 - www: Mention -DGCC_INSTALL_PREFIX instead of --with-gcc-toolchain

2015-12-10 Thread Justin Bogner via cfe-commits
Author: bogner
Date: Thu Dec 10 14:52:59 2015
New Revision: 255297

URL: http://llvm.org/viewvc/llvm-project?rev=255297=rev
Log:
www: Mention -DGCC_INSTALL_PREFIX instead of --with-gcc-toolchain

Since the instructions use cmake, we should probably refer to the
cmake flags and not the configure ones.

Modified:
cfe/trunk/www/get_started.html

Modified: cfe/trunk/www/get_started.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_started.html?rev=255297=255296=255297=diff
==
--- cfe/trunk/www/get_started.html (original)
+++ cfe/trunk/www/get_started.html Thu Dec 10 14:52:59 2015
@@ -109,7 +109,7 @@ follows:
   the best version of libstdc++ headers available and use them - it will
   look both for system installations of libstdc++ as well as installations
   adjacent to Clang itself. If your configuration fits neither of these
-  scenarios, you can use the --with-gcc-toolchain configure option
+  scenarios, you can use the -DGCC_INSTALL_PREFIX cmake option
   to tell Clang where the gcc containing the desired libstdc++ is 
installed.
   
   Try it out (assuming you add llvm/Debug+Asserts/bin to your path):


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9600: Add scan-build python implementation

2015-12-10 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: tools/scan-build-py/libear/ear.c:140
@@ +139,3 @@
+#ifdef HAVE_NSGETENVIRON
+environ = *_NSGetEnviron();
+#endif

The issue I am seeing with library-interposition on OS X seems to be caused by 
eagerly stashing *_NSGetEnviron() in `environ`. This causes processes that 
modify their environment before execv'ing to drop the modified environments 
because interposition forwards execv to call_execve() with the stale 
environment.

To avoid this, you can replace all references to `environ` on Darwin with 
(*_NSGetEnviron()).


http://reviews.llvm.org/D9600



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15433: [libcxx] Remove inline/visibility attributes from exported template methods in valarray.

2015-12-10 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added a reviewer: EricWF.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

This does not affect the libc++ export list now.
It is required for internal_linkage switch to not affect the libc++ export list.
This patch is on top of D15432.

Repository:
  rL LLVM

http://reviews.llvm.org/D15433

Files:
  include/valarray

Index: include/valarray
===
--- include/valarray
+++ include/valarray
@@ -802,7 +802,6 @@
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
 valarray() : __begin_(0), __end_(0) {}
-_LIBCPP_INLINE_VISIBILITY
 explicit valarray(size_t __n);
 _LIBCPP_INLINE_VISIBILITY
 valarray(const value_type& __x, size_t __n);
@@ -820,7 +819,6 @@
 valarray(const mask_array& __ma);
 valarray(const indirect_array& __ia);
 
-_LIBCPP_INLINE_VISIBILITY
 ~valarray();
 
 // assignment:
@@ -1092,16 +1090,14 @@
 
 
 template 
-inline
 valarray<_Tp>::valarray(size_t __n)
 : __begin_(0),
   __end_(0)
 {
 resize(__n);
 }
 
 template 
-inline
 valarray<_Tp>::~valarray()
 {
 resize(0);


Index: include/valarray
===
--- include/valarray
+++ include/valarray
@@ -802,7 +802,6 @@
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
 valarray() : __begin_(0), __end_(0) {}
-_LIBCPP_INLINE_VISIBILITY
 explicit valarray(size_t __n);
 _LIBCPP_INLINE_VISIBILITY
 valarray(const value_type& __x, size_t __n);
@@ -820,7 +819,6 @@
 valarray(const mask_array& __ma);
 valarray(const indirect_array& __ia);
 
-_LIBCPP_INLINE_VISIBILITY
 ~valarray();
 
 // assignment:
@@ -1092,16 +1090,14 @@
 
 
 template 
-inline
 valarray<_Tp>::valarray(size_t __n)
 : __begin_(0),
   __end_(0)
 {
 resize(__n);
 }
 
 template 
-inline
 valarray<_Tp>::~valarray()
 {
 resize(0);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14411: Use __attribute__((internal_linkage)) when available.

2015-12-10 Thread Evgeniy Stepanov via cfe-commits
eugenis added dependencies: D15433: [libcxx] Remove inline/visibility 
attributes from exported template methods in valarray., D15432: [libcxx] Move 
member function definition before it's explicit template instantiation 
declaration in  to satisfy GCC..
eugenis added a comment.

Depends on http://reviews.llvm.org/D15432.
Depends on http://reviews.llvm.org/D15433.

With all that change, the switch to internal_linkage attribute removes 3 
symbols from the libc++ export table, all in basic_string:
insert(..., InputIterator
insert(..., ForwardIterator
replace(..., InputIterator

These are template methods of a template class. They are instantiated only in 
functions/methods that are marked with LIBCPP_INLINE_VISIBILITY; normally they 
are exported as linkonce_odr; after the internal_linkage switch they are not 
instantiated at all because their callers are never evaluated.

Do you think this is an ABI break?


Repository:
  rL LLVM

http://reviews.llvm.org/D14411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2015-12-10 Thread Alexey Samsonov via cfe-commits
samsonov added inline comments.


Comment at: test/Driver/fsanitize.c:221
@@ +220,3 @@
+// RUN: %clang -target x86_64-apple-darwin10 
-resource-dir=%S/Inputs/resource_dir -fsanitize=memory -fsanitize=thread,memory 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-TSAN-MSAN-DARWIN1
+// CHECK-MSAN-TSAN-MSAN-DARWIN1: unsupported option '-fsanitize=thread,memory' 
for target 'x86_64-apple-darwin10'
+// CHECK-MSAN-TSAN-MSAN-DARWIN1-NOT: unsupported option

beanz wrote:
> kubabrecka wrote:
> > samsonov wrote:
> > > Again, I feel like we're lying to users here: `-fsanitize=thread` *is* 
> > > supported for this target, it just requires building a runtime.
> > I'd like to see this from the point-of-view of a binary distribution.  If 
> > the binary distribution (e.g. the one from llvm.org or Apple's Clang in 
> > Xcode) doesn't contain a runtime library, then the sanitizer is *not* 
> > supported in that distribution.  Also, see http://reviews.llvm.org/D14846, 
> > we'd like to have CMake options to select which runtimes will be built.  If 
> > you deliberately choose not to build ThreadSanitizer, then that sanitizer 
> > is *not* supported in your version of Clang.  If you're experimenting and 
> > porting a runtime to a new platform, then this sanitizer *is* supported in 
> > your version of Clang.
> Maybe the point is we should have a different error message for cases where 
> the runtime is just missing. Something like "runtime components for 
> '-fsanitize=thread' not available"
I see, so essentially you want to use a different approach for determining 
sanitizer availability (on OS X for now): if the library is present, then we 
support sanitizer, otherwise we don't: i.e. the binary distribution is the 
source of truth, not the list of sanitizers hardcoded into Clang driver source 
code. I'm fine with that, and see why it would make sense.

It's just that error message looks misleading: the problem is not TSan is 
unsupported for target, it's just unavailable in this distribution for one 
reason or another.


http://reviews.llvm.org/D15225



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] Reinstate and fix overload sets to be const-correct wherever possible

2015-12-10 Thread Richard Smith via cfe-commits
On Thu, Dec 10, 2015 at 11:45 AM, Marshall Clow 
wrote:

> On Tue, Dec 8, 2015 at 3:52 PM, Richard Smith 
>> wrote:
>>
>>> Ping.
>>>
>>
> Sorry about that.
> Completely missed this in my email flood.
>
> This approach looks ok to me, but I wonder if it would be better to get
> Apple to fix their iOS C library instead.
>

Well, it's not broken in the sense that it does what the C standard library
is supposed to do. But it's not providing the "C pieces" of a C++ standard
library. I don't know what its design goal is here, but with this patch we
don't need to care.

Duncan offered to file a bug on this, but I don't know if that's happened.

Are there other broken C libraries that we are concerned with?
>

Probably :) I don't know the complete set of C standard library
implementations that people use with libc++, but I'd be surprised if Darwin
were the only case we need to fix.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255309 - Objective-C properties: merge attributes when redeclaring 'readonly' as 'readwrite' in an extension.

2015-12-10 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Dec 10 17:02:09 2015
New Revision: 255309

URL: http://llvm.org/viewvc/llvm-project?rev=255309=rev
Log:
Objective-C properties: merge attributes when redeclaring 'readonly' as 
'readwrite' in an extension.

r251874 stopped back-patching the AST when an Objective-C 'readonly'
property is redeclared in a class extension as 'readwrite'. However,
it did not properly handle merging of Objective-C property attributes
(e.g., getter name, ownership, atomicity) to the redeclaration,
leading to bad metadata. Merge (and check!) those property attributes
so we get the right metadata and reasonable ASTs. Fixes
rdar://problem/23823989.

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/CodeGenObjC/property-list-in-extension.m
cfe/trunk/test/SemaObjC/property-3.m
cfe/trunk/test/SemaObjC/property-atomic-redecl.m

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=255309=255308=255309=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Dec 10 17:02:09 2015
@@ -2509,17 +2509,14 @@ public:
   void setPropertyAttributes(PropertyAttributeKind PRVal) {
 PropertyAttributes |= PRVal;
   }
+  void overwritePropertyAttributes(unsigned PRVal) {
+PropertyAttributes = PRVal;
+  }
 
   PropertyAttributeKind getPropertyAttributesAsWritten() const {
 return PropertyAttributeKind(PropertyAttributesAsWritten);
   }
 
-  bool hasWrittenStorageAttribute() const {
-return PropertyAttributesAsWritten & (OBJC_PR_assign | OBJC_PR_copy |
-OBJC_PR_unsafe_unretained | OBJC_PR_retain | OBJC_PR_strong |
-OBJC_PR_weak);
-  }
-
   void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) {
 PropertyAttributesAsWritten = PRVal;
   }

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255309=255308=255309=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 10 17:02:09 
2015
@@ -930,6 +930,9 @@ def warn_missing_explicit_synthesis : Wa
 def warn_property_getter_owning_mismatch : Warning<
   "property declared as returning non-retained objects"
   "; getter returning retained objects">;
+def warn_property_redecl_getter_mismatch : Warning<
+  "getter name mismatch between property redeclaration (%1) and its original "
+  "declaration (%0)">, InGroup;
 def error_property_setter_ambiguous_use : Error<
   "synthesized properties %0 and %1 both claim setter %2 -"
   " use of this setter will cause unexpected behavior">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255309=255308=255309=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 10 17:02:09 2015
@@ -3057,11 +3057,9 @@ public:
   FieldDeclarator ,
   Selector GetterSel,
   Selector SetterSel,
-  const bool isAssign,
   const bool isReadWrite,
-  const unsigned Attributes,
+  unsigned ,
   const unsigned AttributesAsWritten,
-  bool *isOverridingProperty,
   QualType T,
   TypeSourceInfo *TSI,
   tok::ObjCKeywordKind MethodImplKind);
@@ -3075,7 +3073,6 @@ public:
FieldDeclarator ,
Selector GetterSel,
Selector SetterSel,
-   const bool isAssign,
const bool isReadWrite,
const unsigned Attributes,
const unsigned AttributesAsWritten,
@@ -7333,7 +7330,6 @@ public:
   SourceLocation LParenLoc,
   FieldDeclarator , ObjCDeclSpec ,
   Selector GetterSel, Selector SetterSel,
-  bool *OverridingProperty,
   tok::ObjCKeywordKind MethodImplKind,
   DeclContext *lexicalDC = nullptr);
 

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 

Re: [libcxx] Reinstate and fix overload sets to be const-correct wherever possible

2015-12-10 Thread Howard Hinnant via cfe-commits
Fwiw, if you ever here me gripe about the C++ committee’s poor record of 
messing around in the C headers with detrimental effects, this is what I’m 
referring to.  Yes, the C++ signatures are superior.  No, this wasn’t a good 
thing to do.  The C++ committee should not try to change or delete stuff in the 
C headers.  Instead the C++ committee should provide superior alternatives in 
C++-owned headers.

To be clear, my comment is not about Richard’s fine patch.  It is about the C++ 
committee’s decades old mistake of trying to change C headers.  I am being 
noisy in the hopes that it helps us (the C++ committee) never again repeat this 
mistake.

Howard

On Dec 10, 2015, at 6:32 PM, Richard Smith via cfe-commits 
 wrote:
> 
> On Thu, Dec 10, 2015 at 11:45 AM, Marshall Clow  wrote:
> On Tue, Dec 8, 2015 at 3:52 PM, Richard Smith  wrote:
> Ping.
> 
> Sorry about that.
> Completely missed this in my email flood.
> 
> This approach looks ok to me, but I wonder if it would be better to get Apple 
> to fix their iOS C library instead.
> 
> Well, it's not broken in the sense that it does what the C standard library 
> is supposed to do. But it's not providing the "C pieces" of a C++ standard 
> library. I don't know what its design goal is here, but with this patch we 
> don't need to care.
> 
> Duncan offered to file a bug on this, but I don't know if that's happened.
> 
> Are there other broken C libraries that we are concerned with?
> 
> Probably :) I don't know the complete set of C standard library 
> implementations that people use with libc++, but I'd be surprised if Darwin 
> were the only case we need to fix.
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14411: Use __attribute__((internal_linkage)) when available.

2015-12-10 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

With http://reviews.llvm.org/D15434, there is no difference in libc++ export 
list with the switch to internal_linkage.


Repository:
  rL LLVM

http://reviews.llvm.org/D14411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2015-12-10 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

I would like to see a test:

  __float128 qf();
  long double ldf();
  
  long double ld{qf()}; // error: narrowing
  __float128 q{ldf()}; // passes



Comment at: include/clang/Basic/TargetInfo.h:384
@@ +383,3 @@
+  unsigned getFloat128Width() const { return 128; }
+  unsigned getFloat128Align() const { return 128; }
+  const llvm::fltSemantics () const {

This should probably not be hard-coded. On s390x-ibm-linux-gnu, the IEEE 
128-bit binary format type has 8 byte alignment (not 16).


Comment at: lib/CodeGen/CGDebugInfo.cpp:539
@@ -538,2 +538,3 @@
   case BuiltinType::LongDouble:
+  case BuiltinType::Float128:
   case BuiltinType::Double:

Is a PPCDoubleDouble "long double" and "__float128" distinguishable on PPC 
given this DWARF treatment?


Comment at: lib/Lex/LiteralSupport.cpp:604
@@ -596,3 +603,3 @@
   if (isLong || isLongLong) break;  // Cannot be repeated.
-  if (isFloat) break;   // LF invalid.
+  if (isFloat || isFloat128) break; // LF, QL invalid.
 

minor: should the comment have FL instead of LF?


Comment at: lib/Sema/SemaOverload.cpp:1921-1922
@@ -1920,4 +1920,4 @@
   // C99 6.3.1.5p1:
   //   When a float is promoted to double or long double, or a
   //   double is promoted to long double [...].
   if (!getLangOpts().CPlusPlus &&

In C99 6.3.1.5p1:
> [...] its value is unchanged.

Allowing `long double` to promote to `__float128` violates that on at least one 
target platform.
For example, PPCDoubleDouble can represent (2^512) - 1 exactly.



Repository:
  rL LLVM

http://reviews.llvm.org/D15120



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.

2015-12-10 Thread David Li via cfe-commits
davidxl added a comment.

LGTM. Wait a little longer in case other reviews want to chime in.


Repository:
  rL LLVM

http://reviews.llvm.org/D15163



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats

2015-12-10 Thread Richard Smith via cfe-commits
rsmith added a comment.

Changes to ExprConstant and CGExprConstant appear to be pure cleanups; please 
check those in as a separate change.

When this is done, you should also be able to remove the `IgnoreImpCasts` and 
`EmitScalarConversion` calls in the `CK_VectorSplat` handling in 
`ScalarExprEmitter::VisitCastExpr`.



Comment at: lib/Sema/SemaExpr.cpp:5576
@@ +5575,3 @@
+return ExprError();
+  return ImpCastExprToType(CastExprRes.get(), DestElemTy, CK);
+}

Looking at `ScalarExprEmitter::VisitCastExpr`, it seems like we are supposed to 
do something slightly bizarre if the source type is `bool` and we're in OpenCL 
mode -- in that case we're supposed to convert `true` to -1 instead of 1. In 
order for ExprConstant to get that case right, we should emit the appropriate 
implicit cast for that conversion here -- maybe add a 
`CK_SignedBooleanToIntegral` and a `CK_SignedBooleanToFloating`; I don't see 
any nice way to express this with our existing cast kinds.


http://reviews.llvm.org/D14877



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2015-12-10 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

> Yes, less boilerplate code needed to work with AST matchers, powerful clang 
> diagnostic infrastructure is used to report errors, also the add_new_check.py 
> script ;)


Pretty convincing advertisement line :).

> If this class stays in the static analyzer, the clang-tidy check code could 
> probably just depend on the relevant library and use this class?


Sounds straightforward.

> That's not a 100% necessary step (you can always add a matcher for 
> translationUnitDecl() and then traverse the AST using a RecursiveASTVisitor, 
> for example), but this usually results in a more compact and easy to 
> understand code.


I guess, in case I need to rewrite the code, I just wanted to know how the 
AST-Matchers work anyway. :)

> Clang-tidy checks should also be backed by tests ;)


I kind of assumed that I need to rewrite the tests if the implementation gets 
changed.

I'll finish with the path-sensitive checks first and will submit the patch for 
the AST-based checks  to clang-tidy after that.
Thanks for offering a review!


http://reviews.llvm.org/D12761



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


PATCH: error on code that redeclares with an __asm__ label after the first ODR use

2015-12-10 Thread Nick Lewycky via cfe-commits
PR22830 shows a case where some code was adding an __asm__ label after the
first use of a function. GCC and Clang diverged on this code, GCC emitting
the name in the last __asm__ label for all uses while clang would switch in
the middle of the TU as the redeclaration was parsed. The attached patch
detects this case and issues an error on such a redeclaration. If this
breaks real code, we can turn it down to a warning.

Please review!

Nick
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 255303)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -4256,6 +4256,8 @@
 def err_conflicting_types : Error<"conflicting types for %0">;
 def err_different_pass_object_size_params : Error<
   "conflicting pass_object_size attributes on parameters">;
+def err_late_asm_label_name : Error<
+  "cannot apply asm label to %select{variable|function}0 after its first use">;
 def err_nested_redefinition : Error<"nested redefinition of %0">;
 def err_use_with_wrong_tag : Error<
   "use of %0 with tag type that does not match previous declaration">;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp	(revision 255303)
+++ lib/Sema/SemaDecl.cpp	(working copy)
@@ -2379,9 +2379,17 @@
   if (!Old->hasAttrs() && !New->hasAttrs())
 return;
 
-  // attributes declared post-definition are currently ignored
+  // Attributes declared post-definition are currently ignored.
   checkNewAttributesAfterDef(*this, New, Old);
 
+  // Check whether this redeclaration adds an __asm__ label name to a
+  // declaration that has already been used.
+  if (Old->isUsed() && !Old->hasAttr() &&
+  New->hasAttr()) {
+Diag(New->getLocation(), diag::err_late_asm_label_name)
+  << isa(Old) << New->getAttr()->getRange();
+  }
+
   if (!Old->hasAttrs())
 return;
 
Index: test/Sema/asm-label.c
===
--- test/Sema/asm-label.c	(revision 0)
+++ test/Sema/asm-label.c	(working copy)
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify %s
+
+void f();
+void g();
+void f() __asm__("fish");
+
+void f() {
+  g();
+}
+void g() __asm__("gold");  // expected-error{{cannot apply asm label to function after its first use}}
+
+int x;
+int y;
+int x __asm__("xenon");
+
+int test() { return y; }
+
+int y __asm__("yacht");   // expected-error{{cannot apply asm label to variable after its first use}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.

2015-12-10 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: lib/CodeGen/CodeGenModule.cpp:380-381
@@ -379,1 +379,4 @@
+  // In PGO mode, attach maximum function count to the module.
+  if (PGOReader)
+getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
   EmitCtorList(GlobalCtors, "llvm.global_ctors");

Can you add a test for this to clang's test/CodeGen?


Repository:
  rL LLVM

http://reviews.llvm.org/D15163



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255311 - In Objective-C, ignore attempts to redefine the ARC/GC qualifier macros.

2015-12-10 Thread John McCall via cfe-commits
Author: rjmccall
Date: Thu Dec 10 17:31:01 2015
New Revision: 255311

URL: http://llvm.org/viewvc/llvm-project?rev=255311=rev
Log:
In Objective-C, ignore attempts to redefine the ARC/GC qualifier macros.

This works around existing system headers which unconditionally
redefine these macros.

This is reasonably safe to do because we used to warn about it anyway
(outside of system headers).  Continue to warn if the redefinition
would have changed the expansion.  Still permit redefinition if the
macro is explicitly #undef'ed first.

rdar://23788307

Added:
cfe/trunk/test/Lexer/objc_macros.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=255311=255310=255311=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Dec 10 17:31:01 2015
@@ -293,6 +293,9 @@ def warn_pp_macro_hides_keyword : Extens
 def warn_pp_macro_is_reserved_id : Warning<
   "macro name is a reserved identifier">, DefaultIgnore,
   InGroup;
+def warn_pp_objc_macro_redef_ignored : Warning<
+  "ignoring redefinition of Objective-C qualifier macro">,
+  InGroup>;
 
 def pp_invalid_string_literal : Warning<
   "invalid string literal, ignoring final '\\'">;

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=255311=255310=255311=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Dec 10 17:31:01 2015
@@ -2266,6 +2266,30 @@ void Preprocessor::HandleDefineDirective
   // Finally, if this identifier already had a macro defined for it, verify 
that
   // the macro bodies are identical, and issue diagnostics if they are not.
   if (const MacroInfo *OtherMI=getMacroInfo(MacroNameTok.getIdentifierInfo())) 
{
+// In Objective-C, ignore attempts to directly redefine the builtin
+// definitions of the ownership qualifiers.  It's still possible to
+// #undef them.
+auto isObjCProtectedMacro = [](const IdentifierInfo *II) -> bool {
+  return II->isStr("__strong") ||
+ II->isStr("__weak") ||
+ II->isStr("__unsafe_unretained") ||
+ II->isStr("__autoreleasing");
+};
+   if (getLangOpts().ObjC1 &&
+SourceMgr.getFileID(OtherMI->getDefinitionLoc())
+  == getPredefinesFileID() &&
+isObjCProtectedMacro(MacroNameTok.getIdentifierInfo())) {
+  // Warn if it changes the tokens.
+  if ((!getDiagnostics().getSuppressSystemWarnings() ||
+   !SourceMgr.isInSystemHeader(DefineTok.getLocation())) &&
+  !MI->isIdenticalTo(*OtherMI, *this,
+ /*Syntactic=*/LangOpts.MicrosoftExt)) {
+Diag(MI->getDefinitionLoc(), diag::warn_pp_objc_macro_redef_ignored);
+  }
+  assert(!OtherMI->isWarnIfUnused());
+  return;
+}
+
 // It is very common for system headers to have tons of macro redefinitions
 // and for warnings to be disabled in system headers.  If this is the case,
 // then don't bother calling MacroInfo::isIdenticalTo.

Added: cfe/trunk/test/Lexer/objc_macros.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/objc_macros.m?rev=255311=auto
==
--- cfe/trunk/test/Lexer/objc_macros.m (added)
+++ cfe/trunk/test/Lexer/objc_macros.m Thu Dec 10 17:31:01 2015
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only "-triple" "x86_64-apple-macosx10.10.0" 
-fobjc-runtime-has-weak -fobjc-weak %s -verify %s
+
+#define __strong
+// expected-warning@-1 {{ignoring redefinition of Objective-C qualifier macro}}
+#define __weak
+// expected-warning@-1 {{ignoring redefinition of Objective-C qualifier macro}}
+#define __unsafe_unretained
+// expected-warning@-1 {{ignoring redefinition of Objective-C qualifier macro}}
+#define __autoreleased
+// No warning because this is the default expansion anyway.
+
+// Check that this still expands to the right text.
+void test() {
+  goto label; // expected-error {{cannot jump from this goto statement to its 
label}}
+  __weak id x; // expected-note {{jump bypasses initialization of __weak 
variable}}
+label:
+  return;
+}
+
+#undef __strong
+#define __strong
+// No warning.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255314 - Clean ExprConstant/CGExprConstant up a bit. NFC.

2015-12-10 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Dec 10 18:23:35 2015
New Revision: 255314

URL: http://llvm.org/viewvc/llvm-project?rev=255314=rev
Log:
Clean ExprConstant/CGExprConstant up a bit. NFC.


Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=255314=255313=255314=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Dec 10 18:23:35 2015
@@ -1180,7 +1180,7 @@ static bool EvaluatePointer(const Expr *
 static bool EvaluateMemberPointer(const Expr *E, MemberPtr ,
   EvalInfo );
 static bool EvaluateTemporary(const Expr *E, LValue , EvalInfo );
-static bool EvaluateInteger(const Expr *E, APSInt  , EvalInfo );
+static bool EvaluateInteger(const Expr *E, APSInt , EvalInfo );
 static bool EvaluateIntegerOrLValue(const Expr *E, APValue ,
 EvalInfo );
 static bool EvaluateFloat(const Expr *E, APFloat , EvalInfo );
@@ -1607,7 +1607,7 @@ static bool HandleFloatToFloatCast(EvalI
 
 static APSInt HandleIntToIntCast(EvalInfo , const Expr *E,
  QualType DestType, QualType SrcType,
- APSInt ) {
+ const APSInt ) {
   unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
   APSInt Result = Value;
   // Figure out if this is a truncate, extend or noop cast.
@@ -5655,7 +5655,7 @@ static bool EvaluateVector(const Expr* E
   return VectorExprEvaluator(Info, Result).Visit(E);
 }
 
-bool VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
+bool VectorExprEvaluator::VisitCastExpr(const CastExpr *E) {
   const VectorType *VTy = E->getType()->castAs();
   unsigned NElts = VTy->getNumElements();
 
@@ -5668,13 +5668,13 @@ bool VectorExprEvaluator::VisitCastExpr(
 if (SETy->isIntegerType()) {
   APSInt IntResult;
   if (!EvaluateInteger(SE, IntResult, Info))
- return false;
-  Val = APValue(IntResult);
+return false;
+  Val = APValue(std::move(IntResult));
 } else if (SETy->isRealFloatingType()) {
-   APFloat F(0.0);
-   if (!EvaluateFloat(SE, F, Info))
- return false;
-   Val = APValue(F);
+  APFloat FloatResult(0.0);
+  if (!EvaluateFloat(SE, FloatResult, Info))
+return false;
+  Val = APValue(std::move(FloatResult));
 } else {
   return Error(E);
 }

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=255314=255313=255314=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Dec 10 18:23:35 2015
@@ -1350,15 +1350,17 @@ llvm::Constant *CodeGenModule::EmitConst
 return llvm::ConstantStruct::get(STy, Complex);
   }
   case APValue::Vector: {
-SmallVector Inits;
 unsigned NumElts = Value.getVectorLength();
+SmallVector Inits(NumElts);
 
-for (unsigned i = 0; i != NumElts; ++i) {
-  const APValue  = Value.getVectorElt(i);
+for (unsigned I = 0; I != NumElts; ++I) {
+  const APValue  = Value.getVectorElt(I);
   if (Elt.isInt())
-Inits.push_back(llvm::ConstantInt::get(VMContext, Elt.getInt()));
+Inits[I] = llvm::ConstantInt::get(VMContext, Elt.getInt());
+  else if (Elt.isFloat())
+Inits[I] = llvm::ConstantFP::get(VMContext, Elt.getFloat());
   else
-Inits.push_back(llvm::ConstantFP::get(VMContext, Elt.getFloat()));
+llvm_unreachable("unsupported vector element type");
 }
 return llvm::ConstantVector::get(Inits);
   }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9600: Add scan-build python implementation

2015-12-10 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: tools/scan-build-py/README.md:86
@@ +85,3 @@
+The 2. mode is available only on FreeBSD, Linux and OSX. Where library preload
+is available from the dynamic loader. On OSX System Integrity Protection 
security
+feature enabled prevents library preload, so this method will not work in such

This is very unfortunate!

We should call out that library interposition is "not supported on OS X (unless 
System Integrity Protection feature is turned off)" and return an error if 
people are trying to use it (and System Integrity Protection feature is turned 
on).


Comment at: tools/scan-build-py/bin/analyze-build:17
@@ +16,2 @@
+from libscanbuild.analyze import main
+sys.exit(main(this_dir, False))

Please rename 'main'.


Comment at: tools/scan-build-py/bin/analyze-c++:3
@@ +2,3 @@
+# -*- coding: utf-8 -*-
+# The LLVM Compiler Infrastructure
+#

I searched the code and did not see it being called. By looking back at the 
previous revision I see that that libscanbuild.analyze.main used to call 
'analyze-cxx' not 'analyze-c++'. Looks like you've also fixed the same bug with 
'intercept-c++'. 

Is this something that could/would be caught by the tests?


Comment at: tools/scan-build-py/bin/analyze-cc:14
@@ +13,2 @@
+from libscanbuild.analyze import scan_build_wrapper
+sys.exit(scan_build_wrapper(False))

Could you rename **all** of the public functions, not just this one? I am 
talking about the other wrapper and several main functions used as the entry 
points in the scripts.


Comment at: tools/scan-build-py/bin/intercept-build:17
@@ +16,2 @@
+from libscanbuild.intercept import main
+sys.exit(main(this_dir))

Please rename 'main'.


Comment at: tools/scan-build-py/bin/intercept-c++:14
@@ +13,2 @@
+from libscanbuild.intercept import wrapper
+sys.exit(wrapper(True))

Please rename 'wrapper'.


Comment at: tools/scan-build-py/bin/intercept-cc:14
@@ +13,2 @@
+from libscanbuild.intercept import wrapper
+sys.exit(wrapper(False))

Please rename 'wrapper'.


Comment at: tools/scan-build-py/bin/scan-build:17
@@ +16,2 @@
+from libscanbuild.analyze import main
+sys.exit(main(this_dir, True))

Please rename 'main'.


http://reviews.llvm.org/D9600



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255323 - Add some more tests for initializer lists related to CWG1591

2015-12-10 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Thu Dec 10 19:04:30 2015
New Revision: 255323

URL: http://llvm.org/viewvc/llvm-project?rev=255323=rev
Log:
Add some more tests for initializer lists related to CWG1591

Modified:
cfe/trunk/test/CXX/drs/dr15xx.cpp

Modified: cfe/trunk/test/CXX/drs/dr15xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr15xx.cpp?rev=255323=255322=255323=diff
==
--- cfe/trunk/test/CXX/drs/dr15xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr15xx.cpp Thu Dec 10 19:04:30 2015
@@ -150,6 +150,26 @@ namespace dr1591 {  //dr1591. Deducing a
 double *p = f({1, 2, 3});
 float *fp = f({{1}, {1, 2}, {1, 2, 3}});
   }
+  namespace core_reflector_28543 {
+
+template int *f(T (&&)[N]);  // #1
+template char *f(std::initializer_list &&);  //#2
+template int **f(T (&&)[N][M]); //#3 
expected-note{{candidate}}
+template char **f(std::initializer_list (&&)[N]); //#4 
expected-note{{candidate}}
+
+template short *f(T (&&)[2]);  //#5
+
+template using Arr = T[];
+ 
+char *pc = f({1, 2, 3}); // OK prefer #2 via 13.3.3.2 [over.ics.rank]
+char *pc2 = f({1, 2}); // #2 also 
+int *pi = f(Arr{1, 2, 3}); // OK prefer #1
+
+void *pv1 = f({ {1, 2, 3}, {4, 5, 6} }); // expected-error{{ambiguous}} 
btw 3 & 4
+char **pcc = f({ {1}, {2, 3} }); // OK #4
+
+short *ps = f(Arr{1, 2});  // OK #5
+  }
 } // dr1591
 
 #endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9600: Add scan-build python implementation

2015-12-10 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist added inline comments.


Comment at: tools/scan-build-py/libear/ear.c:141
@@ +140,3 @@
+environ = *_NSGetEnviron();
+#endif
+if (!initialized)

this call just sets up the `environ` variables for the `bear_capture_env_t` 
method, two lines down. that call saves the relevant variables... so, if before 
execv'ing somebody modify the variables we still have it saved. (by the way 
`Scons` is the tool which does this.) and when `call_execve` called it recovers 
from the saved environment.

there is a test against it. (tests/functional/cases/test_create_cdb.py:53)

> The issue I am seeing with library-interposition on OS X [...]

can you give me details what did you see? what was the test you were running?


http://reviews.llvm.org/D9600



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255312 - [VFS] Fix status() of opened redirected file

2015-12-10 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Dec 10 17:41:39 2015
New Revision: 255312

URL: http://llvm.org/viewvc/llvm-project?rev=255312=rev
Log:
[VFS] Fix status() of opened redirected file

Make RedirectedFileSystem::openFilForRead(path)->status() the same as
RedirectedFileSystem::status(path). Previously we would just get the
status of the underlying real file, which would not have the IsVFSMapped
bit set.

This fixes rebuilding a module that has an include that is relative to
the includer where we will lookup the real path of that file before we
lookup the VFS location.

rdar://problem/23640339

Added:
cfe/trunk/test/VFS/Inputs/public_header3.h
Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/test/VFS/Inputs/public_header.h
cfe/trunk/test/VFS/Inputs/vfsoverlay.yaml
cfe/trunk/test/VFS/real-path-found-first.m
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=255312=255311=255312=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Dec 10 17:41:39 2015
@@ -1266,20 +1266,27 @@ RedirectingFileSystem::lookupPath(sys::p
   return make_error_code(llvm::errc::no_such_file_or_directory);
 }
 
+static Status getRedirectedFileStatus(const Twine , bool UseExternalNames,
+  Status ExternalStatus) {
+  Status S = ExternalStatus;
+  if (!UseExternalNames)
+S = Status::copyWithNewName(S, Path.str());
+  S.IsVFSMapped = true;
+  return S;
+}
+
 ErrorOr RedirectingFileSystem::status(const Twine , Entry *E) {
   assert(E != nullptr);
-  std::string PathStr(Path.str());
   if (auto *F = dyn_cast(E)) {
 ErrorOr S = ExternalFS->status(F->getExternalContentsPath());
 assert(!S || S->getName() == F->getExternalContentsPath());
-if (S && !F->useExternalName(UseExternalNames))
-  *S = Status::copyWithNewName(*S, PathStr);
 if (S)
-  S->IsVFSMapped = true;
+  return getRedirectedFileStatus(Path, 
F->useExternalName(UseExternalNames),
+ *S);
 return S;
   } else { // directory
 auto *DE = cast(E);
-return Status::copyWithNewName(DE->getStatus(), PathStr);
+return Status::copyWithNewName(DE->getStatus(), Path.str());
   }
 }
 
@@ -1291,22 +1298,17 @@ ErrorOr RedirectingFileSystem::s
 }
 
 namespace {
-/// Provide a file wrapper that returns the external name when asked.
-class NamedFileAdaptor : public File {
+/// Provide a file wrapper with an overriden status.
+class FileWithFixedStatus : public File {
   std::unique_ptr InnerFile;
-  std::string NewName;
+  Status S;
 
 public:
-  NamedFileAdaptor(std::unique_ptr InnerFile, std::string NewName)
-  : InnerFile(std::move(InnerFile)), NewName(std::move(NewName)) {}
+  FileWithFixedStatus(std::unique_ptr InnerFile, Status S)
+  : InnerFile(std::move(InnerFile)), S(S) {}
 
-  llvm::ErrorOr status() override {
-auto InnerStatus = InnerFile->status();
-if (InnerStatus)
-  return Status::copyWithNewName(*InnerStatus, NewName);
-return InnerStatus.getError();
-  }
-  llvm::ErrorOr
+  ErrorOr status() override { return S; }
+  ErrorOr
   getBuffer(const Twine , int64_t FileSize, bool RequiresNullTerminator,
 bool IsVolatile) override {
 return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator,
@@ -1330,11 +1332,15 @@ RedirectingFileSystem::openFileForRead(c
   if (!Result)
 return Result;
 
-  if (!F->useExternalName(UseExternalNames))
-return std::unique_ptr(
-new NamedFileAdaptor(std::move(*Result), Path.str()));
-
-  return Result;
+  auto ExternalStatus = (*Result)->status();
+  if (!ExternalStatus)
+return ExternalStatus.getError();
+
+  // FIXME: Update the status with the name and VFSMapped.
+  Status S = getRedirectedFileStatus(Path, 
F->useExternalName(UseExternalNames),
+ *ExternalStatus);
+  return std::unique_ptr(
+  llvm::make_unique(std::move(*Result), S));
 }
 
 IntrusiveRefCntPtr

Modified: cfe/trunk/test/VFS/Inputs/public_header.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/public_header.h?rev=255312=255311=255312=diff
==
--- cfe/trunk/test/VFS/Inputs/public_header.h (original)
+++ cfe/trunk/test/VFS/Inputs/public_header.h Thu Dec 10 17:41:39 2015
@@ -1,2 +1,3 @@
 #import 
+#import "public_header3.h" // includer-relative
 void from_framework(void);

Added: cfe/trunk/test/VFS/Inputs/public_header3.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/public_header3.h?rev=255312=auto
==
--- 

Re: [PATCH] D15406: Add warning for attribute-cleanup on function parameter.

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

In http://reviews.llvm.org/D15406#307733, @rsmith wrote:

> This looks fine to me, though it would be better to express the restrictions 
> as a `SubjectList` on the attribute definition in 
> `include/clang/Basic/Attr.td` rather than here in code.


It would be nice, but the issue is the unwieldy list of diagnostic enumerations 
for custom subject lists. I would love to find a way to express the diagnostic 
replacement for %1 as part of tablegen instead of manually.

FWIW, this LGTM as well.

~Aaron


http://reviews.llvm.org/D15406



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15370: [scan-view] replace deprecated optparse with argparse

2015-12-10 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I know nothing about this code.


http://reviews.llvm.org/D15370



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 42406.
xazax.hun added a comment.

Minor update to docs.


http://reviews.llvm.org/D15411

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringAssignmentCheck.cpp
  clang-tidy/misc/StringAssignmentCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-assignment.rst
  test/clang-tidy/misc-string-assignment.cpp

Index: test/clang-tidy/misc-string-assignment.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-assignment.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s misc-string-assignment %t
+
+namespace std {
+template
+struct basic_string {
+  basic_string(const T*) {}
+  basic_string& operator=(T) {
+return *this;
+  }
+  basic_string& operator=(basic_string) {
+return *this;
+  }
+  basic_string& operator+=(T) {
+return *this;
+  }
+  basic_string& operator+=(basic_string) {
+return *this;
+  }
+};
+
+typedef basic_string string;
+}
+
+int main() {
+  std::string s("foobar");
+
+  s = 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: probably missing to_string operation [misc-string-assignment]
+// CHECK-FIXES: {{^}}  s = std::to_string(6);{{$}}
+  s = 'c';
+  s = (char)6;
+
+// +=
+  s += 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: probably missing to_string operation [misc-string-assignment]
+// CHECK-FIXES: {{^}}  s += std::to_string(6);{{$}}
+  s += 'c';
+  s += (char)6;
+}
Index: docs/clang-tidy/checks/misc-string-assignment.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-assignment.rst
@@ -0,0 +1,30 @@
+misc-string-assignment
+==
+
+The ``std::basic_string`` has an assignment operator with the following signature:
+
+.. code:: c++
+  basic_string& operator=( CharT ch );
+
+The source of the problem is that, the numeric types can be implicity casted to most of the
+character types. It possible to assign integers to ``basic_string``.
+
+.. code:: c++
+  std::string s;
+  int x = 5965;
+  s = 6;
+  s = x;
+
+Use the appropriate conversion functions or character literals.
+
+.. code:: c++
+  std::string s;
+  int x = 5965;
+  s = '6';
+  s = std::to_string(x);
+
+In order to suppress false positives, use an explicit cast.
+
+.. code:: c++
+  std::string s;
+  s = static_cast(6);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -47,6 +47,7 @@
misc-non-copyable-objects
misc-sizeof-container
misc-static-assert
+   misc-string-assignment
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
misc-undelegated-constructor
Index: clang-tidy/misc/StringAssignmentCheck.h
===
--- /dev/null
+++ clang-tidy/misc/StringAssignmentCheck.h
@@ -0,0 +1,34 @@
+//===--- StringAssignmentCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_ASSIGNMENT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_ASSIGNMENT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Finds instances where integer is assigned to a string.
+///
+/// For more details see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-string-assignment.html
+class StringAssignmentCheck : public ClangTidyCheck {
+public:
+  StringAssignmentCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_ASSIGNMENT_H
+
Index: clang-tidy/misc/StringAssignmentCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/StringAssignmentCheck.cpp
@@ -0,0 +1,50 @@
+//===--- StringAssignmentCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "StringAssignmentCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+void 

Re: [PATCH] D9600: Add scan-build python implementation

2015-12-10 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist marked 7 inline comments as done.
rizsotto.mailinglist added a comment.

thanks for the comments.



Comment at: tools/scan-build-py/bin/analyze-c++:1
@@ +1,2 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-

zaks.anna wrote:
> What calls this script?
sorry, don't get the question


Comment at: tools/scan-build-py/libscanbuild/runner.py:23
@@ +22,3 @@
+""" Decorator for checking the required values in state.
+
+It checks the required attributes in the passed state and stop when

dcoughlin wrote:
> Ok. If I create a patch with additional documentation for these fields, would 
> you be willing to take a look at it to make sure the comments are correct?
sure


http://reviews.llvm.org/D9600



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9600: Add scan-build python implementation

2015-12-10 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist added inline comments.


Comment at: tools/scan-build-py/libear/ear.c:282
@@ +281,3 @@
+DLSYM(func, fp, "execve");
+
+char const **const menvp = bear_update_environment(envp, _env);

okay, since i don't have access for OSX machines can you help me to make it 
right?


http://reviews.llvm.org/D9600



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-12-10 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D14653#306675, @EricWF wrote:

> - I like the approach taken in the library. `__throw_helper` and 
> `__libcxx_noexceptions_abort()`. However I don't like that they are in their 
> own header. We should find another header for these to live in. 
> `` tends to be the dumping ground for these sorts of things.


I've moved these into the `__config` header after Marshall's comments. I chose 
`__config` as any standard header needing to throw exceptions would have to 
include the header which contains `__throw_helper`, which means the user of 
that standard header would end up (unknowingly) including the header which 
contains `__throw_helper`. `__config` seemed like a good option in this regard, 
but I can see that `type_traits` is also included by almost all the standard 
headers, so that should be fine as well.

> 

> 

> - I'm concerned about the cost of the call to `__throw_helper()` when 
> exceptions are turned on. Mostly because it copies the exception given to it 
> but also because it's an unneeded layer of indirection.  Perhaps we could 
> have a macro called `_LIBCPP_THROW(E, MSG)` that is simply defined as `throw 
> E` when exceptions are turned on and `__throw_helper(E, MSG)` otherwise.


Agreed, will do this.

> 

> 

> - I would really like to avoid `#define try` and `#define catch`. Replacing 
> keywords has serious code smell and hides the fact that the test does 
> something useful with exceptions turned off. It also has the slightest 
> possibility of hiding bugs in libc++ (ex it might hide a 'try' keyword within 
> a _LIBCPP_HAS_NO_EXCEPTIONS block). I would be happy simply using `TEST_TRY` 
> and `TEST_CATCH` macros or similar.  This communicates the intent of the test 
> (w/o exceptions) to the reader.


Note that a `try` statement within a `_LIBCPP_NO_EXCEPTIONS` guard will lead to 
a compilation failure (not allowed when compiling with `-fno-exceptions`). But 
I agree about the readability aspect. Our intention was to make the change as 
less intrusive as possible, so that contributors to the standard (with 
exceptions) library tests wouldn't have to worry about the no-exceptions case 
that much. I will update the patch to use `TEST_TRY` and `TEST_CATCH` 
explicitly.

> 

> 

> - While your setjmp/longjmp solution is quite clever it concerns me that 
> longjmp doesn't respect destructors (AFAIK). This means that the tests may 
> leak resources with -fno-exceptions. I would like to avoid this because I 
> think it will prevent the use of sanitizers. Unfortunately I think this means 
> that we will need to actually modify each test.


This is a tricky one. The issue here is, when the library encounters an 
exceptional situation and does not stop the control flow (either by throwing, 
aborting or longjumping) it will continue to execute ignoring the error. This 
means that whatever the follow-up asserts in the respective test cases will 
fail. So, if we are not going to really abort (as the test itself will 
terminate if we do this) the closest option is to longjmp. The alternative of 
course is to develop separate tests for the `no-exceptions` variant, which will 
check for the actual `abort` call and `assert(false)` if the test doesn't 
terminate. This requires a significant amount of effort.

> 

> 

> - The `#define try` and `#define catch` only work when the expression only 
> has one catch block and also when that catch block does not reference the 
> caught exception by name. It seems like this would greatly limit the 
> effectiveness of your approach. How many tests begin to pass after applying 
> your patch?


In my full patch, I encountered about may be ~10 cases where the `catch` blocks 
reference the thrown exception object. The solution was to simply disable those 
asserts that reference the exception object. I think this is acceptable from 
the no-exceptions library perspective.

There are few more tests which are irrelevant for the no-exceptions library 
variant. For example, those under 
`tests/std/language.support/support.exception/` which specifically test the 
exception handling behaviour (IIUC). Also, tests related to thread futures 
where an exception thrown from a `future` is saved and later re-thrown into the 
`get()` calling thread. I think these tests do not fall into the scope of the 
no-exceptions library variant. I've left the `XFAIL`s in for these tests.

Apart from those, I was able to fix all the remaining failures. In total, I 
think there are around 120 new passes. More importantly, I was able to dig out 
and fix quite a few places in the library sources where the `-fno-exceptions` 
library variant does the wrong thing (either `assert` or completely ignore the 
error state).

> - We should document libc++'s support -fno-exceptions in general but we 
> should also document each function that now has well defined behavior with 
> -fno-exceptions as we update the tests.


Agreed. I suppose this would be a 

[clang-tools-extra] r255243 - [clang-tidy] Sort includes case-sensitively.

2015-12-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Dec 10 06:24:19 2015
New Revision: 255243

URL: http://llvm.org/viewvc/llvm-project?rev=255243=rev
Log:
[clang-tidy] Sort includes case-sensitively.

The motivation is:
  1. consistency with clang-format, vim :sort etc.
  2. we don't want the tools to depend on the current locale to do the include
 sorting

Modified:
clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp

Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp?rev=255243=255242=255243=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp Thu Dec 10 
06:24:19 2015
@@ -188,10 +188,7 @@ std::vector IncludeSorter::Ge
   // delete inclusions.
   for (int IncludeKind = 0; IncludeKind < IK_InvalidInclude; ++IncludeKind) {
 std::sort(IncludeBucket[IncludeKind].begin(),
-  IncludeBucket[IncludeKind].end(),
-  [](const std::string , const std::string ) {
-return llvm::StringRef(Left).compare_lower(Right) < 0;
-  });
+  IncludeBucket[IncludeKind].end());
 for (const auto  : IncludeBucket[IncludeKind]) {
   auto  = IncludeLocations[IncludeEntry];
   SourceRangeVector::iterator LocationIterator = Location.begin();


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added a reviewer: alexfh.
xazax.hun added subscribers: dkrupp, cfe-commits.

It is possible to assign arbitrary integer types to strings. Sometimes it is 
the result of missing to_string call or apostrophes. 

This check aims to find such errors.

http://reviews.llvm.org/D15411

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringAssignmentCheck.cpp
  clang-tidy/misc/StringAssignmentCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-assignment.rst
  test/clang-tidy/misc-string-assignment.cpp

Index: test/clang-tidy/misc-string-assignment.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-assignment.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s misc-string-assignment %t
+
+namespace std {
+template
+struct basic_string {
+  basic_string(const T*) {}
+  basic_string& operator=(T) {
+return *this;
+  }
+  basic_string& operator=(basic_string) {
+return *this;
+  }
+  basic_string& operator+=(T) {
+return *this;
+  }
+  basic_string& operator+=(basic_string) {
+return *this;
+  }
+};
+
+typedef basic_string string;
+}
+
+int main() {
+  std::string s("foobar");
+
+  s = 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: probably missing to_string operation [misc-string-assignment]
+// CHECK-FIXES: {{^}}  s = std::to_string(6);{{$}}
+  s = 'c';
+  s = (char)6;
+
+// +=
+  s += 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: probably missing to_string operation [misc-string-assignment]
+// CHECK-FIXES: {{^}}  s += std::to_string(6);{{$}}
+  s += 'c';
+  s += (char)6;
+}
Index: docs/clang-tidy/checks/misc-string-assignment.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-assignment.rst
@@ -0,0 +1,24 @@
+misc-string-assignment
+==
+
+The ``std::basic_string`` has an assignment operator with the following signature:
+
+.. code:: c++
+  basic_string& operator=( CharT ch );
+
+The source of the problem is that, the numeric types can be implicity casted to most of the
+character types. It possible to assign integers to ``basic_string``.
+
+.. code:: c++
+  std::string s;
+  int x = 5965;
+  s = 6;
+  s = x;
+
+Use the appropriate conversion functions or character literals.
+
+.. code:: c++
+  std::string s;
+  int x = 5965;
+  s = '6';
+  s = std::to_string(x);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -47,6 +47,7 @@
misc-non-copyable-objects
misc-sizeof-container
misc-static-assert
+   misc-string-assignment
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
misc-undelegated-constructor
Index: clang-tidy/misc/StringAssignmentCheck.h
===
--- /dev/null
+++ clang-tidy/misc/StringAssignmentCheck.h
@@ -0,0 +1,34 @@
+//===--- StringAssignmentCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_ASSIGNMENT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_ASSIGNMENT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Finds instances where integer is assigned to a string.
+///
+/// For more details see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-string-assignment.html
+class StringAssignmentCheck : public ClangTidyCheck {
+public:
+  StringAssignmentCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_ASSIGNMENT_H
+
Index: clang-tidy/misc/StringAssignmentCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/StringAssignmentCheck.cpp
@@ -0,0 +1,50 @@
+//===--- StringAssignmentCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "StringAssignmentCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace 

Re: [PATCH] D13351: [Power PC] add soft float support for ppc32

2015-12-10 Thread hfin...@anl.gov via cfe-commits
hfinkel added inline comments.


Comment at: lib/Driver/Tools.cpp:1477
@@ +1476,3 @@
+  // If unspecified, choose the default based on the platform.
+  if (ABI == ppc::FloatABI::Invalid) {
+ABI = ppc::FloatABI::Hard;

rjmccall wrote:
> hfinkel wrote:
> > Don't need the { } here.
> We don't seem to have a specific style guideline *mandating* the uses of 
> braces around even single-line statements, but please don't *discourage* them.
I don't believe this represents the current consensus convention on this 
matter. We do actively discourage use of unnecessary braces for ifs, fors, etc. 
The exception being that a series of ifs and elses should have braces for all 
of them if any of them need them.

I often point people at the examples here as representative: 
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

You're right, however, we don't formally dictate this policy in our coding 
standards. Do you actively dislike this viewpoint?


http://reviews.llvm.org/D13351



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255273 - libclang: expose dllexport, dllimport attributes

2015-12-10 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Dec 10 12:45:18 2015
New Revision: 255273

URL: http://llvm.org/viewvc/llvm-project?rev=255273=rev
Log:
libclang: expose dllexport, dllimport attributes

These attributes were previously unexposed.  Expose them through the libclang
interfaces.  Add tests that cover both the MSVC spelling and the GNU spelling.

Added:
cfe/trunk/test/Index/index-attrs.c
cfe/trunk/test/Index/index-attrs.cpp
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=255273=255272=255273=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Dec 10 12:45:18 2015
@@ -1102,6 +1102,9 @@ CursorKind.CUDASHARED_ATTR = CursorKind(
 
 CursorKind.VISIBILITY_ATTR = CursorKind(417)
 
+CursorKind.DLLEXPORT_ATTR = CursorKind(418)
+CursorKind.DLLIMPORT_ATTR = CursorKind(419)
+
 ###
 # Preprocessing
 CursorKind.PREPROCESSING_DIRECTIVE = CursorKind(500)

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=255273=255272=255273=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Dec 10 12:45:18 2015
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 31
+#define CINDEX_VERSION_MINOR 32
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2297,7 +2297,9 @@ enum CXCursorKind {
   CXCursor_CUDAHostAttr  = 415,
   CXCursor_CUDASharedAttr= 416,
   CXCursor_VisibilityAttr= 417,
-  CXCursor_LastAttr  = CXCursor_VisibilityAttr,
+  CXCursor_DLLExport = 418,
+  CXCursor_DLLImport = 419,
+  CXCursor_LastAttr  = CXCursor_DLLImport,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,

Added: cfe/trunk/test/Index/index-attrs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-attrs.c?rev=255273=auto
==
--- cfe/trunk/test/Index/index-attrs.c (added)
+++ cfe/trunk/test/Index/index-attrs.c Thu Dec 10 12:45:18 2015
@@ -0,0 +1,16 @@
+// RUN: c-index-test -index-file -check-prefix CHECK %s -target 
armv7-windows-gnu -fdeclspec
+
+void __declspec(dllexport) export_function(void) {}
+// CHECK: [indexDeclaraton]: kind: function | name: export_function | {{.*}} | 
lang: C
+// CHECK: : attribute(dllexport)
+void __attribute__((dllexport)) export_gnu_attribute(void) {}
+// CHECK: [indexDeclaration] kind: function | name: export_gnu_attribute | 
{{.*}} | lang: C
+// CHECK: : attribute(dllexport)
+
+void __declspec(dllimport) import_function(void);
+// CHECK: [indexDeclaration] kind: function | name: import_function | {{.*}} | 
lang: C
+// CHECK: : attribute(dllimport)
+void __attribute__((dllimport)) import_gnu_attribute(void);
+// CHECK: [indexDeclaration] kind: function | name: import_gnu_function | 
{{.*}} | lang: C
+// CHECK: : attribute(dllimport)
+

Added: cfe/trunk/test/Index/index-attrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-attrs.cpp?rev=255273=auto
==
--- cfe/trunk/test/Index/index-attrs.cpp (added)
+++ cfe/trunk/test/Index/index-attrs.cpp Thu Dec 10 12:45:18 2015
@@ -0,0 +1,50 @@
+// RUN: c-index-test -index-file -check-prefix CHECK %s -target 
armv7-windows-gnu -fdeclspec
+
+struct __declspec(dllexport) export_s {
+  void m();
+};
+// CHECK: [indexDeclaration]: kind: struct | name: export_s | {{.*}} | lang: 
C++
+// CHECK: : attribute(dllexport)
+// CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | 
lang: C++
+// CHECK: : attribute(dllexport)
+
+struct __declspec(dllimport) import_s {
+  void m();
+};
+// CHECK: [indexDeclaration]: kind: struct | name: import_s | {{.*}} | lang: 
C++
+// CHECK: : attribute(dllimport)
+// CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | 
lang: C++
+// CHECK: : attribute(dllimport)
+
+class __attribute__((dllexport)) export_gnu_s {
+  void m();
+};
+// CHECK: [indexDeclaration]: kind: struct | name: export_gnu_s | {{.*}} | 
lang: C++
+// CHECK: : attribute(dllexport)
+// CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | 
lang: C++
+// CHECK: : attribute(dllexport)
+
+class __attribute__((dllimport)) import_gnu_s {
+  void m();
+};
+// CHECK: 

[PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2015-12-10 Thread Louis Dionne via cfe-commits
ldionne created this revision.
ldionne added a reviewer: majnemer.
ldionne added a subscriber: cfe-commits.

This patch adds a `__nth_element` builtin that allows fetching the n-th type of 
a parameter pack with very little compile-time overhead. The patch was inspired 
by r252036 and r252115 by David Majnemer, which add a similar 
`__make_integer_seq` builtin for efficiently creating a `std::integer_sequence`.

http://reviews.llvm.org/D15421

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclTemplate.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/PCH/nth-element.cpp
  test/SemaCXX/nth_element.cpp

Index: test/SemaCXX/nth_element.cpp
===
--- /dev/null
+++ test/SemaCXX/nth_element.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+static_assert(__has_builtin(__nth_element), "");
+
+template 
+using NthElement = __nth_element;
+
+template 
+struct X;
+
+static_assert(__is_same(NthElement<0, X<0>>, X<0>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>>, X<1>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>>, X<2>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>>, X<3>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>, X<4>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>, X<4>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>, X<4>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>, X<4>>, X<3>), "");
+static_assert(__is_same(NthElement<4, X<0>, X<1>, X<2>, X<3>, X<4>>, X<4>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<3>), "");
+static_assert(__is_same(NthElement<4, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<4>), "");
+static_assert(__is_same(NthElement<5, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<5>), "");
+
+template 
+using ErrorNthElement1 = __nth_element; // expected-error{{may not be accessed at an out of bounds index}}
+using illformed1 = ErrorNthElement1, X<1>>; // expected-note{{in instantiation}}
+
+
+template 
+using ErrorNthElement2 = __nth_element; // expected-error{{may not be accessed at an out of bounds index}}
+using illformed2 = ErrorNthElement2, X<1>>; // expected-note{{in instantiation}}
+
+
+template 
+using ErrorNthElement3 = __nth_element; // expected-error{{must be indexed using an integral type}}
+enum Color : int { Red, Green, Blue };
+using illformed3 = ErrorNthElement3, X<1>, X<2>>; // expected-note{{in instantiation}}
Index: test/PCH/nth-element.cpp
===
--- /dev/null
+++ test/PCH/nth-element.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
+
+template 
+struct X { };
+
+template 
+using NthElement = __nth_element;
+
+void fn1() {
+  X<0> x0 = NthElement<0, X<0>, X<1>, X<2>>{};
+  X<1> x1 = NthElement<1, X<0>, X<1>, X<2>>{};
+  X<2> x2 = NthElement<2, X<0>, X<1>, X<2>>{};
+}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4145,6 +4145,7 @@
   RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
   RegisterPredefDecl(Context.MakeIntegerSeqDecl,
  PREDEF_DECL_MAKE_INTEGER_SEQ_ID);
+  RegisterPredefDecl(Context.NthElementDecl, PREDEF_DECL_NTH_ELEMENT_ID);
 
   // Build a record containing all of the tentative definitions in this file, in
   // TentativeDefinitions order.  Generally, this record will be empty for
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ 

Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-12-10 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 42440.
rmaprath added a comment.

Addressing review comments by @EricWF:

- Introduced `_LIBCPP_THROW` macro to appropriately throw or call the 
no-exceptions report routine to handle the exceptional situation (avoid the 
overhead of a function call in the default library). The compiler may be able 
to inline the call to `__throw_helper` to achieve the same effect, but wouldn't 
hurt to make it explicit.

- Renamed `__throw_helper` to `__libcxx_noexceptions_report` as appropriate.

- Added `_LIBCPP_NORETURN` qualifiers to both `__libcxx_noexceptions_report` 
and `__libcxx_noexceptions_abort`.


http://reviews.llvm.org/D14653

Files:
  include/__config
  include/array
  test/std/containers/sequences/array/at.pass.cpp
  test/support/noexcept.h

Index: test/support/noexcept.h
===
--- /dev/null
+++ test/support/noexcept.h
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+//===- noexcept.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef NOEXCEPT_H
+#define NOEXCEPT_H
+
+#ifdef _LIBCPP_NO_EXCEPTIONS
+
+#include 
+#include 
+#include "test_macros.h"
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# if TEST_STD_VER >= 11
+#   define TLS_SPEC thread_local
+# elif defined(_LIBCPP_MSVC)
+#   define TLS_SPEC __declspec(thread)
+# else
+#   define TLS_SPEC __thread
+# endif
+#else
+# define TLS_SPEC
+#endif
+
+// Some tests launch multiple threads, in which case we need to make sure that
+// try_buf is maintained per-thread, otherwise setjmp()/longjmp() will attempt
+// to jump between threads!
+TLS_SPEC jmp_buf try_buf;
+#undef TLS_SPEC
+
+// Re-write try/catch with if/else to mimic a similar control flow when testing
+// the no-exceptions library variant. The idea is to save as much of the usual
+// with-exceptions assertions as possible. This of course does not work when
+// there are multiple catch statements, in those cases we have to use the
+// _LIBCPP_NO_EXCEPTIONS macro as appropriate; such cases are rare.
+#define try if(!setjmp(try_buf))
+#define catch(ex) else
+
+// Jump back to the catch (now else) clause.
+void __libcxx_noexceptions_abort(const char *msg) {
+  fprintf(stderr, "%s\n", msg);
+  longjmp(try_buf, 1);
+}
+
+#endif // _LIBCPP_NO_EXCEPTIONS
+
+#endif // NOEXCEPT_H
Index: test/std/containers/sequences/array/at.pass.cpp
===
--- test/std/containers/sequences/array/at.pass.cpp
+++ test/std/containers/sequences/array/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -19,6 +18,7 @@
 #include 
 
 #include "test_macros.h"
+#include "noexcept.h"
 
 // std::array is explicitly allowed to be initialized with A a = { init-list };.
 // Disable the missing braces warning for this reason.
Index: include/array
===
--- include/array
+++ include/array
@@ -201,11 +201,7 @@
 array<_Tp, _Size>::at(size_type __n)
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+_LIBCPP_THROW(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
@@ -215,11 +211,7 @@
 array<_Tp, _Size>::at(size_type __n) const
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+_LIBCPP_THROW(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -281,7 +281,7 @@
 typedef __char32_t char32_t;
 #endif
 
-#if !(__has_feature(cxx_exceptions))
+#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
 #define _LIBCPP_NO_EXCEPTIONS
 #endif
 
@@ -825,6 +825,38 @@
 #define _LIBCPP_HAS_NO_ATOMIC_HEADER
 #endif
 
+#ifdef _LIBCPP_NO_EXCEPTIONS
+_LIBCPP_NORETURN _LIBCPP_WEAK void __libcxx_noexceptions_abort(const char *msg);
+#endif // _LIBCPP_NO_EXCEPTIONS
+
+extern "C++" {
+template
+_LIBCPP_NORETURN _LIBCPP_ALWAYS_INLINE
+void __libcxx_noexceptions_report(T t, const char *msg = nullptr)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+throw t;
+#else
+if (__libcxx_noexceptions_abort) {
+  if (msg)
+__libcxx_noexceptions_abort(msg);
+  else if (t.what())
+__libcxx_noexceptions_abort(t.what());
+  else
+__libcxx_noexceptions_abort("Exception raised, cannot propagate.\n");
+}

Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2015-12-10 Thread Nathan Wilson via cfe-commits
Hi Louis,

It would probably be useful to get the lines of context as well by doing a
full diff as describer here: http://llvm.org/docs/Phabricator.html#id3

For example, git diff -U99 



On Thu, Dec 10, 2015 at 11:32 AM, Louis Dionne via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> ldionne created this revision.
> ldionne added a reviewer: majnemer.
> ldionne added a subscriber: cfe-commits.
>
> This patch adds a `__nth_element` builtin that allows fetching the n-th
> type of a parameter pack with very little compile-time overhead. The patch
> was inspired by r252036 and r252115 by David Majnemer, which add a similar
> `__make_integer_seq` builtin for efficiently creating a
> `std::integer_sequence`.
>
> http://reviews.llvm.org/D15421
>
> Files:
>   include/clang/AST/ASTContext.h
>   include/clang/AST/DeclTemplate.h
>   include/clang/Basic/Builtins.h
>   include/clang/Basic/DiagnosticSemaKinds.td
>   include/clang/Serialization/ASTBitCodes.h
>   lib/AST/ASTContext.cpp
>   lib/AST/DeclTemplate.cpp
>   lib/Lex/PPMacroExpansion.cpp
>   lib/Sema/SemaLookup.cpp
>   lib/Sema/SemaTemplate.cpp
>   lib/Serialization/ASTReader.cpp
>   lib/Serialization/ASTWriter.cpp
>   test/PCH/nth-element.cpp
>   test/SemaCXX/nth_element.cpp
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2015-12-10 Thread Louis Dionne via cfe-commits
ldionne added a comment.

We should probably consider changing the name from `__nth_element` to something 
else, perhaps something that contains the word "pack". This is especially true 
if we are to implement other intrinsics for manipulating parameter packs, like 
slicing (as proposed by Eric Fiselier). Unless someone with a clearer view of 
the project suggests something, I would probably go with `__pack_element` (and 
then we could add `__pack_slice`, etc...). I have no strong preference.

This patch also raises the question of whether we should have a more separated 
way of adding builtin templates. My job here was very easy because I just 
copied David's revision and tweaked a couple of things here and there, but I 
could imagine it not being obvious at all otherwise. Also, and most 
importantly, if we add other builtin templates, do we want these builtins to 
"clutter" the rest of the code instead of being somewhat isolated? I don't know 
the answer to these questions, but I'd just like to point them out.



Comment at: lib/AST/DeclTemplate.cpp:1245-1249
@@ +1244,7 @@
+createNthElement(const ASTContext , DeclContext *DC) {
+  // typename IndexType
+  auto *IndexType = TemplateTypeParmDecl::Create(
+  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/0,
+  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false);
+  IndexType->setImplicit(true);
+

It would be simpler and better (IMO) to have `template ` instead of `template `, but I couldn't figure out how to create a non-type template 
parameter. Hence, I just adapted the code from David's revision for 
`__make_integer_seq`.


Comment at: lib/Sema/SemaTemplate.cpp:2101-2102
@@ +2100,4 @@
+// We simply return the type at index `Index`.
+// TODO:
+// What are the implications of calling .getExtValue() on an APSInt?
+assert(Index.getExtValue() == Index &&

More generally, what is the proper way to retrieve a non-type template argument 
as a number that I can then use as a normal `std::size_t` (or similar) in the 
code? I really just want to retrieve the index, which is given as a non-type 
template parameter to `__nth_element`, and convert it to a numeric index `n` in 
order to fetch the `n`-th element of the parameter pack.


http://reviews.llvm.org/D15421



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13351: [Power PC] add soft float support for ppc32

2015-12-10 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Driver/Tools.cpp:1477
@@ +1476,3 @@
+  // If unspecified, choose the default based on the platform.
+  if (ABI == ppc::FloatABI::Invalid) {
+ABI = ppc::FloatABI::Hard;

hfinkel wrote:
> rjmccall wrote:
> > hfinkel wrote:
> > > Don't need the { } here.
> > We don't seem to have a specific style guideline *mandating* the uses of 
> > braces around even single-line statements, but please don't *discourage* 
> > them.
> I don't believe this represents the current consensus convention on this 
> matter. We do actively discourage use of unnecessary braces for ifs, fors, 
> etc. The exception being that a series of ifs and elses should have braces 
> for all of them if any of them need them.
> 
> I often point people at the examples here as representative: 
> http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
> 
> You're right, however, we don't formally dictate this policy in our coding 
> standards. Do you actively dislike this viewpoint?
The coding style document uses both styles fairly interchangeably; I would not 
say it states a consensus.  And yes, I actively encourage people to add braces 
in code reviews.


http://reviews.llvm.org/D13351



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12624: Top-level anonymous namespaces are missing import DW_TAG_imported_module and nested anonymous namespaces are not

2015-12-10 Thread Katya Romanova via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255281: Do not generate DW_TAG_imported_module for anonymous 
namespaces (even nested)… (authored by kromanova).

Changed prior to commit:
  http://reviews.llvm.org/D12624?vs=42364=42449#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12624

Files:
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp

Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3408,10 +3408,14 @@
 void CGDebugInfo::EmitUsingDirective(const UsingDirectiveDecl ) {
   if (CGM.getCodeGenOpts().getDebugInfo() < CodeGenOptions::LimitedDebugInfo)
 return;
-  DBuilder.createImportedModule(
-  getCurrentContextDescriptor(cast(UD.getDeclContext())),
-  getOrCreateNameSpace(UD.getNominatedNamespace()),
-  getLineNumber(UD.getLocation()));
+  const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
+  if (!NSDecl->isAnonymousNamespace() || 
+  CGM.getCodeGenOpts().DebugExplicitImport) { 
+DBuilder.createImportedModule(
+getCurrentContextDescriptor(cast(UD.getDeclContext())),
+getOrCreateNameSpace(NSDecl),
+getLineNumber(UD.getLocation()));
+  }
 }
 
 void CGDebugInfo::EmitUsingDecl(const UsingDecl ) {
Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -7185,7 +7185,8 @@
SourceLocation IdentLoc,
IdentifierInfo *II,
SourceLocation LBrace,
-   AttributeList *AttrList) {
+   AttributeList *AttrList,
+   UsingDirectiveDecl *) {
   SourceLocation StartLoc = InlineLoc.isValid() ? InlineLoc : NamespaceLoc;
   // For anonymous namespace, take the location of the left brace.
   SourceLocation Loc = II ? IdentLoc : LBrace;
@@ -7299,14 +7300,13 @@
 // namespace internal linkage.
 
 if (!PrevNS) {
-  UsingDirectiveDecl* UD
-= UsingDirectiveDecl::Create(Context, Parent,
- /* 'using' */ LBrace,
- /* 'namespace' */ SourceLocation(),
- /* qualifier */ NestedNameSpecifierLoc(),
- /* identifier */ SourceLocation(),
- Namespc,
- /* Ancestor */ Parent);
+  UD = UsingDirectiveDecl::Create(Context, Parent,
+  /* 'using' */ LBrace,
+  /* 'namespace' */ SourceLocation(),
+  /* qualifier */ NestedNameSpecifierLoc(),
+  /* identifier */ SourceLocation(),
+  Namespc,
+  /* Ancestor */ Parent);
   UD->setImplicit();
   Parent->addDecl(UD);
 }
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -365,6 +365,7 @@
  const TargetOptions ) {
   using namespace options;
   bool Success = true;
+  llvm::Triple Triple = llvm::Triple(TargetOpts.Triple);
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
   // TODO: This could be done in Driver
@@ -409,6 +410,8 @@
   Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
+  if (Triple.isPS4CPU())
+Opts.DebugExplicitImport = true;
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
 Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -1465,15 +1465,13 @@
 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_namespace)) {
   ProhibitAttributes(attrs);
   SourceLocation InlineLoc = ConsumeToken();
-  SingleDecl = ParseNamespace(Context, DeclEnd, InlineLoc);
-  break;
+  return ParseNamespace(Context, DeclEnd, InlineLoc);
 }
 return 

Re: [PATCH] D15433: [libcxx] Remove inline/visibility attributes from exported template methods in valarray.

2015-12-10 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Won't this mean that libc++ possibly exports 3 more template definitions? I 
think this is likely safe but I would rather not export any more symbols if it 
can be avoided.

I'm probably nitpicking here though.



Comment at: include/valarray:823
@@ -822,3 +821,2 @@
 
-_LIBCPP_INLINE_VISIBILITY
 ~valarray();

So I think we still want the almost every instantiation of 
valarray::~valarray() to have internal linkage except for the 
specialization valarray::~valarray(); Do you see any way to make this 
possible?


Repository:
  rL LLVM

http://reviews.llvm.org/D15433



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] Reinstate and fix overload sets to be const-correct wherever possible

2015-12-10 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2015-Dec-10, at 15:32, Richard Smith  wrote:
> 
> On Thu, Dec 10, 2015 at 11:45 AM, Marshall Clow  wrote:
> On Tue, Dec 8, 2015 at 3:52 PM, Richard Smith  wrote:
> Ping.
> 
> Sorry about that.
> Completely missed this in my email flood.
> 
> This approach looks ok to me, but I wonder if it would be better to get Apple 
> to fix their iOS C library instead.
> 
> Well, it's not broken in the sense that it does what the C standard library 
> is supposed to do. But it's not providing the "C pieces" of a C++ standard 
> library. I don't know what its design goal is here, but with this patch we 
> don't need to care.
> 
> Duncan offered to file a bug on this, but I don't know if that's happened.

Nope, I lost track of this.

I just re-read the thread and I'm not clear on what bug I would even file with 
the Libc folks.

Darwin's implementation of the string.h C header seems to match what n1570's 
7.24.5.2 The strchr function asks for.  That's not the right thing for n3337's 
21.7 Null-terminated sequence utilities, but that does seem like a problem for 
libc++ to solve.

I'm probably missing the point somehow though.  If you can clarify exactly what 
should be different in Libc (whether or not it's a bug in C), I can ask around 
and find out how likely it is to get fixed.  (What does GCC do here that it's 
not a problem over there?  Provide different signatures depending on whether 
the caller is C or C++?)

> Are there other broken C libraries that we are concerned with?
> 
> Probably :) I don't know the complete set of C standard library 
> implementations that people use with libc++, but I'd be surprised if Darwin 
> were the only case we need to fix.

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255325 - Correctly type-check the default arguments of local functions

2015-12-10 Thread John McCall via cfe-commits
Author: rjmccall
Date: Thu Dec 10 19:56:36 2015
New Revision: 255325

URL: http://llvm.org/viewvc/llvm-project?rev=255325=rev
Log:
Correctly type-check the default arguments of local functions
when eagerly instantiating them.

rdar://23721638

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=255325=255324=255325=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Dec 10 19:56:36 2015
@@ -1680,8 +1680,11 @@ ParmVarDecl *Sema::SubstParmVarDecl(Parm
   Sema::ContextRAII SavedContext(*this, OwningFunc);
   LocalInstantiationScope Local(*this);
   ExprResult NewArg = SubstExpr(Arg, TemplateArgs);
-  if (NewArg.isUsable())
-NewParm->setDefaultArg(NewArg.get());
+  if (NewArg.isUsable()) {
+// It would be nice if we still had this.
+SourceLocation EqualLoc = NewArg.get()->getLocStart();
+SetParamDefaultArgument(NewParm, NewArg.get(), EqualLoc);
+  }
 } else {
   // FIXME: if we non-lazily instantiated non-dependent default args for
   // non-dependent parameter types we could remove a bunch of duplicate

Modified: cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp?rev=255325=255324=255325=diff
==
--- cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp Thu Dec 10 19:56:36 
2015
@@ -448,3 +448,30 @@ namespace PR21332 {
   }
   template void f7();
 }
+
+// rdar://23721638: Ensure that we correctly perform implicit
+// conversions when instantiating the default arguments of local functions.
+namespace rdar23721638 {
+  struct A {
+A(const char *) = delete;  // expected-note 2 {{explicitly marked deleted 
here}}
+  };
+
+  template  void foo() {
+struct Inner { // expected-note {{in instantiation}}
+  void operator()(T a = "") {} // expected-error {{conversion function 
from 'const char [1]' to 'rdar23721638::A' invokes a deleted function}}
+  // expected-note@-1 {{passing argument to parameter 'a' here}}
+  // expected-note@-2 {{candidate function not viable}}
+};
+Inner()(); // expected-error {{no matching function}}
+  }
+  template void foo(); // expected-note 2 {{in instantiation}}
+
+  template  void bar() {
+auto lambda = [](T a = "") {}; // expected-error {{conversion function 
from 'const char [1]' to 'rdar23721638::A' invokes a deleted function}}
+  // expected-note@-1 {{passing argument to parameter 'a' here}}
+  // expected-note@-2 {{candidate function not viable}}
+  // expected-note@-3 {{conversion candidate of type}}
+lambda(); // expected-error {{no matching function}}
+  }
+  template void bar(); // expected-note {{in instantiation}}
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15433: [libcxx] Remove inline/visibility attributes from exported template methods in valarray.

2015-12-10 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

Libc++.so does not instantiate valarray for any other types, so this does not 
add any extra exports.

Definitions valarray members (with types other than size_t) will now be 
exported from user code. This looks like a positive change to me:

- these methods are already part of the ABI due to the exported template 
valarray
- exported vs hidden/internal can produce smaller code


Repository:
  rL LLVM

http://reviews.llvm.org/D15433



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255326 - [PGO] Add a test case to cover version-3 format

2015-12-10 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Thu Dec 10 22:02:57 2015
New Revision: 255326

URL: http://llvm.org/viewvc/llvm-project?rev=255326=rev
Log:
[PGO] Add a test case to cover version-3 format

Added:
cfe/trunk/test/Profile/Inputs/c-general.profdata.v3   (with props)
Modified:
cfe/trunk/test/Profile/c-general.c

Added: cfe/trunk/test/Profile/Inputs/c-general.profdata.v3
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/c-general.profdata.v3?rev=255326=auto
==
Binary file - no diff available.

Propchange: cfe/trunk/test/Profile/Inputs/c-general.profdata.v3
--
svn:mime-type = application/octet-stream

Modified: cfe/trunk/test/Profile/c-general.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-general.c?rev=255326=255325=255326=diff
==
--- cfe/trunk/test/Profile/c-general.c (original)
+++ cfe/trunk/test/Profile/c-general.c Thu Dec 10 22:02:57 2015
@@ -4,7 +4,7 @@
 
 // RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c 
%s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck 
-check-prefix=PGOUSE %s
-
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c 
%s -o - -emit-llvm -fprofile-instr-use=%S/Inputs/c-general.profdata.v3 | 
FileCheck -check-prefix=PGOUSE %s
 // Also check compatibility with older profiles.
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c 
%s -o - -emit-llvm -fprofile-instr-use=%S/Inputs/c-general.profdata.v1 | 
FileCheck -check-prefix=PGOUSE %s
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255324 - Revert "[Modules] Fix regression when an elaborated-type-specifier mentions a hidden tag"

2015-12-10 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Dec 10 19:44:43 2015
New Revision: 255324

URL: http://llvm.org/viewvc/llvm-project?rev=255324=rev
Log:
Revert "[Modules] Fix regression when an elaborated-type-specifier mentions a 
hidden tag"

This is causing assertion failures; reverting until I can fix.

This reverts commit r255267

Removed:
cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h
cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=255324=255323=255324=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Dec 10 19:44:43 2015
@@ -12121,12 +12121,10 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
 
 // In C++, we need to do a redeclaration lookup to properly
 // diagnose some problems.
-// FIXME: this lookup is also used (with and without C++) to find a hidden
-// declaration so that we don't get ambiguity errors when using a type
-// declared by an elaborated-type-specifier.  In C that is not correct and
-// we should instead merge compatible types found by lookup.
-Previous.setRedeclarationKind(ForRedeclaration);
-LookupQualifiedName(Previous, SearchDC);
+if (getLangOpts().CPlusPlus) {
+  Previous.setRedeclarationKind(ForRedeclaration);
+  LookupQualifiedName(Previous, SearchDC);
+}
   }
 
   // If we have a known previous declaration to use, then use it.

Removed: cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h?rev=255323=auto
==
--- cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h (original)
+++ cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h (removed)
@@ -1,3 +0,0 @@
-struct S1;
-struct S2 { int x; };
-struct S3 { int x; };

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=255324=255323=255324=diff
==
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Thu Dec 10 19:44:43 2015
@@ -386,10 +386,3 @@ module TypedefTag {
 header "typedef-tag-hidden.h"
   }
 }
-
-module ElaboratedTypeStructs {
-  module Empty {}
-  module Structs {
-header "elaborated-type-structs.h"
-  }
-}

Removed: cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m?rev=255323=auto
==
--- cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m 
(original)
+++ cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m 
(removed)
@@ -1,18 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I 
%S/Inputs %s -verify
-
-@import ElaboratedTypeStructs.Empty; // The structs are now hidden.
-struct S1 *x;
-struct S2 *y;
-// FIXME: compatible definition should not be an error.
-struct S2 { int x; }; // expected-error {{redefinition}}
-struct S3 *z;
-// Incompatible definition.
-struct S3 { float y; }; // expected-error {{redefinition}}
-// expected-note@elaborated-type-structs.h:* 2 {{previous definition is here}}
-
-@import ElaboratedTypeStructs.Structs;
-
-void useS1(struct S1 *x);
-void useS2(struct S2 *x);
-void useS2(struct S2 *x);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255244 - [NFC] Improve a comment from my previous commit (r255221)

2015-12-10 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Thu Dec 10 06:29:11 2015
New Revision: 255244

URL: http://llvm.org/viewvc/llvm-project?rev=255244=rev
Log:
[NFC] Improve a comment from my previous commit (r255221)

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=255244=255243=255244=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Dec 10 06:29:11 2015
@@ -3228,7 +3228,7 @@ DeduceFromInitializerList(Sema , Templ
   const bool IsDependentSizedArray =
   !IsConstSizedArray && AdjustedParamType->isDependentSizedArrayType();
 
-  QualType ElTy;  // The type of the std::initializer_list or the array 
element.
+  QualType ElTy;  // The element type of the std::initializer_list or the 
array.
 
   const bool IsSTDList = !IsConstSizedArray && !IsDependentSizedArray &&
  S.isStdInitializerList(AdjustedParamType, );


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-12-10 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Before you spend time changing the tests to use `TEST_TRY`/`TEST_CATCH` I would 
like somebody else to weigh in. I don't really think my solution is that great 
either.  @jroelofs, @mclow any thoughts?

A couple of more thoughts:

- Forget what I said about putting it in . I think it's fine in 
__config

- Because `throw_helper` no longer throws it should probably be renamed to 
something more appropriate.
- `__throw_helper` and `__libcpp_noexceptions_abort` should probably be marked 
`_LIBCPP_NORETURN`. I can't think of a sane case where you would want to return.


http://reviews.llvm.org/D14653



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15030: [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-12-10 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

One more nit. Leaving the rest to Aaron, since most of the comments were his.



Comment at: clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h:25
@@ +24,3 @@
+class ProBoundsConstantArrayIndexCheck : public ClangTidyCheck {
+  std::string GslHeader;
+  const IncludeSorter::IncludeStyle IncludeStyle;

GslHeader can be const as well.


http://reviews.llvm.org/D15030



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

That's quite a surprising behavior. Looks like a bug in the library 
implementation (or in the standard) to me.

But the check is awesome. Thank you!



Comment at: clang-tidy/misc/StringAssignmentCheck.cpp:21
@@ +20,3 @@
+void StringAssignmentCheck::registerMatchers(MatchFinder *Finder) {
+  auto Matcher = cxxOperatorCallExpr(
+  anyOf(hasOverloadedOperatorName("="), hasOverloadedOperatorName("+=")),

Please only register the matcher for C++ code (see almost any other check for 
an example). It also seems that you don't need the `Matcher` variable.


Comment at: clang-tidy/misc/StringAssignmentCheck.cpp:33
@@ +32,3 @@
+
+  if (!ArgType->isIntegerType() || ArgType->isAnyCharacterType())
+return;

The `isIntegerType()` check can be moved to the matcher. I'd also add a matcher 
for `isAnyCharacterType` and move that check to the matcher as well. The latter 
is fine for a follow-up.


Comment at: clang-tidy/misc/StringAssignmentCheck.cpp:36
@@ +35,3 @@
+  SourceLocation Loc = Argument->getLocStart();
+  SmallVector Hints;
+  if (!Loc.isMacroID()) {

Instead of storing the fixits in an array, I'd organize the code as follows:

  auto Diag = diag(...);
  if (!Loc.isMacroID()) {
Diag << FixItHint::CreateInsertion(...) << FixItHint::CreateInsertion(...);
  }


Comment at: clang-tidy/misc/StringAssignmentCheck.cpp:38
@@ +37,3 @@
+  if (!Loc.isMacroID()) {
+Hints.push_back(FixItHint::CreateInsertion(Loc, "std::to_string("));
+Hints.push_back(FixItHint::CreateInsertion(

Please check that we're in C++11 mode before suggesting this fix.


Comment at: clang-tidy/misc/StringAssignmentCheck.h:1
@@ +1,2 @@
+//===--- StringAssignmentCheck.h - clang-tidy*- C++ 
-*-===//
+//

I suggest making the name more specific, e.g. `StringIntegerAssignmentCheck`. 
Same for the check name (`misc-string-integer-assignment`).


http://reviews.llvm.org/D15411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

BTW, Richard, is the possibility of assignment of an integer to a std::string a 
bug in the standard?


http://reviews.llvm.org/D15411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255236 - [analyzer] Fix symbolic element index lifetime.

2015-12-10 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Dec 10 03:28:06 2015
New Revision: 255236

URL: http://llvm.org/viewvc/llvm-project?rev=255236=rev
Log:
[analyzer] Fix symbolic element index lifetime.

SymbolReaper was destroying the symbol too early when it was referenced only
from an index SVal of a live ElementRegion.

In order to test certain aspects of this patch, extend the debug.ExprInspection
checker to allow testing SymbolReaper in a direct manner.

Differential Revision: http://reviews.llvm.org/D12726


Added:
cfe/trunk/test/Analysis/return-ptr-range.cpp
cfe/trunk/test/Analysis/symbol-reaper.c
Modified:
cfe/trunk/docs/analyzer/DebugChecks.rst
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp

Modified: cfe/trunk/docs/analyzer/DebugChecks.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/DebugChecks.rst?rev=255236=255235=255236=diff
==
--- cfe/trunk/docs/analyzer/DebugChecks.rst (original)
+++ cfe/trunk/docs/analyzer/DebugChecks.rst Thu Dec 10 03:28:06 2015
@@ -138,6 +138,29 @@ ExprInspection checks
   clang_analyzer_warnIfReached();  // no-warning
 }
 
+- void clang_analyzer_warnOnDeadSymbol(int);
+
+  Subscribe for a delayed warning when the symbol that represents the value of
+  the argument is garbage-collected by the analyzer.
+
+  When calling 'clang_analyzer_warnOnDeadSymbol(x)', if value of 'x' is a
+  symbol, then this symbol is marked by the ExprInspection checker. Then,
+  during each garbage collection run, the checker sees if the marked symbol is
+  being collected and issues the 'SYMBOL DEAD' warning if it does.
+  This way you know where exactly, up to the line of code, the symbol dies.
+
+  It is unlikely that you call this function after the symbol is already dead,
+  because the very reference to it as the function argument prevents it from
+  dying. However, if the argument is not a symbol but a concrete value,
+  no warning would be issued.
+
+  Example usage::
+
+do {
+  int x = generate_some_integer();
+  clang_analyzer_warnOnDeadSymbol(x);
+} while(0);  // expected-warning{{SYMBOL DEAD}}
+
 
 Statistics
 ==

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h?rev=255236=255235=255236=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
Thu Dec 10 03:28:06 2015
@@ -639,6 +639,7 @@ public:
   }
   
   void markLive(const MemRegion *region);
+  void markElementIndicesLive(const MemRegion *region);
   
   /// \brief Set to the value of the symbolic store after
   /// StoreManager::removeDeadBindings has been called.

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp?rev=255236=255235=255236=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp Thu Dec 10 
03:28:06 2015
@@ -17,22 +17,26 @@ using namespace clang;
 using namespace ento;
 
 namespace {
-class ExprInspectionChecker : public Checker< eval::Call > {
+class ExprInspectionChecker : public Checker {
   mutable std::unique_ptr BT;
 
   void analyzerEval(const CallExpr *CE, CheckerContext ) const;
   void analyzerCheckInlined(const CallExpr *CE, CheckerContext ) const;
   void analyzerWarnIfReached(const CallExpr *CE, CheckerContext ) const;
   void analyzerCrash(const CallExpr *CE, CheckerContext ) const;
+  void analyzerWarnOnDeadSymbol(const CallExpr *CE, CheckerContext ) const;
 
   typedef void (ExprInspectionChecker::*FnCheck)(const CallExpr *,
  CheckerContext ) const;
 
 public:
   bool evalCall(const CallExpr *CE, CheckerContext ) const;
+  void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
 };
 }
 
+REGISTER_SET_WITH_PROGRAMSTATE(MarkedSymbols, const void *)
+
 bool ExprInspectionChecker::evalCall(const CallExpr *CE,
  CheckerContext ) const {
   // These checks should have no effect on the surrounding environment
@@ -42,7 +46,10 @@ bool ExprInspectionChecker::evalCall(con
 .Case("clang_analyzer_checkInlined",
   ::analyzerCheckInlined)
 

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2015-12-10 Thread Nemanja Ivanovic via cfe-commits
nemanjai updated this revision to Diff 42414.
nemanjai added a comment.

Updated to address review comments. Rather than listing responses and 
justification for some of the changes, I'll provide comments inline for better 
readability.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TokenKinds.def
  include/clang/Driver/Options.td
  include/clang/Lex/LiteralSupport.h
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Format/FormatToken.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Index/USRGeneration.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/CodeGenCXX/float128-declarations.cpp
  test/Preprocessor/init.c
  test/Sema/128bitfloat.cpp
  test/SemaCXX/deleted-operator.cpp
  test/SemaCXX/overloaded-builtin-operators.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -51,6 +51,7 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(Float128);
 BTCASE(NullPtr);
 BTCASE(Overload);
 BTCASE(Dependent);
@@ -460,6 +461,7 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(Float128);
 TKIND(NullPtr);
 TKIND(Overload);
 TKIND(Dependent);
Index: test/SemaCXX/overloaded-builtin-operators.cpp
===
--- test/SemaCXX/overloaded-builtin-operators.cpp
+++ test/SemaCXX/overloaded-builtin-operators.cpp
@@ -183,7 +183,7 @@
   // FIXME: lots of candidates here!
   (void)(1.0f * a); // expected-error{{ambiguous}} \
 // expected-note 4{{candidate}} \
-// expected-note {{remaining 117 candidates omitted; pass -fshow-overloads=all to show them}}
+// expected-note {{remaining 140 candidates omitted; pass -fshow-overloads=all to show them}}
 }
 
 // pr5432
Index: test/SemaCXX/deleted-operator.cpp
===
--- test/SemaCXX/deleted-operator.cpp
+++ test/SemaCXX/deleted-operator.cpp
@@ -9,7 +9,7 @@
   PR10757 a1;
   // FIXME: We get a ridiculous number of "built-in candidate" notes here...
   if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 8 {{built-in candidate}}
-  if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 121 {{built-in candidate}}
+  if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 144 {{built-in candidate}}
 }
 
 struct DelOpDel {
Index: test/Sema/128bitfloat.cpp
===
--- test/Sema/128bitfloat.cpp
+++ test/Sema/128bitfloat.cpp
@@ -2,23 +2,23 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 #if !defined(__STRICT_ANSI__)
-__float128 f;  // expected-error {{support for type '__float128' is not yet implemented}}
+__float128 f;  // expected-error {{__float128 is not supported on this target}}
 // But this should work:
 template struct __is_floating_point_helper {};
-template<> struct __is_floating_point_helper<__float128> {};
+template<> struct __is_floating_point_helper<__float128> {};  // expected-error {{__float128 is not supported on this target}}
 
 // FIXME: This could have a better diag.
-void g(int x, __float128 *y) {
-  x + *y;  // expected-error {{invalid operands to binary expression ('int' and '__float128')}}
+int g(int x, __float128 *y) {  // expected-error {{__float128 is not supported on this target}}
+  return x + *y;
 }
 
 #else
-__float128 f;  // expected-error {{unknown type name '__float128'}}
+__float128 f;  // expected-error {{__float128 is not supported on this target}}
 template struct __is_floating_point_helper {};
-template<> struct __is_floating_point_helper<__float128> {};  // expected-error {{use of 

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2015-12-10 Thread Nemanja Ivanovic via cfe-commits
nemanjai added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:2064
@@ +2063,3 @@
+if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble())
+  Out << "U10__float128"; // Match the GCC mangling
+else

Please refer to https://gcc.gnu.org/ml/gcc-patches/2015-10/txt5mF4d1XnFb.txt.
GCC recently added this for PowerPC and the new mangling was provided for the 
__float128 type when it coexists with long double.


Comment at: lib/AST/StmtPrinter.cpp:1234
@@ -1233,2 +1233,3 @@
   case BuiltinType::LongDouble: OS << 'L'; break;
+  case BuiltinType::Float128:   OS << 'Q'; break;
   }

As in GCC, __float128 literals in source code have a suffix 'q'/'Q'. I'll be 
perfectly honest - I don't know when this function is called, but it seems that 
for consistency, we should use the same suffix here.


Comment at: lib/Basic/TargetInfo.cpp:228
@@ -226,1 +227,3 @@
   return LongDouble;
+if (hasFloat128Type())
+  return Float128;

Left this condition in but moved it down. This way if a target exists that has 
'long double' that is narrower than 128 bits, but it supports __float128, we 
can still return a 128-bit floating point type here.


Comment at: lib/Basic/Targets.cpp:1043
@@ +1042,3 @@
+  bool hasFloat128Type() const override {
+return HasFloat128;
+  }

Now that we have different mangling for __float128 and long double, it should 
be safe to support __float128 and leave the mangling of long double unchanged.


Comment at: lib/Basic/Targets.cpp:1236
@@ -1229,1 +1235,3 @@
+  if (HasFloat128)
+Builder.defineMacro("__FLOAT128__");
 

GCC defines this macro when -mfloat128 is specified.


Comment at: lib/CodeGen/CGExprScalar.cpp:1799
@@ -1798,3 +1798,3 @@
 else {
-  // Remaining types are either Half or LongDouble.  Convert from float.
+  // Remaining types are Half, LongDouble or __float128. Convert from 
float.
   llvm::APFloat F(static_cast(amount));

An expression incrementing a variable of __float128 type was added to the test 
case.


Comment at: lib/Frontend/InitPreprocessor.cpp:718
@@ -717,1 +717,3 @@
+  if (TI.hasFloat128Type())
+DefineFloatMacros(Builder, "FLT128", (), "Q");
 

GCC does not do this at this particular time, but it seems logical to actually 
provide this macro on targets that support it. For PPC, the macros are defined 
(and tested) to match IEEE quad precision values (when -mfloat128 is specified).


Comment at: lib/Index/USRGeneration.cpp:603
@@ -602,1 +602,3 @@
+case BuiltinType::Float128:
+  c = 'Q'; break;
 case BuiltinType::NullPtr:

As far as I can tell, this does not collide and it is consistent with the 
literal suffix for this type. However, I'd be happy to change it if there is a 
better suffix to use. Do you have a different suggestion @akyrtzi?


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r255248 - Add a license clarification for use of links and titles of CERT secure coding guidelines.

2015-12-10 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Dec 10 07:53:36 2015
New Revision: 255248

URL: http://llvm.org/viewvc/llvm-project?rev=255248=rev
Log:
Add a license clarification for use of links and titles of CERT secure coding 
guidelines.

Added:
clang-tools-extra/trunk/clang-tidy/cert/LICENSE.TXT
Modified:
clang-tools-extra/trunk/LICENSE.TXT

Modified: clang-tools-extra/trunk/LICENSE.TXT
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/LICENSE.TXT?rev=255248=255247=255248=diff
==
--- clang-tools-extra/trunk/LICENSE.TXT (original)
+++ clang-tools-extra/trunk/LICENSE.TXT Thu Dec 10 07:53:36 2015
@@ -59,5 +59,4 @@ licenses, and/or restrictions:
 
 Program Directory
 --- -
-
-
+clang-tidy  clang-tidy/cert

Added: clang-tools-extra/trunk/clang-tidy/cert/LICENSE.TXT
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/LICENSE.TXT?rev=255248=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/LICENSE.TXT (added)
+++ clang-tools-extra/trunk/clang-tidy/cert/LICENSE.TXT Thu Dec 10 07:53:36 2015
@@ -0,0 +1,22 @@
+--
+clang-tidy CERT Files
+--
+All clang-tidy files are licensed under the LLVM license with the following
+additions:
+
+Any file referencing a CERT Secure Coding guideline:
+Please allow this letter to serve as confirmation that open source projects on
+http://llvm.org are permitted to link via hypertext to the CERT(R) secure 
coding
+guidelines available at https://www.securecoding.cert.org.   
+
+The foregoing is permitted by the Terms of Use as follows:
+"Linking to the Service
+Because we update many of our Web documents regularly, we would prefer that you
+link to our Web pages whenever possible rather than reproduce them. It is not
+necessary to request permission to make referential hypertext links to The
+Service."
+http://www.sei.cmu.edu/legal/ip/index.cfm.
+
+Please allow this letter to also confirm that no formal permission is required
+to reproduce the title of the content being linked to, nor to reproduce any
+de Minimis description of such content.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15087: [PATCH] Add CERT license clarification

2015-12-10 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Commit in r255248, thank you for the review!

~Aaron


http://reviews.llvm.org/D15087



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14839: [libcxx] LWG2485: get() should be overloaded for const tuple&

2015-12-10 Thread Agustín Bergé via cfe-commits
K-ballo updated this revision to Diff 42432.
K-ballo added a comment.

Addressed review comments


http://reviews.llvm.org/D14839

Files:
  include/__tuple
  include/array
  include/tuple
  include/utility
  test/std/containers/sequences/array/array.tuple/get_const_rv.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
  test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
  test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp

Index: test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
===
--- test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
+++ test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -23,7 +24,7 @@
 assert ( std::get(t1).real() == 1 );
 assert ( std::get(t1).imag() == 2 );
 }
-
+
 {
 const std::pair p1 { 1, 2 };
 const int  = std::get(p1);
@@ -35,9 +36,35 @@
 {
 typedef std::unique_ptr upint;
 std::pair t(upint(new int(4)), 42);
-upint p = std::get<0>(std::move(t)); // get rvalue
+upint p = std::get(std::move(t)); // get rvalue
+assert(*p == 4);
+assert(std::get(t) == nullptr); // has been moved from
+}
+
+{
+typedef std::unique_ptr upint;
+const std::pair t(upint(new int(4)), 42);
+static_assert(std::is_same(std::move(t)))>::value, "");
+static_assert(std::is_same(std::move(t)))>::value, "");
+auto&& p = std::get(std::move(t)); // get const rvalue
+auto&& i = std::get(std::move(t)); // get const rvalue
 assert(*p == 4);
-assert(std::get<0>(t) == nullptr); // has been moved from
+assert(i == 42);
+assert(std::get(t) != nullptr);
+}
+
+{
+int x = 42;
+int const y = 43;
+std::pair const p(x, y);
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(std::is_same(std::move(p)))>::value, "");
+}
+
+{
+constexpr const std::pair p { 1, 2 };
+static_assert(std::get(std::move(p)) == 1, "");
+static_assert(std::get(std::move(p)) == 2, "");
 }
 
 #endif
Index: test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
===
--- /dev/null
+++ test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
@@ -0,0 +1,51 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  struct pair
+
+// template
+// const typename tuple_element >::type&&
+// get(const pair&&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+#include 
+#include 
+
+int main()
+{
+{
+typedef std::pair P;
+const P p(std::unique_ptr(new int(3)), 4);
+static_assert(std::is_same&&, decltype(std::get<0>(std::move(p)))>::value, "");
+const std::unique_ptr&& ptr = std::get<0>(std::move(p));
+assert(*ptr == 3);
+}
+
+{
+int x = 42;
+int const y = 43;
+std::pair const p(x, y);
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(std::is_same(std::move(p)))>::value, "");
+}
+
+#if TEST_STD_VER > 11
+{
+typedef std::pair P;
+constexpr const P p1(3, 4);
+static_assert(std::get<0>(std::move(p1)) == 3, "");
+static_assert(std::get<1>(std::move(p1)) == 4, "");
+}
+#endif
+}
Index: test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -21,19 +22,19 @@
 typedef std::complex cf;
 {
 auto t1 = std::tuple { 42, "Hi", { 1,2 }};
-assert ( std::get(t1) == 42 ); // find at the beginning 
+assert ( std::get(t1) == 42 ); // find at the beginning
 assert ( std::get(t1) == "Hi" ); // find in the middle
 assert ( std::get(t1).real() == 1 ); // find at the end
 assert ( std::get(t1).imag() == 2 );
 }
-
+
 {
 auto t2 = std::tuple { 42, "Hi", 23, { 1,2 }};
 //  get would 

Re: r252960 - [modules] Simplify and generalize the existing rule for finding hidden

2015-12-10 Thread Ben Langmuir via cfe-commits

> On Dec 9, 2015, at 2:49 PM, Richard Smith  wrote:
> 
> On Wed, Dec 9, 2015 at 2:00 PM, Ben Langmuir  > wrote:
> 
>> On Dec 9, 2015, at 1:36 PM, Richard Smith > > wrote:
>> 
>> On Wed, Dec 9, 2015 at 11:55 AM, Ben Langmuir via cfe-commits 
>> > wrote:
>> > On Dec 9, 2015, at 11:07 AM, Ben Langmuir > > > wrote:
>> >
>> > Hey Richard,
>> >
>> > This caused a new error for the following code:
>> >
>> >@import Foo.X; // declaration of ‘struct foo’ from Foo.Y is not visible 
>> > yet, but the pcm is loaded.
>> >struct foo *bar; // declares ‘struct foo’
>> >@import Foo.Y; // also declares ‘struct foo’
>> >
>> >void useFoo(struct foo *x);  // error: reference to ‘foo’ is ambiguous
>> >
>> > This seems to be specific to declaring the tag with an elaborated type 
>> > specifier that is not just ‘struct foo;’.  Any idea what went wrong?  I’m 
>> > trying to track this down and fix it.
>> 
>> It’s also specific to non-C++ language modes.  In C++ we seem to cheat and 
>> make a second lookup that has ForRedeclaration set (SemaDecl.cpp:12122) 
>> which then turns this into a use of the hidden declaration rather than 
>> creating a new declaration or redeclaration.  I call this “cheating” because 
>> the comments imply this second lookup is for diagnostic purposes, but it 
>> clearly has a semantic affect in this case.
>> 
>> Well, this comes back to our handling of C structs and modules being a 
>> little incoherent. Suppose Foo.Y defines one 'struct foo', and we define a 
>> completely different 'struct foo':
>> 
>> // Foo.Y
>> struct foo { int n; };
>> 
>> // my.c
>> @import Foo.X;
>> struct foo *bar;
>> struct foo { double d; };
>> // Don't import Foo.Y
>> 
>> If this is not an error, then our declaration of 'struct foo' cannot be the 
>> same type as Foo.Y. The usual C rule for structs is that you can have 
>> multiple conflicting definitions in different TUs. Such declarations declare 
>> different types, but they're compatible types (and thus can be used 
>> interchangeably) if they're structurally equivalent.
>> 
>> I think implementing that rule for C is the right way to go here. Either 
>> that, or we extend C++'s ODR semantics to C modules, but given that the C 
>> standard gives us a completely reasonable rule here, it seems more 
>> appropriate to follow it.
> 
> + Doug
> 
> To make sure I understand: if we followed the C rules then in my original 
> example we would get a fresh declaration here:
> struct foo *x;
> 
> and then when we import
> @import Foo.Y;
> 
> we would try to merge the types, and if we had more than one definition we 
> would diagnose if they aren’t structurally equivalent.
> 
> No. At the point of import, the name 'foo' would name two different structs. 
> If at some later point we look up 'foo' in the tag name space, name lookup 
> would fold together the lookup results if they refer to compatible types (and 
> if they're not compatible, you'd get an ambiguity error at the point of use). 
> Likewise, ASTContext::typesAreCompatible would be extended to treat such 
> types as compatible in the cases where the C standard says they are 
> compatible (presumably with a cache so we don't repeatedly check for the same 
> pair of types).

Ah, thanks for explaining.

> 
> Whereas if we used the ODR we could use the hidden declaration directly like 
> we do in C++,
> 
> That would cause my example above to silently do the wrong thing. You'd get a 
> struct foo with a single member 'n', despite no such member being visible. In 
> C++, the code would already be ill-formed (NDR) due to violating the ODR, so 
> that's less terrible (but still pretty bad). In C, where the corresponding 
> code not using modules is valid, such behavior is pretty hard to defend.
> 
> although perhaps looking it up with a for-redeclaration lookup wouldn’t be 
> sufficient if we fixed the linkage of the structs as you mention below.
> 
> Switching to structural equivalence checking seems like a big change to make 
> just to fix this regression.  Even if that’s what we want I’m not sure I 
> could sign up for it right now.  Is there a more tactical way we could fix 
> this in the interim?
> 
> Adding the for-redeclaration lookup to C seems fine to me as a short-term 
> workaround. (This will break again if/when we fix the linkage of C types, but 
> I don't think we have a reason to do that until we have the type 
> compatibility rules implemented.)

Okay, I did this in r255267.

>> I guess the reason this started failing after r252960 is because of this 
>> change:
>> > This also removes the prior special case for tag lookup, which made some 
>> > cases
>> > of this work, but also led to bizarre, bogus "must use 'struct' to refer 
>> > to type
>> > 'Foo' in this 

Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2015-12-10 Thread Louis Dionne via cfe-commits
ldionne updated this revision to Diff 42443.
ldionne added a comment.

Added full lines of context. Sorry for not doing it the first time around.


http://reviews.llvm.org/D15421

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclTemplate.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/PCH/nth-element.cpp
  test/SemaCXX/nth_element.cpp

Index: test/SemaCXX/nth_element.cpp
===
--- /dev/null
+++ test/SemaCXX/nth_element.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+static_assert(__has_builtin(__nth_element), "");
+
+template 
+using NthElement = __nth_element;
+
+template 
+struct X;
+
+static_assert(__is_same(NthElement<0, X<0>>, X<0>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>>, X<1>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>>, X<2>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>>, X<3>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>, X<4>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>, X<4>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>, X<4>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>, X<4>>, X<3>), "");
+static_assert(__is_same(NthElement<4, X<0>, X<1>, X<2>, X<3>, X<4>>, X<4>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<3>), "");
+static_assert(__is_same(NthElement<4, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<4>), "");
+static_assert(__is_same(NthElement<5, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<5>), "");
+
+template 
+using ErrorNthElement1 = __nth_element; // expected-error{{may not be accessed at an out of bounds index}}
+using illformed1 = ErrorNthElement1, X<1>>; // expected-note{{in instantiation}}
+
+
+template 
+using ErrorNthElement2 = __nth_element; // expected-error{{may not be accessed at an out of bounds index}}
+using illformed2 = ErrorNthElement2, X<1>>; // expected-note{{in instantiation}}
+
+
+template 
+using ErrorNthElement3 = __nth_element; // expected-error{{must be indexed using an integral type}}
+enum Color : int { Red, Green, Blue };
+using illformed3 = ErrorNthElement3, X<1>, X<2>>; // expected-note{{in instantiation}}
Index: test/PCH/nth-element.cpp
===
--- /dev/null
+++ test/PCH/nth-element.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
+
+template 
+struct X { };
+
+template 
+using NthElement = __nth_element;
+
+void fn1() {
+  X<0> x0 = NthElement<0, X<0>, X<1>, X<2>>{};
+  X<1> x1 = NthElement<1, X<0>, X<1>, X<2>>{};
+  X<2> x2 = NthElement<2, X<0>, X<1>, X<2>>{};
+}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4136,6 +4136,7 @@
   RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
   RegisterPredefDecl(Context.MakeIntegerSeqDecl,
  PREDEF_DECL_MAKE_INTEGER_SEQ_ID);
+  RegisterPredefDecl(Context.NthElementDecl, PREDEF_DECL_NTH_ELEMENT_ID);
 
   // Build a record containing all of the tentative definitions in this file, in
   // TentativeDefinitions order.  Generally, this record will be empty for
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6423,6 +6423,9 @@
 
   case PREDEF_DECL_MAKE_INTEGER_SEQ_ID:
 return Context.getMakeIntegerSeqDecl();
+
+  case PREDEF_DECL_NTH_ELEMENT_ID:
+return Context.getNthElementDecl();
   }
   llvm_unreachable("PredefinedDeclIDs unknown enum value");

Re: [PATCH] D15440: [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a

2015-12-10 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: cmake/config-ix.cmake:45
@@ -44,3 +44,3 @@
 check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
-check_library_exists(gcc_eh _Unwind_GetRegionStart "" LIBCXXABI_HAS_GCC_EH_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
 check_library_exists(c __cxa_thread_atexit_impl ""

Might be nice to extend this further to allow building against 
clang_rt.builtins.  We could of course do that as a follow up if you prefer.


Comment at: src/CMakeLists.txt:37
@@ +36,3 @@
+
+remove_flags(-Wl,-z,defs)
+

Do we need to worry about an alternative spelling of `-z defs`?


http://reviews.llvm.org/D15440



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15440: [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a

2015-12-10 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: cmake/config-ix.cmake:45
@@ -44,3 +44,3 @@
 check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
-check_library_exists(gcc_eh _Unwind_GetRegionStart "" LIBCXXABI_HAS_GCC_EH_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
 check_library_exists(c __cxa_thread_atexit_impl ""

compnerd wrote:
> Might be nice to extend this further to allow building against 
> clang_rt.builtins.  We could of course do that as a follow up if you prefer.
I don't think the clang_rt.builtin libraries are *ever* along the library 
search path. Maybe we could detect if clang accepts `--rtlib `? (I don't 
know the flag off hand).


Comment at: src/CMakeLists.txt:37
@@ +36,3 @@
+
+remove_flags(-Wl,-z,defs)
+

compnerd wrote:
> Do we need to worry about an alternative spelling of `-z defs`?
Not sure. I only considered the spellings used within the LLVM source tree 
`llvm/cmake/modules/HandleLLVMOptions.cmake`.


http://reviews.llvm.org/D15440



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13351: [Power PC] add soft float support for ppc32

2015-12-10 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Driver/Tools.cpp:1477
@@ +1476,3 @@
+  // If unspecified, choose the default based on the platform.
+  if (ABI == ppc::FloatABI::Invalid) {
+ABI = ppc::FloatABI::Hard;

hfinkel wrote:
> Don't need the { } here.
We don't seem to have a specific style guideline *mandating* the uses of braces 
around even single-line statements, but please don't *discourage* them.


http://reviews.llvm.org/D13351



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255328 - Driver: add multilibs for ARM EB

2015-12-10 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Dec 11 00:20:59 2015
New Revision: 255328

URL: http://llvm.org/viewvc/llvm-project?rev=255328=rev
Log:
Driver: add multilibs for ARM EB

This improves the coverage for the multilib directories used for ARM.  Also add
tests covering the internal triple (thumbv7-*).  The Juno board can be run in
this configuration.

Added:
cfe/trunk/test/Driver/Inputs/multilib_arm_linux_tree/
cfe/trunk/test/Driver/Inputs/multilib_arm_linux_tree/usr/
cfe/trunk/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/

cfe/trunk/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/arm-linux-gnueabi/

cfe/trunk/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/arm-linux-gnueabi/.keep
cfe/trunk/test/Driver/Inputs/multilib_armeb_linux_tree/
cfe/trunk/test/Driver/Inputs/multilib_armeb_linux_tree/usr/
cfe/trunk/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/

cfe/trunk/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi/

cfe/trunk/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi/.keep
cfe/trunk/test/Driver/Inputs/multilib_armebhf_linux_tree/
cfe/trunk/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/
cfe/trunk/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/

cfe/trunk/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf/

cfe/trunk/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
cfe/trunk/test/Driver/Inputs/multilib_armhf_linux_tree/
cfe/trunk/test/Driver/Inputs/multilib_armhf_linux_tree/usr/
cfe/trunk/test/Driver/Inputs/multilib_armhf_linux_tree/usr/include/

cfe/trunk/test/Driver/Inputs/multilib_armhf_linux_tree/usr/include/arm-linux-gnueabihf/

cfe/trunk/test/Driver/Inputs/multilib_armhf_linux_tree/usr/include/arm-linux-gnueabihf/.keep
cfe/trunk/test/Driver/arm-multilibs.c
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=255328=255327=255328=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Dec 11 00:20:59 2015
@@ -3954,6 +3954,10 @@ void Linux::AddClangSystemIncludeArgs(co
   "/usr/include/arm-linux-gnueabi"};
   const StringRef ARMHFMultiarchIncludeDirs[] = {
   "/usr/include/arm-linux-gnueabihf"};
+  const StringRef ARMEBMultiarchIncludeDirs[] = {
+  "/usr/include/armeb-linux-gnueabi"};
+  const StringRef ARMEBHFMultiarchIncludeDirs[] = {
+  "/usr/include/armeb-linux-gnueabihf"};
   const StringRef MIPSMultiarchIncludeDirs[] = {"/usr/include/mips-linux-gnu"};
   const StringRef MIPSELMultiarchIncludeDirs[] = {
   "/usr/include/mipsel-linux-gnu"};
@@ -3987,11 +3991,19 @@ void Linux::AddClangSystemIncludeArgs(co
 MultiarchIncludeDirs = AArch64MultiarchIncludeDirs;
 break;
   case llvm::Triple::arm:
+  case llvm::Triple::thumb:
 if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF)
   MultiarchIncludeDirs = ARMHFMultiarchIncludeDirs;
 else
   MultiarchIncludeDirs = ARMMultiarchIncludeDirs;
 break;
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumbeb:
+if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF)
+  MultiarchIncludeDirs = ARMEBHFMultiarchIncludeDirs;
+else
+  MultiarchIncludeDirs = ARMEBMultiarchIncludeDirs;
+break;
   case llvm::Triple::mips:
 MultiarchIncludeDirs = MIPSMultiarchIncludeDirs;
 break;

Added: 
cfe/trunk/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/arm-linux-gnueabi/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/arm-linux-gnueabi/.keep?rev=255328=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi/.keep?rev=255328=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf/.keep?rev=255328=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/multilib_armhf_linux_tree/usr/include/arm-linux-gnueabihf/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/multilib_armhf_linux_tree/usr/include/arm-linux-gnueabihf/.keep?rev=255328=auto

[PATCH] D15440: [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a

2015-12-10 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: danalbert, chandlerc, mclow.lists, compnerd, ismail.
EricWF added a subscriber: cfe-commits.

libgcc_eh.a cannot be used when building libc++abi as a shared library (the 
default configuration). See this post for some more discussion: 
https://gcc.gnu.org/ml/gcc/2012-03/msg00104.html

This patch reverts back to using libgcc_s when linking libc++abi.so. However 
gcc_s doesn't contain all of the symbols needed by libc++abi.so. The missing 
symbols will be resolved by libgcc.a when linking the final executable.



http://reviews.llvm.org/D15440

Files:
  cmake/config-ix.cmake
  src/CMakeLists.txt

Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -19,6 +19,23 @@
   typeinfo.cpp
 )
 
+
+# Remove a list of flags from all CMake variables that affect compile flags.
+# This can be used to remove unwanted flags specified on the command line
+# or added in other parts of LLVM's cmake configuration.
+macro(remove_flags)
+  foreach(var ${ARGN})
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS 
"${CMAKE_EXE_LINKER_FLAGS}")
+string(REPLACE "${var}" "" CMAKE_SHARED_LINKER_FLAGS 
"${CMAKE_SHARED_LINKER_FLAGS}")
+string(REPLACE "${var}" "" CMAKE_SHARED_MODULE_FLAGS 
"${CMAKE_SHARED_MODULE_FLAGS}")
+remove_definitions(${var})
+  endforeach()
+endmacro(remove_flags)
+
+remove_flags(-Wl,-z,defs)
+
 if (UNIX AND NOT (APPLE OR CYGWIN))
   list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp)
 endif()
@@ -40,17 +57,25 @@
   add_definitions(-DHAVE___CXA_THREAD_ATEXIT_IMPL)
 endif()
 
-# Generate library list.
+# Generate library list. When not using LLVM unwinder libgcc_s should be the
+# first and last library on the link line. This behavior mimics clang's
+# behavior.
 set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})
-append_if(libraries LIBCXXABI_HAS_C_LIB c)
+
+if (NOT LIBCXXABI_USE_LLVM_UNWINDER)
+  append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s)
+endif()
+
 if (LIBCXXABI_ENABLE_THREADS)
   append_if(libraries LIBCXXABI_HAS_PTHREAD_LIB pthread)
 endif()
 
+append_if(libraries LIBCXXABI_HAS_C_LIB c)
+
 if (LIBCXXABI_USE_LLVM_UNWINDER)
   list(APPEND libraries unwind)
 else()
-  append_if(libraries LIBCXXABI_HAS_GCC_EH_LIB gcc_eh)
+  append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -42,6 +42,6 @@
 check_library_exists(c fopen "" LIBCXXABI_HAS_C_LIB)
 check_library_exists(dl dladdr "" LIBCXXABI_HAS_DL_LIB)
 check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
-check_library_exists(gcc_eh _Unwind_GetRegionStart "" LIBCXXABI_HAS_GCC_EH_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
 check_library_exists(c __cxa_thread_atexit_impl ""
   LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -19,6 +19,23 @@
   typeinfo.cpp
 )
 
+
+# Remove a list of flags from all CMake variables that affect compile flags.
+# This can be used to remove unwanted flags specified on the command line
+# or added in other parts of LLVM's cmake configuration.
+macro(remove_flags)
+  foreach(var ${ARGN})
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
+string(REPLACE "${var}" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
+string(REPLACE "${var}" "" CMAKE_SHARED_MODULE_FLAGS "${CMAKE_SHARED_MODULE_FLAGS}")
+remove_definitions(${var})
+  endforeach()
+endmacro(remove_flags)
+
+remove_flags(-Wl,-z,defs)
+
 if (UNIX AND NOT (APPLE OR CYGWIN))
   list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp)
 endif()
@@ -40,17 +57,25 @@
   add_definitions(-DHAVE___CXA_THREAD_ATEXIT_IMPL)
 endif()
 
-# Generate library list.
+# Generate library list. When not using LLVM unwinder libgcc_s should be the
+# first and last library on the link line. This behavior mimics clang's
+# behavior.
 set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})
-append_if(libraries LIBCXXABI_HAS_C_LIB c)
+
+if (NOT LIBCXXABI_USE_LLVM_UNWINDER)
+  append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s)
+endif()
+
 if (LIBCXXABI_ENABLE_THREADS)
   append_if(libraries LIBCXXABI_HAS_PTHREAD_LIB pthread)
 endif()
 
+append_if(libraries LIBCXXABI_HAS_C_LIB c)
+
 if (LIBCXXABI_USE_LLVM_UNWINDER)
   list(APPEND libraries unwind)
 else()
-  append_if(libraries LIBCXXABI_HAS_GCC_EH_LIB gcc_eh)
+  append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup 

[PATCH] D15441: [libc++] Use libgcc_s and libgcc instead of libgcc_eh when running the libc++ tests

2015-12-10 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: danalbert, jroelofs, chandlerc.
EricWF added a subscriber: cfe-commits.
EricWF added a dependency: D15440: [libc++abi] Use libgcc and libgcc_s to 
provide _Unwind symbols instead of libgcc_eh.a.

This change depends on D15440.

http://reviews.llvm.org/D15441

Files:
  test/libcxx/test/config.py

Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -572,15 +572,16 @@
 if target_platform == 'darwin':
 self.cxx.link_flags += ['-lSystem']
 elif target_platform == 'linux':
+self.cxx.link_flags += ['-lm']
 if not llvm_unwinder:
-self.cxx.link_flags += ['-lgcc_eh']
-self.cxx.link_flags += ['-lc', '-lm']
+self.cxx.link_flags += ['-lgcc_s', '-lgcc']
 if enable_threads:
 self.cxx.link_flags += ['-lpthread']
+self.cxx.link_flags += ['-lc']
 if llvm_unwinder:
 self.cxx.link_flags += ['-lunwind', '-ldl']
 else:
-self.cxx.link_flags += ['-lgcc_s']
+self.cxx.link_flags += ['-lgcc_s', '-lgcc']
 elif target_platform.startswith('freebsd'):
 self.cxx.link_flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', 
'-lcxxrt']
 else:


Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -572,15 +572,16 @@
 if target_platform == 'darwin':
 self.cxx.link_flags += ['-lSystem']
 elif target_platform == 'linux':
+self.cxx.link_flags += ['-lm']
 if not llvm_unwinder:
-self.cxx.link_flags += ['-lgcc_eh']
-self.cxx.link_flags += ['-lc', '-lm']
+self.cxx.link_flags += ['-lgcc_s', '-lgcc']
 if enable_threads:
 self.cxx.link_flags += ['-lpthread']
+self.cxx.link_flags += ['-lc']
 if llvm_unwinder:
 self.cxx.link_flags += ['-lunwind', '-ldl']
 else:
-self.cxx.link_flags += ['-lgcc_s']
+self.cxx.link_flags += ['-lgcc_s', '-lgcc']
 elif target_platform.startswith('freebsd'):
 self.cxx.link_flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lcxxrt']
 else:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15195: PR4941: Add support for -fno-builtin-foo options.

2015-12-10 Thread hfin...@anl.gov via cfe-commits
hfinkel added a subscriber: hfinkel.
hfinkel added a comment.

Can you use a StringSet instead of a vector and avoid all (most) of the code 
iterating over the vector of builtins being disabled?



Comment at: lib/Frontend/CompilerInvocation.cpp:147
@@ +146,3 @@
+Values.push_back(FuncName);
+  // FIXME: We could warn about invalid/unsupported -fno-builtin-*.
+}

I'd remove this; there's no need for Clang to know about all functions that the 
optimizer knows about, and thus for which adding the nobuiltin attribute might 
be useful.


http://reviews.llvm.org/D15195



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 42427.
xazax.hun marked 5 inline comments as done.
xazax.hun added a comment.

- Modified the patch according to the review.


http://reviews.llvm.org/D15411

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringIntegerAssignmentCheck.cpp
  clang-tidy/misc/StringIntegerAssignmentCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-integer-assignment.rst
  test/clang-tidy/misc-string-integer-assignment.cpp

Index: test/clang-tidy/misc-string-integer-assignment.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-integer-assignment.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s misc-string-integer-assignment %t
+
+namespace std {
+template
+struct basic_string {
+  basic_string(const T*) {}
+  basic_string& operator=(T) {
+return *this;
+  }
+  basic_string& operator=(basic_string) {
+return *this;
+  }
+  basic_string& operator+=(T) {
+return *this;
+  }
+  basic_string& operator+=(basic_string) {
+return *this;
+  }
+};
+
+typedef basic_string string;
+}
+
+int main() {
+  std::string s("foobar");
+
+  s = 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: probably missing to_string operation [misc-string-integer-assignment]
+// CHECK-FIXES: {{^}}  s = std::to_string(6);{{$}}
+  s = 'c';
+  s = (char)6;
+
+// +=
+  s += 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: probably missing to_string operation [misc-string-integer-assignment]
+// CHECK-FIXES: {{^}}  s += std::to_string(6);{{$}}
+  s += 'c';
+  s += (char)6;
+}
Index: docs/clang-tidy/checks/misc-string-integer-assignment.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-integer-assignment.rst
@@ -0,0 +1,30 @@
+misc-string-integer-assignment
+==
+
+The ``std::basic_string`` has an assignment operator with the following signature:
+
+.. code:: c++
+  basic_string& operator=( CharT ch );
+
+The source of the problem is that, the numeric types can be implicity casted to most of the
+character types. It possible to assign integers to ``basic_string``.
+
+.. code:: c++
+  std::string s;
+  int x = 5965;
+  s = 6;
+  s = x;
+
+Use the appropriate conversion functions or character literals.
+
+.. code:: c++
+  std::string s;
+  int x = 5965;
+  s = '6';
+  s = std::to_string(x);
+
+In order to suppress false positives, use an explicit cast.
+
+.. code:: c++
+  std::string s;
+  s = static_cast(6);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -47,6 +47,7 @@
misc-non-copyable-objects
misc-sizeof-container
misc-static-assert
+   misc-string-integer-assignment
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
misc-undelegated-constructor
Index: clang-tidy/misc/StringIntegerAssignmentCheck.h
===
--- /dev/null
+++ clang-tidy/misc/StringIntegerAssignmentCheck.h
@@ -0,0 +1,34 @@
+//===--- StringIntegerAssignmentCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_INTEGER_ASSIGNMENT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_INTEGER_ASSIGNMENT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Finds instances where integer is assigned to a string.
+///
+/// For more details see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-string-assignment.html
+class StringIntegerAssignmentCheck : public ClangTidyCheck {
+public:
+  StringIntegerAssignmentCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_INTEGER_ASSIGNMENT_H
+
Index: clang-tidy/misc/StringIntegerAssignmentCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/StringIntegerAssignmentCheck.cpp
@@ -0,0 +1,57 @@
+//===--- StringIntegerAssignmentCheck.cpp - clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 

Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-10 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Thank you for the review. I have seen a few false positives in the llvm 
codebase. I agree that these kind of conversions are unfortunate but I am sure 
fixing this would cause a huge backward compatibility problem. Nontheless I 
also think that it might be something that is worth to consider.


http://reviews.llvm.org/D15411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14839: [libcxx] LWG2485: get() should be overloaded for const tuple&

2015-12-10 Thread Agustín Bergé via cfe-commits
K-ballo marked 2 inline comments as done.
K-ballo added a comment.

In http://reviews.llvm.org/D14839#306306, @EricWF wrote:

>   int x = 42;
>   int const y = 43;
>   std::pair const p(x, y);
>   static_assert(std::is_same decltype(std::get<0>(std::move(p)))>::value, "");
>   static_assert(std::is_same decltype(std::get<1>(std::move(p)))>::value, "");
>   
>
> I assume you agree that this test has the correct behavior?


I believe the first `static_assert` is incorrect, `const` is shallow so it 
should be just `int&`.


http://reviews.llvm.org/D14839



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15370: [scan-view] replace deprecated optparse with argparse

2015-12-10 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

Looks reasonable to me from a "I haven't actually tried it with this patch" 
perspective.


http://reviews.llvm.org/D15370



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2015-12-10 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked an inline comment as done.
danielmarjamaki added a comment.

I have looked all warnings that I got. 1678 projects where scanned. In total I 
got 124 warnings.

I classified 91 warnings as TP. 14 as FP. and then there were 19 that I failed 
to triage. I for instance failed to triage code implemented in headers when I 
don't know what values function arguments will have.

My feeling for the 14 FP is that the value analysis fails and then there is not 
much my checker could do.

I don't see any particular use case that my checker should handle better.

For information, here are the packages I got warnings in:
ftp://ftp.se.debian.org/debian/pool/main/a/abcm2ps/abcm2ps_7.8.9.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/a/abcmidi/abcmidi_20151110.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/a/acm/acm_5.0.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/a/aewan/aewan_1.0.01.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/a/ap-utils/ap-utils_1.5.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/a/aspell/aspell_0.60.7~20110707.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/a/audiofile/audiofile_0.3.6.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/b/bash/bash_4.3.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/b/binutils-h8300-hms/binutils-h8300-hms_2.16.1.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/b/bison++/bison++_1.21.11.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/b/brltty/brltty_5.2~20141018.orig.tar.xz
ftp://ftp.se.debian.org/debian/pool/main/b/bvi/bvi_1.4.0.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/c/cmus/cmus_2.7.1.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/c/cone/cone_0.89.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/c/cscope/cscope_15.8b.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/d/dash/dash_0.5.8.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/d/directfb/directfb_1.4.3.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/e/elk/elk_3.99.8.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/e/erlang/erlang_18.1-dfsg.orig.tar.xz
ftp://ftp.se.debian.org/debian/pool/main/f/findutils/findutils_4.5.14.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/f/fish/fish_2.2.0.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/f/fltk1.1/fltk1.1_1.1.10.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/f/fltk1.3/fltk1.3_1.3.3.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/f/fontforge/fontforge_20120731.b.orig.tar.bz2
ftp://ftp.se.debian.org/debian/pool/main/f/fox1.6/fox1.6_1.6.50.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/f/freewnn/freewnn_1.1.1~a021+cvs20130302.orig.tar.xz
ftp://ftp.se.debian.org/debian/pool/main/f/frei0r/frei0r_1.4.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/f/ftnchek/ftnchek_3.3.1.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/g/gnupg/gnupg_1.4.19.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/g/gxemul/gxemul_0.4.7.2.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/h/haildb/haildb_2.3.2.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/h/hercules/hercules_3.11.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/i/ion/ion_3.2.1+dfsg.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/l/lame/lame_3.99.5+repack1.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/l/loop-aes-utils/loop-aes-utils_2.16.2.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/m/m17n-lib/m17n-lib_1.7.0.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/m/mbr/mbr_1.1.11.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/m/mcpp/mcpp_2.7.2.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/m/mtools/mtools_4.0.18.orig.tar.bz2
ftp://ftp.se.debian.org/debian/pool/main/m/musl/musl_1.1.9.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/n/nasm/nasm_2.11.06-1really2.11.05.orig.tar.xz
ftp://ftp.se.debian.org/debian/pool/main/n/netkit-ftp/netkit-ftp_0.17.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/n/nmap/nmap_7.00.orig.tar.bz2
ftp://ftp.se.debian.org/debian/pool/main/o/openct/openct_0.6.20.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/o/owl/owl_2.2.2.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/p/paperkey/paperkey_1.3.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/p/pnm2ppa/pnm2ppa_1.13.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/p/procps/procps_3.3.9.orig.tar.xz
ftp://ftp.se.debian.org/debian/pool/main/p/protobuf/protobuf_2.6.1.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/p/proxycheck/proxycheck_0.49a.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/p/putty/putty_0.66.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/r/rds-tools/rds-tools_1.4.1-OFED-1.4.2.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.7.358.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/s/sam2p/sam2p_0.49.2.orig.tar.gz
ftp://ftp.se.debian.org/debian/pool/main/s/sane-backends/sane-backends_1.0.26~git20151121.orig.tar.gz

Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2015-12-10 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

> I classified 91 warnings as TP. 14 as FP. and then there were 19 that I 
> failed to triage. I for instance failed to triage code implemented in headers 
> when I don't know what values function arguments will have.


Sorry I calculated wrong.

I classified 91 warnings as TP. 14 as FP.

Then that means there were 9 warnings that I failed to triage.


http://reviews.llvm.org/D13126



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits