r339039 - [NFC] Remove TODO comment that no longer applies (ParsedAttr)

2018-08-06 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Aug  6 11:11:48 2018
New Revision: 339039

URL: http://llvm.org/viewvc/llvm-project?rev=339039&view=rev
Log:
[NFC] Remove TODO comment that no longer applies (ParsedAttr)

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339039&r1=339038&r2=339039&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Mon Aug  6 11:11:48 2018
@@ -102,7 +102,7 @@ using ArgsVector = llvm::SmallVectorhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339344 - Implement diagnostic stream operator for ParsedAttr.

2018-08-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Aug  9 06:21:32 2018
New Revision: 339344

URL: http://llvm.org/viewvc/llvm-project?rev=339344&view=rev
Log:
Implement diagnostic stream operator for ParsedAttr.

As a part of attempting to clean up the way attributes are 
printed, this patch adds an operator << to the diagnostics/
partialdiagnostics so that ParsedAttr can be sent directly.

This patch also rewrites a large amount* of the times when
ParsedAttr was printed using its IdentifierInfo object instead
of being printed itself.  
*"a large amount" == "All I could find".

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaStmtAttr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339344&r1=339343&r2=339344&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug  9 06:21:32 2018
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_SEMA_ATTRIBUTELIST_H
 
 #include "clang/Basic/AttrSubjectMatchRules.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Sema/Ownership.h"
@@ -939,6 +940,34 @@ enum AttributeDeclKind {
   ExpectedFunctionWithProtoType,
 };
 
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+   const ParsedAttr &At) {
+  DB.AddTaggedVal(reinterpret_cast(At.getName()),
+  DiagnosticsEngine::ak_identifierinfo);
+  return DB;
+}
+
+inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
+   const ParsedAttr &At) {
+  PD.AddTaggedVal(reinterpret_cast(At.getName()),
+  DiagnosticsEngine::ak_identifierinfo);
+  return PD;
+}
+
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+   const ParsedAttr *At) {
+  DB.AddTaggedVal(reinterpret_cast(At->getName()),
+  DiagnosticsEngine::ak_identifierinfo);
+  return DB;
+}
+
+inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
+   const ParsedAttr *At) {
+  PD.AddTaggedVal(reinterpret_cast(At->getName()),
+  DiagnosticsEngine::ak_identifierinfo);
+  return PD;
+}
+
 } // namespace clang
 
 #endif // LLVM_CLANG_SEMA_ATTRIBUTELIST_H

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=339344&r1=339343&r2=339344&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Aug  9 06:21:32 2018
@@ -2456,11 +2456,11 @@ public:
 unsigned AttrSpellingListIndex);
   OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, SourceRange Range,
   unsigned AttrSpellingListIndex);
-  InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, SourceRange Range,
-IdentifierInfo *Ident,
-unsigned 
AttrSpellingListIndex);
-  CommonAttr *mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo 
*Ident,
-  unsigned AttrSpellingListIndex);
+  InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
+  InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
+const InternalLinkageAttr &AL);
+  CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL);
+  CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL);
 
   void mergeDeclAttributes(NamedDecl *New, Decl *Old,
AvailabilityMergeKind AMK = AMK_Redeclaration);

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=339344&r1=339343&r2=339344&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug  9 06:21:32 2018
@@ -2474,14 +2474,9 @@ static bool mergeDeclAttribute(Sema &S,
   else if (const auto *OA = dyn_cast(Attr))
 NewAttr = S.mergeOptimizeNoneAttr(D, OA->getRange(), 
AttrSpellingListIndex);
   else if (const auto *InternalLinkageA = dyn_cast(Attr))
-NewAttr = S.mergeInternalLinkageAttr(
-D, InternalLinkageA->getRange(),
-&S.Context.Idents.get(InternalLinkageA->getSpelling()),
-AttrSpellingListIndex);
+NewAttr = S.mer

r339380 - [NFC] Convert ParsedAttr to use llvm::TrailingObjects

2018-08-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Aug  9 13:25:12 2018
New Revision: 339380

URL: http://llvm.org/viewvc/llvm-project?rev=339380&view=rev
Log:
[NFC] Convert ParsedAttr to use llvm::TrailingObjects

ParsedAttr is using a hand-rolled trailing-objects
implementation that gets cleaned up quite a bit by
just using llvm::TrailingObjects. This is a large
TrailingObjects list, but most things are length '0'.

Differential Revision: https://reviews.llvm.org/D50531

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h
cfe/trunk/lib/Sema/ParsedAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339380&r1=339379&r2=339380&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug  9 13:25:12 2018
@@ -55,8 +55,7 @@ struct AvailabilityChange {
   bool isValid() const { return !Version.empty(); }
 };
 
-namespace {
-
+namespace detail {
 enum AvailabilitySlot {
   IntroducedSlot, DeprecatedSlot, ObsoletedSlot, NumAvailabilitySlots
 };
@@ -78,6 +77,18 @@ struct AvailabilityData {
   }
 };
 
+struct TypeTagForDatatypeData {
+  ParsedType *MatchingCType;
+  unsigned LayoutCompatible : 1;
+  unsigned MustBeNull : 1;
+};
+struct PropertyData {
+  IdentifierInfo *GetterId, *SetterId;
+
+  PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId)
+  : GetterId(getterId), SetterId(setterId) {}
+};
+
 } // namespace
 
 /// Wraps an identifier and optional source location for the identifier.
@@ -103,7 +114,29 @@ using ArgsVector = llvm::SmallVector {
+  friend class llvm::TrailingObjects<
+  ParsedAttr, ArgsUnion, detail::AvailabilityData,
+  detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData>;
+
+  size_t numTrailingObjects(OverloadToken) const { return NumArgs; }
+  size_t numTrailingObjects(OverloadToken) const {
+return IsAvailability;
+  }
+  size_t
+  numTrailingObjects(OverloadToken) const {
+return IsTypeTagForDatatype;
+  }
+  size_t numTrailingObjects(OverloadToken) const {
+return HasParsedType;
+  }
+  size_t numTrailingObjects(OverloadToken) const {
+return IsProperty;
+  }
+
 public:
   /// The style used to specify an attribute.
   enum Syntax {
@@ -183,34 +216,18 @@ private:
 
   const Expr *MessageExpr;
 
-  /// Arguments, if any, are stored immediately following the object.
-  ArgsUnion *getArgsBuffer() { return reinterpret_cast(this + 1); 
}
+  ArgsUnion *getArgsBuffer() { return getTrailingObjects(); }
   ArgsUnion const *getArgsBuffer() const {
-return reinterpret_cast(this + 1);
+return getTrailingObjects();
   }
 
-  /// Availability information is stored immediately following the arguments,
-  /// if any, at the end of the object.
-  AvailabilityData *getAvailabilityData() {
-return reinterpret_cast(getArgsBuffer() + NumArgs);
+  detail::AvailabilityData *getAvailabilityData() {
+return getTrailingObjects();
   }
-  const AvailabilityData *getAvailabilityData() const {
-return reinterpret_cast(getArgsBuffer() + 
NumArgs);
+  const detail::AvailabilityData *getAvailabilityData() const {
+return getTrailingObjects();
   }
 
-public:
-  struct TypeTagForDatatypeData {
-ParsedType *MatchingCType;
-unsigned LayoutCompatible : 1;
-unsigned MustBeNull : 1;
-  };
-  struct PropertyData {
-IdentifierInfo *GetterId, *SetterId;
-
-PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId)
-: GetterId(getterId), SetterId(setterId) {}
-  };
-
 private:
   friend class AttributeFactory;
   friend class AttributePool;
@@ -245,7 +262,7 @@ private:
 MessageExpr(messageExpr) {
 ArgsUnion PVal(Parm);
 memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
-new (getAvailabilityData()) AvailabilityData(
+new (getAvailabilityData()) detail::AvailabilityData(
 introduced, deprecated, obsoleted, strict, replacementExpr);
 AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
   }
@@ -279,7 +296,7 @@ private:
 HasProcessingCache(false) {
 ArgsUnion PVal(ArgKind);
 memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
-TypeTagForDatatypeData &ExtraData = getTypeTagForDatatypeDataSlot();
+detail::TypeTagForDatatypeData &ExtraData = 
getTypeTagForDatatypeDataSlot();
 new (&ExtraData.MatchingCType) ParsedType(matchingCType);
 ExtraData.LayoutCompatible = layoutCompatible;
 ExtraData.MustBeNull = mustBeNull;
@@ -309,39 +326,36 @@ private:
 UsedAsTypeAttr(false), IsAvailability(false),
 IsTypeTagForDatatype(false), IsProperty(true), HasParsedType(false),
 HasProcessingCache(false) {
-new (&getPropertyDataBuffer()) PropertyData(getterId, setterId);
+new (&getPropertyDataBuffer()) detail::PropertyData(getterId, setterId);
 AttrKind = getKind(getName(),

r339382 - [NFC] Simplify 'friend' declaration in ParsedAttr

2018-08-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Aug  9 14:03:39 2018
New Revision: 339382

URL: http://llvm.org/viewvc/llvm-project?rev=339382&view=rev
Log:
[NFC] Simplify 'friend' declaration in ParsedAttr

As suggested in the post-commit review for D50531,
change from the templatized TrailingObjects friend declaration
to a version referring to the base.

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339382&r1=339381&r2=339382&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug  9 14:03:39 2018
@@ -118,9 +118,7 @@ class ParsedAttr final
 : private llvm::TrailingObjects<
   ParsedAttr, ArgsUnion, detail::AvailabilityData,
   detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> {
-  friend class llvm::TrailingObjects<
-  ParsedAttr, ArgsUnion, detail::AvailabilityData,
-  detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData>;
+  friend class TrailingObjects;
 
   size_t numTrailingObjects(OverloadToken) const { return NumArgs; }
   size_t numTrailingObjects(OverloadToken) const {


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


r339383 - [NFC] Complete the rule-of-5 for ParsedAttr

2018-08-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Aug  9 14:04:34 2018
New Revision: 339383

URL: http://llvm.org/viewvc/llvm-project?rev=339383&view=rev
Log:
[NFC] Complete the rule-of-5 for ParsedAttr

Add move assign/construct as 'deleted' to ParsedAttr
to complete the rule-of-5.

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339383&r1=339382&r2=339383&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug  9 14:04:34 2018
@@ -360,7 +360,9 @@ private:
 
 public:
   ParsedAttr(const ParsedAttr &) = delete;
+  ParsedAttr(ParsedAttr &&) = delete;
   ParsedAttr &operator=(const ParsedAttr &) = delete;
+  ParsedAttr &operator=(ParsedAttr &&) = delete;
   ~ParsedAttr() = delete;
 
   void operator delete(void *) = delete;


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


r339387 - Revert -r339382, which apparently breaks the Windows build.

2018-08-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Aug  9 14:13:46 2018
New Revision: 339387

URL: http://llvm.org/viewvc/llvm-project?rev=339387&view=rev
Log:
Revert -r339382, which apparently breaks the Windows build.

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339387&r1=339386&r2=339387&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug  9 14:13:46 2018
@@ -118,7 +118,9 @@ class ParsedAttr final
 : private llvm::TrailingObjects<
   ParsedAttr, ArgsUnion, detail::AvailabilityData,
   detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> {
-  friend class TrailingObjects;
+  friend class llvm::TrailingObjects<
+  ParsedAttr, ArgsUnion, detail::AvailabilityData,
+  detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData>;
 
   size_t numTrailingObjects(OverloadToken) const { return NumArgs; }
   size_t numTrailingObjects(OverloadToken) const {


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


r339389 - Fix and recommit r339382 based on solution from RSmith:

2018-08-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Aug  9 14:18:13 2018
New Revision: 339389

URL: http://llvm.org/viewvc/llvm-project?rev=339389&view=rev
Log:
Fix and recommit r339382 based on solution from RSmith:

As sent on cfe-commits:
 "You need to use "friend TrailingObjects;" here, not 
 "friend class TrailingObjects;", to avoid breaking MSVC 
 (which doesn't implement injected-class-names quite according to spec)."

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339389&r1=339388&r2=339389&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug  9 14:18:13 2018
@@ -118,9 +118,7 @@ class ParsedAttr final
 : private llvm::TrailingObjects<
   ParsedAttr, ArgsUnion, detail::AvailabilityData,
   detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> {
-  friend class llvm::TrailingObjects<
-  ParsedAttr, ArgsUnion, detail::AvailabilityData,
-  detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData>;
+  friend TrailingObjects;
 
   size_t numTrailingObjects(OverloadToken) const { return NumArgs; }
   size_t numTrailingObjects(OverloadToken) const {


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


r339597 - Enforce instantiation of template multiversion functions

2018-08-13 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Aug 13 11:33:20 2018
New Revision: 339597

URL: http://llvm.org/viewvc/llvm-project?rev=339597&view=rev
Log:
Enforce instantiation of template multiversion functions

Multiversioned member functions inside of a template type were 
not properly being emitted.  The solution to this is to simply 
ensure that their bodies are correctly evaluated/assigned during
template instantiation.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-member-funcs.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=339597&r1=339596&r2=339597&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Aug 13 11:33:20 2018
@@ -2743,7 +2743,7 @@ public:
   /// predicate.
   void forEachMultiversionedFunctionVersion(
   const FunctionDecl *FD,
-  llvm::function_ref Pred) const;
+  llvm::function_ref Pred) const;
 
   const CXXConstructorDecl *
   getCopyConstructorForExceptionObject(CXXRecordDecl *RD);

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=339597&r1=339596&r2=339597&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Aug 13 11:33:20 2018
@@ -9819,7 +9819,7 @@ bool ASTContext::DeclMustBeEmitted(const
 
 void ASTContext::forEachMultiversionedFunctionVersion(
 const FunctionDecl *FD,
-llvm::function_ref Pred) const {
+llvm::function_ref Pred) const {
   assert(FD->isMultiVersion() && "Only valid for multiversioned functions");
   llvm::SmallDenseSet SeenDecls;
   FD = FD->getCanonicalDecl();

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=339597&r1=339596&r2=339597&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Aug 13 11:33:20 2018
@@ -5175,10 +5175,20 @@ void Sema::PerformPendingInstantiations(
 if (FunctionDecl *Function = dyn_cast(Inst.first)) {
   bool DefinitionRequired = Function->getTemplateSpecializationKind() ==
 TSK_ExplicitInstantiationDefinition;
-  InstantiateFunctionDefinition(/*FIXME:*/Inst.second, Function, true,
-DefinitionRequired, true);
-  if (Function->isDefined())
-Function->setInstantiationIsPending(false);
+  if (Function->isMultiVersion()) {
+getASTContext().forEachMultiversionedFunctionVersion(
+Function, [this, Inst, DefinitionRequired](FunctionDecl *CurFD) {
+  InstantiateFunctionDefinition(/*FIXME:*/ Inst.second, CurFD, 
true,
+DefinitionRequired, true);
+  if (CurFD->isDefined())
+CurFD->setInstantiationIsPending(false);
+});
+  } else {
+InstantiateFunctionDefinition(/*FIXME:*/ Inst.second, Function, true,
+  DefinitionRequired, true);
+if (Function->isDefined())
+  Function->setInstantiationIsPending(false);
+  }
   continue;
 }
 

Modified: cfe/trunk/test/CodeGenCXX/attr-target-mv-member-funcs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-target-mv-member-funcs.cpp?rev=339597&r1=339596&r2=339597&view=diff
==
--- cfe/trunk/test/CodeGenCXX/attr-target-mv-member-funcs.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/attr-target-mv-member-funcs.cpp Mon Aug 13 
11:33:20 2018
@@ -111,13 +111,12 @@ int templ_use() {
 // CHECK:  call i32 @_ZN5templIiE3fooEi.ifunc
 // CHECK:  call i32 @_ZN5templIdE3fooEi.ifunc
 
-
 // CHECK: define i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.resolver() 
comdat
 // CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.arch_sandybridge
 // CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.arch_ivybridge
 // CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.sse4.2
 // CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi
-//
+
 // CHECK: define i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.resolver() 
comdat
 // CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.arch_sandybridge
 // CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.arch_ivybridge
@@ -135,3 +134,12 @@ int templ_use() {
 // CHECK: define linkonce_odr i32 @_ZN1S3fooEi(%struct.S* %this, i32)
 /

r340025 - Fix for bug 38508 - Don't do PCH processing when only generating preprocessor output

2018-08-17 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Aug 17 06:43:39 2018
New Revision: 340025

URL: http://llvm.org/viewvc/llvm-project?rev=340025&view=rev
Log:
Fix for bug 38508 - Don't do PCH processing when only generating preprocessor 
output

This clang-cl driver change removes the PCH options when we are only generating
preprocessed output. This is similar to the behavior of Y-.

Patch by: mikerice
Differential Revision: https://reviews.llvm.org/D50640

Added:
cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp
cfe/trunk/test/PCH/Inputs/pch-through3c.h
cfe/trunk/test/PCH/pch-through3c.cpp
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-pch.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=340025&r1=340024&r2=340025&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Aug 17 06:43:39 2018
@@ -3010,9 +3010,10 @@ void Driver::BuildActions(Compilation &C
 Args.eraseArg(options::OPT__SLASH_Yc);
 YcArg = nullptr;
   }
-  if (Args.hasArg(options::OPT__SLASH_Y_)) {
-// /Y- disables all pch handling.  Rather than check for it everywhere,
-// just remove clang-cl pch-related flags here.
+  if (FinalPhase == phases::Preprocess || Args.hasArg(options::OPT__SLASH_Y_)) 
{
+// If only preprocessing or /Y- is used, all pch handling is disabled.
+// Rather than check for it everywhere, just remove clang-cl pch-related
+// flags here.
 Args.eraseArg(options::OPT__SLASH_Fp);
 Args.eraseArg(options::OPT__SLASH_Yc);
 Args.eraseArg(options::OPT__SLASH_Yu);

Modified: cfe/trunk/test/Driver/cl-pch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.cpp?rev=340025&r1=340024&r2=340025&view=diff
==
--- cfe/trunk/test/Driver/cl-pch.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch.cpp Fri Aug 17 06:43:39 2018
@@ -345,3 +345,24 @@
 // CHECK-NoSourceTP: pchfile.pch
 // CHECK-NoSourceTP: -x
 // CHECK-NoSourceTP: "c++"
+
+// If only preprocessing, PCH options are ignored.
+// RUN: %clang_cl /P /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-P %s
+// CHECK-YC-P-NOT: -emit-pch
+// CHECK-YC-P-NOT: -include-pch
+
+// RUN: %clang_cl /E /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-E %s
+// CHECK-YC-E-NOT: -emit-pch
+// CHECK-YC-E-NOT: -include-pch
+
+// RUN: %clang_cl /P /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YU-P %s
+// CHECK-YU-P-NOT: -emit-pch
+// CHECK-YU-P-NOT: -include-pch
+
+// RUN: %clang_cl /E /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YU-E %s
+// CHECK-YU-E-NOT: -emit-pch
+// CHECK-YU-E-NOT: -include-pch

Added: cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp?rev=340025&view=auto
==
--- cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp (added)
+++ cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp Fri Aug 17 06:43:39 2018
@@ -0,0 +1,2 @@
+int a = A;
+// expected-no-diagnostics

Added: cfe/trunk/test/PCH/Inputs/pch-through3c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through3c.h?rev=340025&view=auto
==
--- cfe/trunk/test/PCH/Inputs/pch-through3c.h (added)
+++ cfe/trunk/test/PCH/Inputs/pch-through3c.h Fri Aug 17 06:43:39 2018
@@ -0,0 +1 @@
+#define A 1

Added: cfe/trunk/test/PCH/pch-through3c.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pch-through3c.cpp?rev=340025&view=auto
==
--- cfe/trunk/test/PCH/pch-through3c.cpp (added)
+++ cfe/trunk/test/PCH/pch-through3c.cpp Fri Aug 17 06:43:39 2018
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -I %S -emit-pch \
+// RUN:   -include Inputs/pch-through3c.h \
+// RUN:   -pch-through-header=Inputs/pch-through3c.h -o %t.3c %s
+
+// RUN: %clang_cc1 -verify -I %S -include-pch %t.3c \
+// RUN:   -include Inputs/pch-through3c.h \
+// RUN:   -pch-through-header=Inputs/pch-through3c.h \
+// RUN:   %S/Inputs/pch-through-use3c.cpp 2>&1


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


r331812 - Fix float->int conversion warnings when near barriers.

2018-05-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue May  8 14:26:21 2018
New Revision: 331812

URL: http://llvm.org/viewvc/llvm-project?rev=331812&view=rev
Log:
Fix float->int conversion warnings when near barriers.

As Eli brought up here: https://reviews.llvm.org/D46535
I'd previously messed up this fix by missing conversions
that are just slightly outside the range.  This patch fixes
this by no longer ignoring the return value of 
convertToInteger.  Additionally, one of the error messages
wasn't very sensical (mentioning out of range value, when it 
really was not), so it was cleaned up as well.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=331812&r1=331811&r2=331812&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May  8 14:26:21 
2018
@@ -3148,8 +3148,7 @@ def warn_impcast_float_integer : Warning
   InGroup, DefaultIgnore;
 
 def warn_impcast_float_to_integer : Warning<
-  "implicit conversion of out of range value from %0 to %1 changes value "
-  "from %2 to %3">,
+  "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_out_of_range : Warning<
   "implicit conversion of out of range value from %0 to %1 is undefined">,

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=331812&r1=331811&r2=331812&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue May  8 14:26:21 2018
@@ -9419,26 +9419,25 @@ static void DiagnoseFloatingImpCast(Sema
 
   llvm::APSInt IntegerValue(S.Context.getIntWidth(T),
 T->hasUnsignedIntegerRepresentation());
-  if (Value.convertToInteger(IntegerValue, llvm::APFloat::rmTowardZero,
- &isExact) == llvm::APFloat::opOK &&
-  isExact) {
+  llvm::APFloat::opStatus Result = Value.convertToInteger(
+  IntegerValue, llvm::APFloat::rmTowardZero, &isExact);
+
+  if (Result == llvm::APFloat::opOK && isExact) {
 if (IsLiteral) return;
 return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer,
PruneWarnings);
   }
 
+  // Conversion of a floating-point value to a non-bool integer where the
+  // integral part cannot be represented by the integer type is undefined.
+  if (!IsBool && Result == llvm::APFloat::opInvalidOp)
+return DiagnoseImpCast(
+S, E, T, CContext,
+IsLiteral ? diag::warn_impcast_literal_float_to_integer_out_of_range
+  : diag::warn_impcast_float_to_integer_out_of_range);
+
   unsigned DiagID = 0;
   if (IsLiteral) {
-// Conversion of a floating-point value to a non-bool integer where the
-// integral part cannot be represented by the integer type is undefined.
-if (!IsBool &&
-((IntegerValue.isSigned() && (IntegerValue.isMaxSignedValue() ||
-  IntegerValue.isMinSignedValue())) ||
- (IntegerValue.isUnsigned() &&
-  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()
-  return DiagnoseImpCast(
-  S, E, T, CContext,
-  diag::warn_impcast_literal_float_to_integer_out_of_range);
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9454,19 +9453,12 @@ static void DiagnoseFloatingImpCast(Sema
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, 
PruneWarnings);
   }
-  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
-return DiagnoseImpCast(S, E, T, CContext,
-   
diag::warn_impcast_float_to_integer_out_of_range,
-   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, 
PruneWarnings);
   }
-  return DiagnoseImpCast(S, E, T, CContext,
- diag::warn_impcast_float_to_integer_out_of_range,
- PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;

Modified: cfe/trunk/test/Sema

r332470 - Add support for __declspec(code_seg("segname"))

2018-05-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed May 16 06:57:17 2018
New Revision: 332470

URL: http://llvm.org/viewvc/llvm-project?rev=332470&view=rev
Log:
Add support for __declspec(code_seg("segname"))

Add support for __declspec(code_seg("segname"))

This patch is built on the existing support for #pragma code_seg. The code_seg
declspec is allowed on functions and classes. The attribute enables the
placement of code into separate named segments, including compiler-generated
members and template instantiations.

For more information, please see the following:
https://msdn.microsoft.com/en-us/library/dn636922.aspx

A new CodeSeg attribute is used instead of adding a new spelling to the existing
Section attribute since they don’t apply to the same Subjects. Section
attributes are also added for the code_seg declspec since they are used for
#pragma code_seg. No CodeSeg attributes are added to the AST.

The patch is written to match with the Microsoft compiler’s behavior even where
that behavior is a little complicated (see https://reviews.llvm.org/D22931, the
Microsoft feedback page is no longer available since MS has removed the page).
That code is in getImplicitSectionAttrFromClass routine.

Diagnostics messages are added to match with the Microsoft compiler for code-seg
attribute mismatches on base and derived classes and virtual overrides.


Differential Revision: https://reviews.llvm.org/D43352

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=332470&r1=332469&r2=332470&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 16 06:57:17 2018
@@ -1769,6 +1769,13 @@ def Section : InheritableAttr {
   let Documentation = [SectionDocs];
 }
 
+def CodeSeg : InheritableAttr {
+  let Spellings = [Declspec<"code_seg">];
+  let Args = [StringArgument<"Name">];
+  let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
+  let Documentation = [CodeSegDocs];
+}
+
 def PragmaClangBSSSection : InheritableAttr {
   // This attribute has no spellings as it is only ever created implicitly.
   let Spellings = [];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=332470&r1=332469&r2=332470&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed May 16 06:57:17 2018
@@ -306,6 +306,18 @@ An example of how to use ``alloc_size``
   }];
 }
 
+def CodeSegDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``__declspec(code_seg)`` attribute enables the placement of code into 
separate
+named segments that can be paged or locked in memory individually. This 
attribute
+is used to control the placement of instantiated templates and 
compiler-generated
+code. See the documentation for `__declspec(code_seg)`_ on MSDN.
+
+.. _`__declspec(code_seg)`: 
http://msdn.microsoft.com/en-us/library/dn636922.aspx
+  }];
+}
+
 def AllocAlignDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=332470&r1=332469&r2=332470&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 16 06:57:17 
2018
@@ -2668,6 +2668,14 @@ def warn_mismatched_section : Warning<
 def warn_attribute_section_on_redeclaration : Warning<
   "section attribute is specified on redeclared variable">, InGroup;
 
+def err_mismatched_code_seg_base : Error<
+  "derived class must specify the same code segment as its base classes">;
+def err_mismatched_code_seg_override : Error<
+  "overriding virtual function must specify the same code segment as its 
overridden function">;
+def err_conflicting_codeseg_attribute : Error<
+  "conflicting code segment specifiers">;
+def warn_duplicate_codeseg_attribute : Warning<
+  "duplicate code segment specifiers">, InGroup;
 def err_anonymous_property: Error<
   "anonymous property is not supported">;
 def err_property_is_variably_modified : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=332470&r1=332469&r2=33

r332492 - Add lit tests forgotten for R332470

2018-05-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed May 16 10:04:47 2018
New Revision: 332492

URL: http://llvm.org/viewvc/llvm-project?rev=332492&view=rev
Log:
Add lit tests forgotten for R332470

I forgot to svn-add the lit tests for R332470.  
Added here!

Added:
cfe/trunk/test/CodeGenCXX/code_seg1.cpp   (with props)
cfe/trunk/test/CodeGenCXX/code_seg2.cpp   (with props)
cfe/trunk/test/CodeGenCXX/code_seg3.cpp   (with props)
cfe/trunk/test/CodeGenCXX/code_seg4.cpp   (with props)
cfe/trunk/test/SemaCXX/code_seg.cpp   (with props)
cfe/trunk/test/SemaCXX/code_seg1.cpp   (with props)

Added: cfe/trunk/test/CodeGenCXX/code_seg1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/code_seg1.cpp?rev=332492&view=auto
==
--- cfe/trunk/test/CodeGenCXX/code_seg1.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/code_seg1.cpp Wed May 16 10:04:47 2018
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -verify -o 
- %s | FileCheck %s
+// expected-no-diagnostics
+
+// Simple case
+
+int __declspec(code_seg("foo_one")) bar_one() { return 1; }
+//CHECK: define {{.*}}bar_one{{.*}} section "foo_one"
+
+// Simple case - explicit attribute used over pragma
+#pragma code_seg("foo_two")
+int __declspec(code_seg("foo_three")) bar2() { return 2; }
+//CHECK: define {{.*}}bar2{{.*}} section "foo_three"
+
+// Check that attribute on one function doesn't affect another
+int another1() { return 1001; }
+//CHECK: define {{.*}}another1{{.*}} section "foo_two"
+
+// Member functions
+
+struct __declspec(code_seg("foo_four")) Foo {
+  int bar3() {return 0;}
+  int bar4();
+  int __declspec(code_seg("foo_six")) bar6() { return 6; }
+  int bar7() { return 7; }
+  struct Inner {
+int bar5() { return 5; }
+  } z;
+  virtual int baz1() { return 1; }
+};
+
+struct __declspec(code_seg("foo_four")) FooTwo : Foo {
+  int baz1() { return 20; }
+};
+
+int caller1() {
+  Foo f; return f.bar3();
+}
+
+//CHECK: define {{.*}}bar3@Foo{{.*}} section "foo_four"
+int Foo::bar4() { return 4; }
+//CHECK: define {{.*}}bar4@Foo{{.*}} section "foo_four"
+
+#pragma code_seg("someother")
+
+int caller2() {
+  Foo f;
+  Foo *fp = new FooTwo;
+  return f.z.bar5() + f.bar6() + f.bar7() + fp->baz1();
+}
+// TBD: MS Compiler and Docs do not match for nested routines
+// Doc says:  define {{.*}}bar5@Inner@Foo{{.*}} section "foo_four"
+// Compiler says: define {{.*}}bar5@Inner@Foo{{.*}} section "foo_two"
+//CHECK: define {{.*}}bar6@Foo{{.*}} section "foo_six"
+//CHECK: define {{.*}}bar7@Foo{{.*}} section "foo_four"
+// Check that code_seg active at class declaration is not used on member
+// declared outside class when it is not active.
+
+#pragma code_seg(push,"AnotherSeg")
+
+struct FooThree {
+  int bar8();
+  int bar9() { return 9; }
+};
+
+#pragma code_seg(pop)
+
+
+int FooThree::bar8() {return 0;}
+
+int caller3()
+{
+  FooThree f;
+  return f.bar8() + f.bar9();
+}
+
+//CHECK: define {{.*}}bar8@FooThree{{.*}} section "someother"
+//CHECK: define {{.*}}bar9@FooThree{{.*}} section "AnotherSeg"
+
+struct NonTrivialCopy {
+  NonTrivialCopy();
+  NonTrivialCopy(const NonTrivialCopy&);
+  ~NonTrivialCopy();
+};
+
+// check the section for compiler-generated function with declspec.
+
+struct __declspec(code_seg("foo_seven")) FooFour {
+  FooFour() {}
+  int __declspec(code_seg("foo_eight")) bar10(int t) { return t; }
+  NonTrivialCopy f;
+};
+
+//CHECK: define {{.*}}0FooFour@@QAE@ABU0@@Z{{.*}} section "foo_seven"
+// check the section for compiler-generated function with no declspec.
+
+struct FooFive {
+  FooFive() {}
+  int __declspec(code_seg("foo_nine")) bar11(int t) { return t; }
+  NonTrivialCopy f;
+};
+
+//CHECK: define {{.*}}0FooFive@@QAE@ABU0@@Z{{.*}} section "someother"
+
+#pragma code_seg("YetAnother")
+int caller4()
+{
+  FooFour z1;
+  FooFour z2 = z1;
+  FooFive y1;
+  FooFive y2 = y1;
+  return z2.bar10(0) + y2.bar11(1);
+}
+
+//CHECK: define {{.*}}bar10@FooFour{{.*}} section "foo_eight"
+//CHECK: define {{.*}}bar11@FooFive{{.*}} section "foo_nine"
+
+struct FooSix {
+  #pragma code_seg("foo_ten")
+  int bar12() { return 12; }
+  #pragma code_seg("foo_eleven")
+  int bar13() { return 13; }
+};
+
+int bar14() { return 14; }
+//CHECK: define {{.*}}bar14{{.*}} section "foo_eleven"
+
+int caller5()
+{
+  FooSix fsix;
+  return fsix.bar12() + fsix.bar13();
+}
+
+//CHECK: define {{.*}}bar12@FooSix{{.*}} section "foo_ten"
+//CHECK: define {{.*}}bar13@FooSix{{.*}} section "foo_eleven"
+//CHECK: define {{.*}}baz1@FooTwo{{.*}} section "foo_four"

Propchange: cfe/trunk/test/CodeGenCXX/code_seg1.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGenCXX/code_seg1.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/CodeGenCXX/code_seg1.cpp
--

r314229 - [Sema] Corrected the warn-on-throw-from-noexcept behavior to include nothrow

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 11:20:39 2017
New Revision: 314229

URL: http://llvm.org/viewvc/llvm-project?rev=314229&view=rev
Log:
[Sema] Corrected the warn-on-throw-from-noexcept behavior to include nothrow

Discovered that 'nothrow' (which is supposed to be an alias for noexcept)
was not warning with a throw inside of it. This patch corrects the behavior
previously created to add 'nothrow' to this list.

Differential Revision: https://reviews.llvm.org/D38203

Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=314229&r1=314228&r2=314229&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Sep 26 11:20:39 2017
@@ -426,7 +426,7 @@ static void checkThrowInNonThrowingFunc(
 
 static bool isNoexcept(const FunctionDecl *FD) {
   const auto *FPT = FD->getType()->castAs();
-  if (FPT->isNothrow(FD->getASTContext()))
+  if (FPT->isNothrow(FD->getASTContext()) || FD->hasAttr())
 return true;
   return false;
 }

Modified: cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp?rev=314229&r1=314228&r2=314229&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp Tue Sep 26 11:20:39 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fsyntax-only -Wexceptions -verify -std=c++11
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fsyntax-only -Wexceptions -verify -fdeclspec -std=c++11
 struct A_ShouldDiag {
   ~A_ShouldDiag(); // implicitly noexcept(true)
 };
@@ -14,6 +14,15 @@ struct R_ShouldDiag : A_ShouldDiag {
   ~R_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing 
exception specification}}
 throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
   }
+  __attribute__((nothrow)) R_ShouldDiag() {// expected-note {{function 
declared non-throwing here}}
+throw 1;// expected-warning {{has a non-throwing exception specification 
but}}
+  }
+  void __attribute__((nothrow)) SomeThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
+  }
+  void __declspec(nothrow) SomeDeclspecThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
+  }
 };
 
 struct M_ShouldNotDiag {


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


r314235 - Allow IUnknown/IInterface types to come from extern C++

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 11:55:16 2017
New Revision: 314235

URL: http://llvm.org/viewvc/llvm-project?rev=314235&view=rev
Log:
Allow IUnknown/IInterface types to come from extern C++ 

It was brought up in response to my last implementation for
this struct-as-interface features that at least 1 header in
the MS SDK uses "extern C++" around an IUnknown declaration.

The previous implementation demanded that this type exist
in the TranslationUnit DeclContext.  This small change simply
also allows in the situation where we're extern "C++".

Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaCXX/ms-iunknown.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=314235&r1=314234&r2=314235&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Sep 26 11:55:16 2017
@@ -1491,7 +1491,8 @@ bool CXXRecordDecl::isInterfaceLike() co
 
   // Check "Special" types.
   const auto *Uuid = getAttr();
-  if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() &&
+  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
+ getDeclContext()->isExternCXXContext()) &&
   ((getName() == "IUnknown" &&
 Uuid->getGuid() == "---C000-0046") ||
(getName() == "IDispatch" &&

Modified: cfe/trunk/test/SemaCXX/ms-iunknown.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown.cpp?rev=314235&r1=314234&r2=314235&view=diff
==
--- cfe/trunk/test/SemaCXX/ms-iunknown.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-iunknown.cpp Tue Sep 26 11:55:16 2017
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
 
-struct __declspec(uuid("---C000-0046")) IUnknown {
+extern "C++" struct __declspec(uuid("---C000-0046")) 
IUnknown {
   void foo();
 };
 struct IPropertyPageBase : public IUnknown {};


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


r314262 - Emit section information for extern variables.

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 16:42:34 2017
New Revision: 314262

URL: http://llvm.org/viewvc/llvm-project?rev=314262&view=rev
Log:
Emit section information for extern variables. 

Currently, if _attribute_((section())) is used for extern variables, 
section information is not emitted in generated IR when the variables are used. 
This is expected since sections are not generated for external linkage objects. 
However NiosII requires this information as it uses special GP-relative 
accesses 
for any objects that use attribute section (.sdata). GCC keeps this attribute 
in 
  middle-end.

This change emits the section information for all targets.

Patch By: Elizabeth Andrews

Differential Revision:https://reviews.llvm.org/D36487


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/attr-section.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314262&r1=314261&r2=314262&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 26 16:42:34 
2017
@@ -2620,6 +2620,8 @@ def err_attribute_section_invalid_for_ta
   "argument to 'section' attribute is not valid for this target: %0">;
 def warn_mismatched_section : Warning<
   "section does not match previous declaration">, InGroup;
+def warn_attribute_section_on_redeclaration : Warning<
+  "section attribute is specified on redeclared variable">, InGroup;
 
 def err_anonymous_property: Error<
   "anonymous property is not supported">;

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=314262&r1=314261&r2=314262&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Sep 26 16:42:34 2017
@@ -2432,6 +2432,12 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
   EmitGlobalVarDefinition(D);
 }
 
+// Emit section information for extern variables.
+if (D->hasExternalStorage()) {
+  if (const SectionAttr *SA = D->getAttr())
+GV->setSection(SA->getName());
+}
+
 // Handle XCore specific ABI requirements.
 if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=314262&r1=314261&r2=314262&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 26 16:42:34 2017
@@ -2607,6 +2607,16 @@ void Sema::mergeDeclAttributes(NamedDecl
 }
   }
 
+  // This redeclaration adds a section attribute.
+  if (New->hasAttr() && !Old->hasAttr()) {
+if (auto *VD = dyn_cast(New)) {
+  if (VD->isThisDeclarationADefinition() != VarDecl::Definition) {
+Diag(New->getLocation(), 
diag::warn_attribute_section_on_redeclaration);
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
+}
+  }
+
   if (!Old->hasAttrs())
 return;
 

Modified: cfe/trunk/test/Sema/attr-section.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-section.c?rev=314262&r1=314261&r2=314262&view=diff
==
--- cfe/trunk/test/Sema/attr-section.c (original)
+++ cfe/trunk/test/Sema/attr-section.c Tue Sep 26 16:42:34 2017
@@ -19,3 +19,7 @@ void __attribute__((section("foo,zed")))
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning 
{{section does not match previous declaration}}
 
 enum __attribute__((section("NEAR,x"))) e { one }; // expected-error 
{{'section' attribute only applies to functions, methods, properties, and 
global variables}}
+
+extern int a; // expected-note {{previous declaration is here}}
+int *b = &a;
+extern int a __attribute__((section("foo,zed"))); // expected-warning 
{{section attribute is specified on redeclared variable}}


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


r314267 - Fix capitalization of a bunch of parameters in SemaDeclAttr [NFC]

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 20:20:13 2017
New Revision: 314267

URL: http://llvm.org/viewvc/llvm-project?rev=314267&view=rev
Log:
Fix capitalization of a bunch of parameters in SemaDeclAttr [NFC]

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

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=314267&r1=314266&r2=314267&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Sep 26 20:20:13 2017
@@ -1969,20 +1969,20 @@ static void handleNakedAttr(Sema &S, Dec
  
Attr.getAttributeSpellingListIndex()));
 }
 
-static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &attr) {
+static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &Attrs) {
   if (hasDeclarator(D)) return;
 
-  if (S.CheckNoReturnAttr(attr))
+  if (S.CheckNoReturnAttr(Attrs))
 return;
 
   if (!isa(D)) {
-S.Diag(attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-<< attr.getName() << ExpectedFunctionOrMethod;
+S.Diag(Attrs.getLoc(), diag::warn_attribute_wrong_decl_type)
+<< Attrs.getName() << ExpectedFunctionOrMethod;
 return;
   }
 
   D->addAttr(::new (S.Context) NoReturnAttr(
-  attr.getRange(), S.Context, attr.getAttributeSpellingListIndex()));
+  Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
 }
 
 static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D,
@@ -1994,9 +1994,9 @@ static void handleNoCallerSavedRegsAttr(
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }
 
-bool Sema::CheckNoReturnAttr(const AttributeList &attr) {
-  if (!checkAttributeNumArgs(*this, attr, 0)) {
-attr.setInvalid();
+bool Sema::CheckNoReturnAttr(const AttributeList &Attrs) {
+  if (!checkAttributeNumArgs(*this, Attrs, 0)) {
+Attrs.setInvalid();
 return true;
   }
 
@@ -4303,24 +4303,24 @@ static void handleSuppressAttr(Sema &S,
   DiagnosticIdentifiers.size(), Attr.getAttributeSpellingListIndex()));
 }
 
-bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, 
+bool Sema::CheckCallingConvAttr(const AttributeList &Attrs, CallingConv &CC, 
 const FunctionDecl *FD) {
-  if (attr.isInvalid())
+  if (Attrs.isInvalid())
 return true;
 
-  if (attr.hasProcessingCache()) {
-CC = (CallingConv) attr.getProcessingCache();
+  if (Attrs.hasProcessingCache()) {
+CC = (CallingConv) Attrs.getProcessingCache();
 return false;
   }
 
-  unsigned ReqArgs = attr.getKind() == AttributeList::AT_Pcs ? 1 : 0;
-  if (!checkAttributeNumArgs(*this, attr, ReqArgs)) {
-attr.setInvalid();
+  unsigned ReqArgs = Attrs.getKind() == AttributeList::AT_Pcs ? 1 : 0;
+  if (!checkAttributeNumArgs(*this, Attrs, ReqArgs)) {
+Attrs.setInvalid();
 return true;
   }
 
   // TODO: diagnose uses of these conventions on the wrong target.
-  switch (attr.getKind()) {
+  switch (Attrs.getKind()) {
   case AttributeList::AT_CDecl: CC = CC_C; break;
   case AttributeList::AT_FastCall: CC = CC_X86FastCall; break;
   case AttributeList::AT_StdCall: CC = CC_X86StdCall; break;
@@ -4339,8 +4339,8 @@ bool Sema::CheckCallingConvAttr(const At
 break;
   case AttributeList::AT_Pcs: {
 StringRef StrRef;
-if (!checkStringLiteralArgumentAttr(attr, 0, StrRef)) {
-  attr.setInvalid();
+if (!checkStringLiteralArgumentAttr(Attrs, 0, StrRef)) {
+  Attrs.setInvalid();
   return true;
 }
 if (StrRef == "aapcs") {
@@ -4351,8 +4351,8 @@ bool Sema::CheckCallingConvAttr(const At
   break;
 }
 
-attr.setInvalid();
-Diag(attr.getLoc(), diag::err_invalid_pcs);
+Attrs.setInvalid();
+Diag(Attrs.getLoc(), diag::err_invalid_pcs);
 return true;
   }
   case AttributeList::AT_IntelOclBicc: CC = CC_IntelOclBicc; break;
@@ -4365,7 +4365,7 @@ bool Sema::CheckCallingConvAttr(const At
   TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC);
   if (A != TargetInfo::CCCR_OK) {
 if (A == TargetInfo::CCCR_Warning)
-  Diag(attr.getLoc(), diag::warn_cconv_ignored) << attr.getName();
+  Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs.getName();
 
 // This convention is not valid for the target. Use the default function or
 // method calling convention.
@@ -4377,7 +4377,7 @@ bool Sema::CheckCallingConvAttr(const At
 CC = Context.getDefaultCallingConvention(IsVariadic, IsCXXMethod);
   }
 
-  attr.setProcessingCache((unsigned) CC);
+  Attrs.setProcessingCache((unsigned) CC);
   return false;
 }
 
@@ -4414,10 +4414,10 @@ static bool isValidSwiftErrorResultType(
   return isValidSwiftContextType(type);
 }
 
-static void handleParameterABIAttr(Sema &S, Decl *D, const AttributeList &attr,
-   ParameterABI abi) {
-  S.AddParameterABIAttr(attr.getRange(), 

r314268 - Add test forgotten in r314262.

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 20:23:02 2017
New Revision: 314268

URL: http://llvm.org/viewvc/llvm-project?rev=314268&view=rev
Log:
Add test forgotten in r314262.

Added:
cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp   (with props)

Added: cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp?rev=314268&view=auto
==
--- cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp Tue Sep 26 20:23:02 
2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck 
%s
+
+extern int aa __attribute__((section(".sdata")));
+// CHECK-DAG: @aa = external global i32, section ".sdata", align 4
+
+extern int bb __attribute__((section(".sdata"))) = 1;
+// CHECK-DAG: @bb = global i32 1, section ".sdata", align 4
+
+int foo() {
+  return aa + bb;
+}

Propchange: cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp
--
svn:mime-type = text/plain


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


r314456 - Add Documentation to attribute-nothrow. Additionally, limit to functions.

2017-09-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 28 13:08:03 2017
New Revision: 314456

URL: http://llvm.org/viewvc/llvm-project?rev=314456&view=rev
Log:
Add Documentation to attribute-nothrow. Additionally, limit to functions.

Attribute nothrow is only allowed on functions, so I added that. Additionally,
it lacks any documentation, so I added some.

Differential Revision: https://reviews.llvm.org/D38202

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=314456&r1=314455&r2=314456&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Sep 28 13:08:03 2017
@@ -1437,7 +1437,8 @@ def NotTailCalled : InheritableAttr {
 
 def NoThrow : InheritableAttr {
   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
-  let Documentation = [Undocumented];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoThrowDocs];
 }
 
 def NvWeak : IgnoredAttr {

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=314456&r1=314455&r2=314456&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Sep 28 13:08:03 2017
@@ -2727,6 +2727,18 @@ Marking virtual functions as ``not_tail_
   }];
 }
 
+def NoThrowDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the GNU style ``__attribute__((nothrow))`` and Microsoft style
+``__declspec(nothrow)`` attribute as an equivilent of `noexcept` on function
+declarations. This attribute informs the compiler that the annotated function
+does not throw an exception. This prevents exception-unwinding. This attribute
+is particularly useful on functions in the C Standard Library that are
+guaranteed to not throw an exception.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=314456&r1=314455&r2=314456&view=diff
==
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test 
(original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Thu Sep 
28 13:08:03 2017
@@ -40,6 +40,7 @@
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, 
SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSplitStack (SubjectMatchRule_function)
+// CHECK-NEXT: NoThrow (SubjectMatchRule_function)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)


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


r314460 - Fix test change missed in r314456

2017-09-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 28 13:23:43 2017
New Revision: 314460

URL: http://llvm.org/viewvc/llvm-project?rev=314460&view=rev
Log:
Fix test change missed in r314456

Modified:
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=314460&r1=314459&r2=314460&view=diff
==
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test 
(original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Thu Sep 
28 13:23:43 2017
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 65 attributes:
+// CHECK: #pragma clang attribute supports 66 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)


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


r314461 - [Sema] Warn on attribute nothrow conflicting with language specifiers

2017-09-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 28 13:36:53 2017
New Revision: 314461

URL: http://llvm.org/viewvc/llvm-project?rev=314461&view=rev
Log:
[Sema] Warn on attribute nothrow conflicting with language specifiers

I discovered it was possible to create a 'nothrow' noexcept(false)
function, which is both non-sensical as well as seemingly breaking.

This patch warns if attribute nothrow is used with anything besides "noexcept".

"noexcept(true)" isn't possible, because the noexcept decl isn't parsed until
later.

Differential Revision: https://reviews.llvm.org/D38205

Added:
cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp   
(with props)
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314461&r1=314460&r2=314461&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 28 13:36:53 
2017
@@ -1407,6 +1407,10 @@ def err_noexcept_needs_constant_expressi
   "argument to noexcept specifier must be a constant expression">;
 def err_exception_spec_not_parsed : Error<
   "exception specification is not available until end of class definition">;
+def warn_nothrow_attr_disagrees_with_exception_specification
+: ExtWarn<"attribute 'nothrow' ignored due to conflicting exception "
+  "specification">,
+  InGroup;
 
 // C++ access checking
 def err_class_redeclared_with_different_access : Error<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=314461&r1=314460&r2=314461&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Sep 28 13:36:53 2017
@@ -1985,6 +1985,25 @@ static void handleNoReturnAttr(Sema &S,
   Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
 }
 
+static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) {
+  assert(isa(D) && "attribute nothrow only valid on functions");
+
+  auto *FD = cast(D);
+  const auto *FPT = FD->getType()->getAs();
+
+  if (FPT && FPT->hasExceptionSpec() &&
+  FPT->getExceptionSpecType() != EST_BasicNoexcept) {
+S.Diag(Attrs.getLoc(),
+   diag::warn_nothrow_attr_disagrees_with_exception_specification);
+S.Diag(FD->getExceptionSpecSourceRange().getBegin(),
+   diag::note_previous_decl)
+<< "exception specification";
+  }
+
+  D->addAttr(::new (S.Context) NoThrowAttr(
+  Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
+}
+
 static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
   if (S.CheckNoCallerSavedRegsAttr(Attr))
@@ -6211,7 +6230,7 @@ static void ProcessDeclAttribute(Sema &S
 handleNoReturnAttr(S, D, Attr);
 break;
   case AttributeList::AT_NoThrow:
-handleSimpleAttribute(S, D, Attr);
+handleNoThrowAttr(S, D, Attr);
 break;
   case AttributeList::AT_CUDAShared:
 handleSharedAttr(S, D, Attr);

Added: cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp?rev=314461&view=auto
==
--- cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp 
(added)
+++ cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp Thu 
Sep 28 13:36:53 2017
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify 
-std=c++14
+
+struct S {
+  //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) S() noexcept(true);
+  //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) void Func1() noexcept(false);
+  __attribute__((nothrow)) void Func3() noexcept;
+};
+
+void throwing() noexcept(false);
+void non_throwing(bool b = true) noexcept;
+
+template 
+struct T {
+__attribute__((nothrow)) void f(Fn) noexcept(Fn());
+};
+
+//expected-warning@-3 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+//expected-note@-4 {{exception specification declared here}}
+template struct T;
+template struct T;

Propchange: 
cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
--

r314462 - [Sema] Correct nothrow inherited by noexcept

2017-09-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 28 13:47:10 2017
New Revision: 314462

URL: http://llvm.org/viewvc/llvm-project?rev=314462&view=rev
Log:
[Sema] Correct nothrow inherited by noexcept

As reported in https://bugs.llvm.org/show_bug.cgi?id=33235,
a noexcept function was unable to inherit from a nothrow defaulted
constructor. Attribute "nothrow" is supposed to be semantically
identical to noexcept, and in fact, a number of other places in the
code treat them identically.

This patch simply checks the RecordDecl for the correct attribute in
the case where no other exception specifier was set.

Differential Revision: https://reviews.llvm.org/D38209

Added:
cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp   (with props)
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=314462&r1=314461&r2=314462&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Sep 28 13:47:10 2017
@@ -167,6 +167,9 @@ Sema::ImplicitExceptionSpecification::Ca
   if (ComputedEST == EST_None)
 return;
 
+  if (EST == EST_None && Method->hasAttr())
+EST = EST_BasicNoexcept;
+
   switch(EST) {
   // If this function can throw any exceptions, make a note of that.
   case EST_MSAny:

Added: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp?rev=314462&view=auto
==
--- cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp (added)
+++ cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp Thu Sep 28 13:47:10 2017
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify 
-std=c++14
+
+// expected-no-diagnostics
+struct Base {
+  __attribute__((nothrow)) Base() {}
+};
+
+struct Derived : Base {
+  Derived() noexcept = default;
+};
+
+struct Base2 {
+   Base2() noexcept {}
+};
+
+struct Derived2 : Base2 {
+  __attribute__((nothrow)) Derived2() = default;
+};
+
+struct Base3 {
+  __attribute__((nothrow)) Base3() {}
+};
+
+struct Derived3 : Base3 {
+  __attribute__((nothrow)) Derived3() = default;
+};

Propchange: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
--
svn:mime-type = text/plain


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


r314557 - [Sema] Correct IUnknown to support Unknwnbase.h Header.

2017-09-29 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Sep 29 14:06:00 2017
New Revision: 314557

URL: http://llvm.org/viewvc/llvm-project?rev=314557&view=rev
Log:
[Sema] Correct IUnknown to support Unknwnbase.h Header.

Apparently, the MSVC SDK has a strange implementation that
causes a number of implicit functions as well as a template member
function of the IUnknown type. This patch allows these as InterfaceLike
types as well.

Additionally, it corrects the behavior where extern-C++ wrapped around an
Interface-Like type would permit an interface-like type to exist in a namespace.

Differential Revision: https://reviews.llvm.org/D38303

Added:
cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp   (with props)
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaCXX/ms-iunknown.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=314557&r1=314556&r2=314557&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Sep 29 14:06:00 2017
@@ -1470,6 +1470,15 @@ bool CXXRecordDecl::isAnyDestructorNoRet
   return false;
 }
 
+static bool isDeclContextInNamespace(const DeclContext *DC) {
+  while (!DC->isTranslationUnit()) {
+if (DC->isNamespace())
+  return true;
+DC = DC->getParent();
+  }
+  return false;
+}
+
 bool CXXRecordDecl::isInterfaceLike() const {
   assert(hasDefinition() && "checking for interface-like without a 
definition");
   // All __interfaces are inheritently interface-like.
@@ -1486,13 +1495,16 @@ bool CXXRecordDecl::isInterfaceLike() co
 
   // No interface-like type can have a method with a definition.
   for (const auto *const Method : methods())
-if (Method->isDefined())
+if (Method->isDefined() && !Method->isImplicit())
   return false;
 
   // Check "Special" types.
   const auto *Uuid = getAttr();
-  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
- getDeclContext()->isExternCXXContext()) &&
+  // MS SDK declares IUnknown/IDispatch both in the root of a TU, or in an
+  // extern C++ block directly in the TU.  These are only valid if in one
+  // of these two situations.
+  if (Uuid && isStruct() && !getDeclContext()->isExternCContext() &&
+  !isDeclContextInNamespace(getDeclContext()) &&
   ((getName() == "IUnknown" &&
 Uuid->getGuid() == "---C000-0046") ||
(getName() == "IDispatch" &&

Added: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp?rev=314557&view=auto
==
--- cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp (added)
+++ cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp Fri Sep 29 
14:06:00 2017
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
+typedef long HRESULT;
+typedef unsigned long ULONG;
+typedef struct _GUID {
+  unsigned long Data1;
+  unsigned short Data2;
+  unsigned short Data3;
+  unsigned char Data4[8];
+} GUID;
+typedef GUID IID;
+
+// remove stdcall, since the warnings have nothing to do with
+// what is being tested.
+#define __stdcall
+
+extern "C" {
+extern "C++" {
+// expected-warning@+1 {{__declspec attribute 'novtable'}}
+struct __declspec(uuid("---C000-0046")) 
__declspec(novtable)
+IUnknown {
+public:
+  virtual HRESULT __stdcall QueryInterface(
+  const IID &riid,
+  void **ppvObject) = 0;
+
+  virtual ULONG __stdcall AddRef(void) = 0;
+
+  virtual ULONG __stdcall Release(void) = 0;
+
+  template 
+  HRESULT __stdcall QueryInterface(Q **pp) {
+return QueryInterface(__uuidof(Q), (void **)pp);
+  }
+};
+}
+}
+
+__interface ISfFileIOPropertyPage : public IUnknown{};
+

Propchange: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
--
svn:mime-type = text/plain

Modified: cfe/trunk/test/SemaCXX/ms-iunknown.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown.cpp?rev=314557&r1=314556&r2=314557&view=diff
==
--- cfe/trunk/test/SemaCXX/ms-iunknown.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-iunknown.cpp Fri Sep 29 14:06:00 2017
@@ -2,7 +2,11 @@
 
 extern "C++" struct __declspec(uuid("---C000-0046")) 
IUnknown {
   void foo();
+  // 

r314687 - Update IUnknown lit test to pass on Win32

2017-10-02 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Oct  2 09:49:32 2017
New Revision: 314687

URL: http://llvm.org/viewvc/llvm-project?rev=314687&view=rev
Log:
Update IUnknown lit test to pass on Win32

Modified:
cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp

Modified: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp?rev=314687&r1=314686&r2=314687&view=diff
==
--- cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp Mon Oct  2 
09:49:32 2017
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// expected-no-diagnostics
 typedef long HRESULT;
 typedef unsigned long ULONG;
 typedef struct _GUID {
@@ -15,8 +16,7 @@ typedef GUID IID;
 
 extern "C" {
 extern "C++" {
-// expected-warning@+1 {{__declspec attribute 'novtable'}}
-struct __declspec(uuid("---C000-0046")) 
__declspec(novtable)
+struct __declspec(uuid("---C000-0046"))
 IUnknown {
 public:
   virtual HRESULT __stdcall QueryInterface(


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


r314939 - Fix 'section' warning behavior with tentatively-defined values

2017-10-04 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Oct  4 15:16:24 2017
New Revision: 314939

URL: http://llvm.org/viewvc/llvm-project?rev=314939&view=rev
Log:
Fix 'section' warning behavior with tentatively-defined values

As reported on cfe-commits, r314262 resulted in tentatively-defined
variables not being excluded for the warning.

Patch By: Elizabeth Andrews

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/attr-section.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=314939&r1=314938&r2=314939&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct  4 15:16:24 2017
@@ -2627,7 +2627,7 @@ void Sema::mergeDeclAttributes(NamedDecl
   // This redeclaration adds a section attribute.
   if (New->hasAttr() && !Old->hasAttr()) {
 if (auto *VD = dyn_cast(New)) {
-  if (VD->isThisDeclarationADefinition() != VarDecl::Definition) {
+  if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly) {
 Diag(New->getLocation(), 
diag::warn_attribute_section_on_redeclaration);
 Diag(Old->getLocation(), diag::note_previous_declaration);
   }

Modified: cfe/trunk/test/Sema/attr-section.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-section.c?rev=314939&r1=314938&r2=314939&view=diff
==
--- cfe/trunk/test/Sema/attr-section.c (original)
+++ cfe/trunk/test/Sema/attr-section.c Wed Oct  4 15:16:24 2017
@@ -23,3 +23,12 @@ enum __attribute__((section("NEAR,x")))
 extern int a; // expected-note {{previous declaration is here}}
 int *b = &a;
 extern int a __attribute__((section("foo,zed"))); // expected-warning 
{{section attribute is specified on redeclared variable}}
+
+// Not a warning.
+int c;
+int c __attribute__((section("foo,zed")));
+
+// Also OK.
+struct r_debug {};
+extern struct r_debug _r_debug;
+struct r_debug _r_debug __attribute__((nocommon, section(".r_debug,bar")));


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


r315075 - Split X86::BI__builtin_cpu_init handling into own function[NFC]

2017-10-06 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Oct  6 09:40:45 2017
New Revision: 315075

URL: http://llvm.org/viewvc/llvm-project?rev=315075&view=rev
Log:
Split X86::BI__builtin_cpu_init handling into own function[NFC]

The Cpu Init functionality is required for the target
attribute, so this patch simply splits it out into its own
function, exactly like CpuIs and CpuSupports.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=315075&r1=315074&r2=315075&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Oct  6 09:40:45 2017
@@ -7708,12 +7708,21 @@ Value *CodeGenFunction::EmitX86CpuSuppor
   return Builder.CreateICmpNE(Bitset, llvm::ConstantInt::get(Int32Ty, 0));
 }
 
+Value *CodeGenFunction::EmitX86CpuInit() {
+  llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
+/*Variadic*/ false);
+  llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, 
"__cpu_indicator_init");
+  return Builder.CreateCall(Func);
+}
+
 Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
   if (BuiltinID == X86::BI__builtin_cpu_is)
 return EmitX86CpuIs(E);
   if (BuiltinID == X86::BI__builtin_cpu_supports)
 return EmitX86CpuSupports(E);
+  if (BuiltinID == X86::BI__builtin_cpu_init)
+return EmitX86CpuInit();
 
   SmallVector Ops;
 
@@ -7765,13 +7774,6 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 
   switch (BuiltinID) {
   default: return nullptr;
-  case X86::BI__builtin_cpu_init: {
-llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
-  /*Variadic*/false);
-llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy,
- "__cpu_indicator_init");
-return Builder.CreateCall(Func);
-  }
   case X86::BI_mm_prefetch: {
 Value *Address = Ops[0];
 Value *RW = ConstantInt::get(Int32Ty, 0);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=315075&r1=315074&r2=315075&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Oct  6 09:40:45 2017
@@ -3901,6 +3901,7 @@ private:
   llvm::Value *EmitX86CpuIs(StringRef CPUStr);
   llvm::Value *EmitX86CpuSupports(const CallExpr *E);
   llvm::Value *EmitX86CpuSupports(ArrayRef FeatureStrs);
+  llvm::Value *EmitX86CpuInit();
 };
 
 /// Helper class with most of the code for saving a value for a


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


r315638 - [Sema][Crash] Correctly handle an non-dependent noexcept expr in function template

2017-10-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Oct 12 16:01:53 2017
New Revision: 315638

URL: http://llvm.org/viewvc/llvm-project?rev=315638&view=rev
Log:
[Sema][Crash] Correctly handle an non-dependent noexcept expr in function 
template

It seems that all of the other templated cases are handled correctly,
however the function template case was not correctly handled. This
patch recovers from this condition by setting the function to noexcept
after diagnosing. Previously it simply set NoexceptExpr to null,
which caused an Assert when this was evaluated during substitution.

Differential Revision:https://reviews.llvm.org/D38700


Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/except/except.spec/p1.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=315638&r1=315637&r2=315638&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Oct 12 16:01:53 2017
@@ -14865,10 +14865,16 @@ void Sema::checkExceptionSpecification(
 return;
   }
 
-  if (!NoexceptExpr->isValueDependent())
-NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, nullptr,
- diag::err_noexcept_needs_constant_expression,
- /*AllowFold*/ false).get();
+  if (!NoexceptExpr->isValueDependent()) {
+ExprResult Result = VerifyIntegerConstantExpression(
+NoexceptExpr, nullptr, 
diag::err_noexcept_needs_constant_expression,
+/*AllowFold*/ false);
+if (Result.isInvalid()) {
+  ESI.Type = EST_BasicNoexcept;
+  return;
+}
+NoexceptExpr = Result.get();
+  }
   ESI.NoexceptExpr = NoexceptExpr;
 }
 return;

Modified: cfe/trunk/test/CXX/except/except.spec/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/except/except.spec/p1.cpp?rev=315638&r1=315637&r2=315638&view=diff
==
--- cfe/trunk/test/CXX/except/except.spec/p1.cpp (original)
+++ cfe/trunk/test/CXX/except/except.spec/p1.cpp Thu Oct 12 16:01:53 2017
@@ -86,3 +86,12 @@ namespace PR11084 {
 f<0>(); // expected-note{{in instantiation of function template 
specialization}}
   }
 }
+
+namespace FuncTmplNoexceptError {
+  int a = 0;
+  // expected-error@+1{{argument to noexcept specifier must be a constant 
expression}}
+  template  T f() noexcept(a++){ return {};}
+  void g(){
+f();
+  }
+};


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


r315929 - Clarify the 'interrupt' names in Attribute Docs

2017-10-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Oct 16 13:13:36 2017
New Revision: 315929

URL: http://llvm.org/viewvc/llvm-project?rev=315929&view=rev
Log:
Clarify the 'interrupt' names in Attribute Docs

All 4 of the 'interrupt' headers were automatically named
'interrupt'. This patch gives them unique names.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=315929&r1=315928&r2=315929&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Oct 16 13:13:36 2017
@@ -1290,6 +1290,7 @@ Here is an example:
 
 def ARMInterruptDocs : Documentation {
   let Category = DocCatFunction;
+  let Heading = "interrupt (ARM)";
   let Content = [{
 Clang supports the GNU style ``__attribute__((interrupt("TYPE")))`` attribute 
on
 ARM targets. This attribute may be attached to a function definition and
@@ -1331,6 +1332,7 @@ The semantics are as follows:
 
 def MipsInterruptDocs : Documentation {
   let Category = DocCatFunction;
+  let Heading = "interrupt (MIPS)";
   let Content = [{
 Clang supports the GNU style ``__attribute__((interrupt("ARGUMENT")))`` 
attribute on
 MIPS targets. This attribute may be attached to a function definition and 
instructs
@@ -1427,6 +1429,7 @@ as ``-mlong-calls`` and ``-mno-long-call
 
 def AVRInterruptDocs : Documentation {
   let Category = DocCatFunction;
+  let Heading = "interrupt (AVR)";
   let Content = [{
 Clang supports the GNU style ``__attribute__((interrupt))`` attribute on
 AVR targets. This attribute may be attached to a function definition and 
instructs
@@ -2789,6 +2792,7 @@ Marking virtual functions as ``disable_t
 
 def AnyX86InterruptDocs : Documentation {
   let Category = DocCatFunction;
+  let Heading = "interrupt (X86)";
   let Content = [{
 Clang supports the GNU style ``__attribute__((interrupt))`` attribute on
 x86/x86-64 targets.The compiler generates function entry and exit sequences


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


r315931 - Sort Attributes by "HeaderName"

2017-10-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Oct 16 13:31:05 2017
New Revision: 315931

URL: http://llvm.org/viewvc/llvm-project?rev=315931&view=rev
Log:
Sort Attributes by "HeaderName" 

Attributes in the docs were previously sorted (apparently)
by the attribute name, so AnyX86Interrupt ended up being the
first one, rather than in a meaningful place. This resulted in the
4 'interrupt' titled sections being all in different places.

This replaces it with a naive alphabetical sort (case sensitive, underscore
and special characters first, etc).

Differential Revision: https://reviews.llvm.org/D38969

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=315931&r1=315930&r2=315931&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Oct 16 13:31:05 2017
@@ -3663,9 +3663,14 @@ class DocumentationData {
 public:
   const Record *Documentation;
   const Record *Attribute;
+  std::string Heading;
+  unsigned SupportedSpellings;
 
-  DocumentationData(const Record &Documentation, const Record &Attribute)
-  : Documentation(&Documentation), Attribute(&Attribute) {}
+  DocumentationData(const Record &Documentation, const Record &Attribute,
+const std::pair HeadingAndKinds)
+  : Documentation(&Documentation), Attribute(&Attribute),
+Heading(std::move(HeadingAndKinds.first)),
+SupportedSpellings(HeadingAndKinds.second) {}
 };
 
 static void WriteCategoryHeader(const Record *DocCategory,
@@ -3691,16 +3696,17 @@ enum SpellingKind {
   Pragma = 1 << 6
 };
 
-static void WriteDocumentation(RecordKeeper &Records,
-   const DocumentationData &Doc, raw_ostream &OS) {
+static std::pair
+GetAttributeHeadingAndSpellingKinds(const Record &Documentation,
+const Record &Attribute) {
   // FIXME: there is no way to have a per-spelling category for the attribute
   // documentation. This may not be a limiting factor since the spellings
   // should generally be consistently applied across the category.
 
-  std::vector Spellings = 
GetFlattenedSpellings(*Doc.Attribute);
+  std::vector Spellings = GetFlattenedSpellings(Attribute);
 
   // Determine the heading to be used for this attribute.
-  std::string Heading = Doc.Documentation->getValueAsString("Heading");
+  std::string Heading = Documentation.getValueAsString("Heading");
   bool CustomHeading = !Heading.empty();
   if (Heading.empty()) {
 // If there's only one spelling, we can simply use that.
@@ -3722,7 +3728,7 @@ static void WriteDocumentation(RecordKee
 
   // If the heading is still empty, it is an error.
   if (Heading.empty())
-PrintFatalError(Doc.Attribute->getLoc(),
+PrintFatalError(Attribute.getLoc(),
 "This attribute requires a heading to be specified");
 
   // Gather a list of unique spellings; this is not the same as the semantic
@@ -3765,29 +3771,33 @@ static void WriteDocumentation(RecordKee
 }
 Heading += ")";
   }
-  OS << Heading << "\n" << std::string(Heading.length(), '-') << "\n";
-
   if (!SupportedSpellings)
-PrintFatalError(Doc.Attribute->getLoc(),
+PrintFatalError(Attribute.getLoc(),
 "Attribute has no supported spellings; cannot be "
 "documented");
+  return std::make_pair(std::move(Heading), SupportedSpellings);
+}
+
+static void WriteDocumentation(RecordKeeper &Records,
+   const DocumentationData &Doc, raw_ostream &OS) {
+  OS << Doc.Heading << "\n" << std::string(Doc.Heading.length(), '-') << "\n";
 
   // List what spelling syntaxes the attribute supports.
   OS << ".. csv-table:: Supported Syntaxes\n";
   OS << "   :header: \"GNU\", \"C++11\", \"C2x\", \"__declspec\", 
\"Keyword\",";
   OS << " \"Pragma\", \"Pragma clang attribute\"\n\n";
   OS << "   \"";
-  if (SupportedSpellings & GNU) OS << "X";
+  if (Doc.SupportedSpellings & GNU) OS << "X";
   OS << "\",\"";
-  if (SupportedSpellings & CXX11) OS << "X";
+  if (Doc.SupportedSpellings & CXX11) OS << "X";
   OS << "\",\"";
-  if (SupportedSpellings & C2x) OS << "X";
+  if (Doc.SupportedSpellings & C2x) OS << "X";
   OS << "\",\"";
-  if (SupportedSpellings & Declspec) OS << "X";
+  if (Doc.SupportedSpellings & Declspec) OS << "X";
   OS << "\",\"";
-  if (SupportedSpellings & Keyword) OS << "X";
+  if (Doc.SupportedSpellings & Keyword) OS << "X";
   OS << "\", \"";
-  if (SupportedSpellings & Pragma) OS << "X";
+  if (Doc.SupportedSpellings & Pragma) OS << "X";
   OS << "\", \"";
   if (getPragmaAttributeSupport(Records).isAttributedSupported(*Doc.Attribute))
 OS << "X";
@@ -3842,18 +3852,24 @@ void EmitClangAttrDocs(RecordKeeper &Rec
   if (Undocumented && Docs.size() > 1)
   

r315934 - Remove AnyX86Interrupt documentation

2017-10-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Oct 16 13:44:14 2017
New Revision: 315934

URL: http://llvm.org/viewvc/llvm-project?rev=315934&view=rev
Log:
Remove AnyX86Interrupt documentation

This documentation was copied directly from the GCC
documentaiton in r257867.  Reverting and alterting
the original author so that it can be rewritten in
copyright-safe language.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=315934&r1=315933&r2=315934&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Oct 16 13:44:14 2017
@@ -2044,7 +2044,7 @@ def AnyX86Interrupt : InheritableAttr, T
   let Subjects = SubjectList<[HasFunctionProto]>;
   let ParseKind = "Interrupt";
   let HasCustomParsing = 1;
-  let Documentation = [AnyX86InterruptDocs];
+  let Documentation = [Undocumented];
 }
 
 def AnyX86NoCallerSavedRegisters : InheritableAttr,

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=315934&r1=315933&r2=315934&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Oct 16 13:44:14 2017
@@ -2790,60 +2790,6 @@ Marking virtual functions as ``disable_t
   }];
 }
 
-def AnyX86InterruptDocs : Documentation {
-  let Category = DocCatFunction;
-  let Heading = "interrupt (X86)";
-  let Content = [{
-Clang supports the GNU style ``__attribute__((interrupt))`` attribute on
-x86/x86-64 targets.The compiler generates function entry and exit sequences
-suitable for use in an interrupt handler when this attribute is present.
-The 'IRET' instruction, instead of the 'RET' instruction, is used to return
-from interrupt or exception handlers.  All registers, except for the EFLAGS
-register which is restored by the 'IRET' instruction, are preserved by the
-compiler.
-
-Any interruptible-without-stack-switch code must be compiled with
--mno-red-zone since interrupt handlers can and will, because of the
-hardware design, touch the red zone.
-
-1. interrupt handler must be declared with a mandatory pointer argument:
-
-  .. code-block:: c
-
-struct interrupt_frame
-{
-  uword_t ip;
-  uword_t cs;
-  uword_t flags;
-  uword_t sp;
-  uword_t ss;
-};
-
-__attribute__ ((interrupt))
-void f (struct interrupt_frame *frame) {
-  ...
-}
-
-2. exception handler:
-
-  The exception handler is very similar to the interrupt handler with
-  a different mandatory function signature:
-
-  .. code-block:: c
-
-__attribute__ ((interrupt))
-void f (struct interrupt_frame *frame, uword_t error_code) {
-  ...
-}
-
-  and compiler pops 'ERROR_CODE' off stack before the 'IRET' instruction.
-
-  The exception handler should only be used for exceptions which push an
-  error code and all other exceptions must use the interrupt handler.
-  The system will crash if the wrong handler is used.
-  }];
-}
-
 def AnyX86NoCallerSavedRegistersDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{


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


r315950 - Replace usage of std::stringstream with raw_string_ostream

2017-10-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Oct 16 15:47:26 2017
New Revision: 315950

URL: http://llvm.org/viewvc/llvm-project?rev=315950&view=rev
Log:
Replace usage of std::stringstream with raw_string_ostream

Typically we don't use the stringstream, so instead use
raw_string_stream.  Additionally, the dependent function
changed to use raw_ostream.

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=315950&r1=315949&r2=315950&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Oct 16 15:47:26 2017
@@ -2998,7 +2998,7 @@ static bool isArgVariadic(const Record &
   return createArgument(R, AttrName)->isVariadic();
 }
 
-static void emitArgInfo(const Record &R, std::stringstream &OS) {
+static void emitArgInfo(const Record &R, raw_ostream &OS) {
   // This function will count the number of arguments specified for the
   // attribute and emit the number of required arguments followed by the
   // number of optional arguments.
@@ -3471,7 +3471,8 @@ void EmitClangAttrParsedAttrImpl(RecordK
   // another mapping. At the same time, generate the AttrInfoMap object
   // contents. Due to the reliance on generated code, use separate streams so
   // that code will not be interleaved.
-  std::stringstream SS;
+  std::string Buffer;
+  raw_string_ostream SS {Buffer};
   for (auto I = Attrs.begin(), E = Attrs.end(); I != E; ++I) {
 // TODO: If the attribute's kind appears in the list of duplicates, that is
 // because it is a target-specific attribute that appears multiple times.


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


r315956 - Fix usage in TableGen of getValueAsString

2017-10-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Oct 16 16:25:24 2017
New Revision: 315956

URL: http://llvm.org/viewvc/llvm-project?rev=315956&view=rev
Log:
Fix usage in TableGen of getValueAsString

Record::getValueAsString returns a stringref to an interned
string (apparently had been changed since most of tablegen was
written). In this patch, I audited the usage of getValueAsString
to find places where we can trivially stop storing 'std::string' and instead
keep the stringref.

There was one instance where an unnecessary 'stringstream' was being used,
so that has been removed as well to unblock the stringref replacing string fix.

Differential Revision: https://reviews.llvm.org/D38979

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=315956&r1=315955&r2=315956&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Oct 16 16:25:24 2017
@@ -1440,7 +1440,7 @@ static void writeAttrAccessorDefinition(
   assert(!SpellingList.empty() &&
  "Attribute with empty spelling list can't have accessors!");
   for (const auto *Accessor : Accessors) {
-std::string Name = Accessor->getValueAsString("Name");
+const StringRef Name = Accessor->getValueAsString("Name");
 std::vector Spellings = 
GetFlattenedSpellings(*Accessor);
 
 OS << "  bool " << Name << "() const { return SpellingListIndex == ";
@@ -1589,7 +1589,7 @@ struct AttributeSubjectMatchRule {
   // Abstract rules are used only for sub-rules
   bool isAbstractRule() const { return getSubjects().empty(); }
 
-  std::string getName() const {
+  StringRef getName() const {
 return (Constraint ? Constraint : MetaSubject)->getValueAsString("Name");
   }
 
@@ -1821,13 +1821,11 @@ PragmaClangAttributeSupport::generateStr
   // Generate a function that constructs a set of matching rules that describe
   // to which declarations the attribute should apply to.
   std::string FnName = "matchRulesFor" + Attr.getName().str();
-  std::stringstream SS;
-  SS << "static void " << FnName << "(llvm::SmallVectorImpl> &MatchRules, const LangOptions &LangOpts) {\n";
   if (Attr.isValueUnset("Subjects")) {
-SS << "}\n\n";
-OS << SS.str();
+OS << "}\n\n";
 return FnName;
   }
   const Record *SubjectObj = Attr.getValueAsDef("Subjects");
@@ -1840,24 +1838,23 @@ PragmaClangAttributeSupport::generateStr
   // The rule might be language specific, so only subtract it from the 
given
   // rules if the specific language options are specified.
   std::vector LangOpts = Rule.getLangOpts();
-  SS << "  MatchRules.push_back(std::make_pair(" << Rule.getEnumValue()
+  OS << "  MatchRules.push_back(std::make_pair(" << Rule.getEnumValue()
  << ", /*IsSupported=*/";
   if (!LangOpts.empty()) {
 for (auto I = LangOpts.begin(), E = LangOpts.end(); I != E; ++I) {
-  std::string Part = (*I)->getValueAsString("Name");
+  const StringRef Part = (*I)->getValueAsString("Name");
   if ((*I)->getValueAsBit("Negated"))
-SS << "!";
-  SS << "LangOpts." + Part;
+OS << "!";
+  OS << "LangOpts." << Part;
   if (I + 1 != E)
-SS << " || ";
+OS << " || ";
 }
   } else
-SS << "true";
-  SS << "));\n";
+OS << "true";
+  OS << "));\n";
 }
   }
-  SS << "}\n\n";
-  OS << SS.str();
+  OS << "}\n\n";
   return FnName;
 }
 
@@ -1913,7 +1910,8 @@ void PragmaClangAttributeSupport::genera
   continue;
 std::string SubRuleFunction;
 if (SubMatchRules.count(Rule.MetaSubject))
-  SubRuleFunction = "isAttributeSubjectMatchSubRuleFor_" + Rule.getName();
+  SubRuleFunction =
+  ("isAttributeSubjectMatchSubRuleFor_" + Rule.getName()).str();
 else
   SubRuleFunction = "defaultIsAttributeSubjectMatchSubRuleFor";
 OS << "  Case(\"" << Rule.getName() << "\", std::make_pair("
@@ -3030,7 +3028,7 @@ static void GenerateDefaultAppertainsTo(
 static std::string CalculateDiagnostic(const Record &S) {
   // If the SubjectList object has a custom diagnostic associated with it,
   // return that directly.
-  std::string CustomDiag = S.getValueAsString("CustomDiag");
+  const StringRef CustomDiag = S.getValueAsString("CustomDiag");
   if (!CustomDiag.empty())
 return CustomDiag;
 
@@ -3314,12 +3312,13 @@ static std::string GenerateLangOptRequir
   // codegen efficiency).
   std::string FnName = "check", Test;
   for (auto I = LangOpts.begin(), E = LangOpts.end(); I != E; ++I) {
-std::string Part = (*I)->getValueAsString("Name");
+const StringRef Part = (*I)->getValueAsString("Name");
 if ((*I)->getValueAsBit("Negated")) {
   FnName += "Not";
   Test += "!";
 }
-Test += "S.Lan

r316015 - Replace use of SmallVector::back + pop_back with pop_back_val

2017-10-17 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Oct 17 10:45:21 2017
New Revision: 316015

URL: http://llvm.org/viewvc/llvm-project?rev=316015&view=rev
Log:
Replace use of SmallVector::back + pop_back with pop_back_val

I ran across an instance where the value was being loaded
out via back, then immediately popped.  Since pop_back_val
is more efficient at this (it moves out), replace this 
instance.

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=316015&r1=316014&r2=316015&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Oct 17 10:45:21 2017
@@ -361,8 +361,7 @@ static bool hasThrowOutNonThrowingFunc(S
   SmallVector Stack;
   Stack.push_back(&BodyCFG->getEntry());
   while (!Stack.empty()) {
-CFGBlock *CurBlock = Stack.back();
-Stack.pop_back();
+CFGBlock *CurBlock = Stack.pop_back_val();
 
 unsigned ID = CurBlock->getBlockID();
 ThrowState CurState = States[ID];


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


r316030 - [CFG] Relax Wexceptions warning on rethrow

2017-10-17 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Oct 17 13:57:24 2017
New Revision: 316030

URL: http://llvm.org/viewvc/llvm-project?rev=316030&view=rev
Log:
[CFG] Relax Wexceptions warning on rethrow 

As reported here: https://bugs.llvm.org/show_bug.cgi?id=34973

"catch(...)" should catch EVERYTHING, even a rethrow. This
patch changes the order in which things are checked to ensure
that a '...' catch will get a rethrow.

Differential Revision: https://reviews.llvm.org/D39013

Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=316030&r1=316029&r2=316030&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Oct 17 13:57:24 2017
@@ -289,14 +289,14 @@ enum ThrowState {
 
 static bool isThrowCaught(const CXXThrowExpr *Throw,
   const CXXCatchStmt *Catch) {
+  const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+  if (!CaughtType)
+return true;
   const Type *ThrowType = nullptr;
   if (Throw->getSubExpr())
 ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
   if (!ThrowType)
 return false;
-  const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
-  if (!CaughtType)
-return true;
   if (ThrowType->isReferenceType())
 ThrowType = ThrowType->castAs()
 ->getPointeeType()

Modified: cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp?rev=316030&r1=316029&r2=316030&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp Tue Oct 17 13:57:24 
2017
@@ -239,13 +239,30 @@ void n_ShouldNotDiag() noexcept {
   } catch (const S &s) {
   }
 }
-void o_ShouldDiag() noexcept { //expected-note {{function declared 
non-throwing here}}
+// As seen in p34973, this should not throw the warning.  If there is an active
+// exception, catch(...) catches everything. 
+void o_ShouldNotDiag() noexcept {
   try {
-throw; //expected-warning {{has a non-throwing exception specification 
but}}
+throw;
   } catch (...) {
   }
 }
 
+void p_ShouldDiag() noexcept { //expected-note {{function declared 
non-throwing here}}
+  try {
+throw; //expected-warning {{has a non-throwing exception specification 
but}}
+  } catch (int){
+  }
+}
+
+void q_ShouldNotDiag() noexcept {
+  try {
+throw;
+  } catch (int){
+  } catch (...){
+  }
+}
+
 #define NOEXCEPT noexcept
 void with_macro() NOEXCEPT { //expected-note {{function declared non-throwing 
here}}
   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}


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


r316132 - Fix capitalization of parameter

2017-10-18 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Oct 18 15:17:16 2017
New Revision: 316132

URL: http://llvm.org/viewvc/llvm-project?rev=316132&view=rev
Log:
Fix capitalization of parameter

The .cpp file has this properly capitalized, but 
the header does not.  Simply fixed it.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=316132&r1=316131&r2=316132&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Oct 18 15:17:16 2017
@@ -2229,7 +2229,7 @@ public:
   getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const;
 
   /// \brief Retrieves the default calling convention for the current target.
-  CallingConv getDefaultCallingConvention(bool isVariadic,
+  CallingConv getDefaultCallingConvention(bool IsVariadic,
   bool IsCXXMethod) const;
 
   /// \brief Retrieves the "canonical" template name that refers to a


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


r316166 - Fix nodiscard for volatile references

2017-10-19 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Oct 19 08:58:58 2017
New Revision: 316166

URL: http://llvm.org/viewvc/llvm-project?rev=316166&view=rev
Log:
Fix nodiscard for volatile references

As reported here https://bugs.llvm.org/show_bug.cgi?id=34988
[[nodiscard]] warnings were not being suppressed for
volatile-ref return values.

Differential Revision: https://reviews.llvm.org/D39075

Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=316166&r1=316165&r2=316166&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Oct 19 08:58:58 2017
@@ -2298,7 +2298,8 @@ bool Expr::isUnusedResultAWarning(const
 const DeclRefExpr *DRE =
 dyn_cast(CE->getSubExpr()->IgnoreParens());
 if (!(DRE && isa(DRE->getDecl()) &&
-  cast(DRE->getDecl())->hasLocalStorage())) {
+  cast(DRE->getDecl())->hasLocalStorage()) &&
+!isa(CE->getSubExpr()->IgnoreParens())) {
   return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc,
   R1, R2, Ctx);
 }

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp?rev=316166&r1=316165&r2=316166&view=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp Thu Oct 19 
08:58:58 2017
@@ -9,21 +9,33 @@ enum [[nodiscard]] E {};
 E get_e();
 
 [[nodiscard]] int get_i();
+[[nodiscard]] volatile int &get_vi();
 
 void f() {
   get_s(); // expected-warning {{ignoring return value of function declared 
with 'nodiscard' attribute}}
   get_i(); // expected-warning {{ignoring return value of function declared 
with 'nodiscard' attribute}}
+  get_vi(); // expected-warning {{ignoring return value of function declared 
with 'nodiscard' attribute}}
   get_e(); // expected-warning {{ignoring return value of function declared 
with 'nodiscard' attribute}}
 
   // Okay, warnings are not encouraged
   get_s_ref();
   (void)get_s();
   (void)get_i();
+  (void)get_vi();
   (void)get_e();
 }
 
+[[nodiscard]] volatile char &(*fp)();
+void g() {
+  fp(); // expected-warning {{ignoring return value of function declared with 
'nodiscard' attribute}}
+
+  // OK, warning suppressed.
+  (void)fp();
+}
 #ifdef EXT
 // expected-warning@4 {{use of the 'nodiscard' attribute is a C++17 extension}}
 // expected-warning@8 {{use of the 'nodiscard' attribute is a C++17 extension}}
 // expected-warning@11 {{use of the 'nodiscard' attribute is a C++17 
extension}}
+// expected-warning@12 {{use of the 'nodiscard' attribute is a C++17 
extension}}
+// expected-warning@28 {{use of the 'nodiscard' attribute is a C++17 
extension}}
 #endif


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


r316225 - Allow /showIncludes with /P

2017-10-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Oct 20 12:18:30 2017
New Revision: 316225

URL: http://llvm.org/viewvc/llvm-project?rev=316225&view=rev
Log:
Allow /showIncludes with /P

r213589 was checked in as a solution to
https://bugs.llvm.org/show_bug.cgi?id=20336.

However, it is possible to use /EP with /P
to suppress #line directives AND output to
a file. There is no reason in that case to
suppress /showIncludes.

This was reported here:
https://bugs.llvm.org/show_bug.cgi?id=34997

Differential Revision: https://reviews.llvm.org/D39104


Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=316225&r1=316224&r2=316225&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Oct 20 12:18:30 2017
@@ -4873,7 +4873,9 @@ void Clang::AddClangCLArgs(const ArgList
 
   // Both /showIncludes and /E (and /EP) write to stdout. Allowing both
   // would produce interleaved output, so ignore /showIncludes in such cases.
-  if (!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP))
+  if ((!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) ||
+  (Args.hasArg(options::OPT__SLASH_P) &&
+   Args.hasArg(options::OPT__SLASH_EP) && !Args.hasArg(options::OPT_E)))
 if (Arg *A = Args.getLastArg(options::OPT_show_includes))
   A->render(Args, CmdArgs);
 

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=316225&r1=316224&r2=316225&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Fri Oct 20 12:18:30 2017
@@ -197,8 +197,12 @@
 
 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E %s
 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E %s
+// RUN: %clang_cl /E /EP /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E %s
 // showIncludes_E: warning: argument unused during compilation: 
'--show-includes'
 
+// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E_And_P %s
+// showIncludes_E_And_P-NOT: warning: argument unused during compilation: 
'--show-includes'
+
 // /source-charset: should warn on everything except UTF-8.
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck 
-check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16'


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


r316338 - Pull X86 "CPUKind" checking into .cpp file. [NFC]

2017-10-23 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Oct 23 09:20:15 2017
New Revision: 316338

URL: http://llvm.org/viewvc/llvm-project?rev=316338&view=rev
Log:
Pull X86 "CPUKind" checking into .cpp file. [NFC]

Preparing to do a refactor of CPU/feature checking, this
patch pulls the one CPU implementation from the .h file
to the .cpp file.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=316338&r1=316337&r2=316338&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Mon Oct 23 09:20:15 2017
@@ -1522,6 +1522,78 @@ std::string X86TargetInfo::convertConstr
   }
 }
 
+bool X86TargetInfo::checkCPUKind(CPUKind Kind) const {
+  // Perform any per-CPU checks necessary to determine if this CPU is
+  // acceptable.
+  // FIXME: This results in terrible diagnostics. Clang just says the CPU is
+  // invalid without explaining *why*.
+  switch (Kind) {
+  case CK_Generic:
+// No processor selected!
+return false;
+
+  case CK_i386:
+  case CK_i486:
+  case CK_WinChipC6:
+  case CK_WinChip2:
+  case CK_C3:
+  case CK_i586:
+  case CK_Pentium:
+  case CK_PentiumMMX:
+  case CK_i686:
+  case CK_PentiumPro:
+  case CK_Pentium2:
+  case CK_Pentium3:
+  case CK_PentiumM:
+  case CK_Yonah:
+  case CK_C3_2:
+  case CK_Pentium4:
+  case CK_Lakemont:
+  case CK_Prescott:
+  case CK_K6:
+  case CK_K6_2:
+  case CK_K6_3:
+  case CK_Athlon:
+  case CK_AthlonXP:
+  case CK_Geode:
+// Only accept certain architectures when compiling in 32-bit mode.
+if (getTriple().getArch() != llvm::Triple::x86)
+  return false;
+
+LLVM_FALLTHROUGH;
+  case CK_Nocona:
+  case CK_Core2:
+  case CK_Penryn:
+  case CK_Bonnell:
+  case CK_Silvermont:
+  case CK_Goldmont:
+  case CK_Nehalem:
+  case CK_Westmere:
+  case CK_SandyBridge:
+  case CK_IvyBridge:
+  case CK_Haswell:
+  case CK_Broadwell:
+  case CK_SkylakeClient:
+  case CK_SkylakeServer:
+  case CK_Cannonlake:
+  case CK_KNL:
+  case CK_KNM:
+  case CK_K8:
+  case CK_K8SSE3:
+  case CK_AMDFAM10:
+  case CK_BTVER1:
+  case CK_BTVER2:
+  case CK_BDVER1:
+  case CK_BDVER2:
+  case CK_BDVER3:
+  case CK_BDVER4:
+  case CK_ZNVER1:
+  case CK_x86_64:
+return true;
+  }
+  llvm_unreachable("Unhandled CPU kind");
+}
+
 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
   return llvm::StringSwitch(CPU)
   .Case("i386", CK_i386)

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=316338&r1=316337&r2=316338&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Mon Oct 23 09:20:15 2017
@@ -270,77 +270,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetI
 //@}
   } CPU = CK_Generic;
 
-  bool checkCPUKind(CPUKind Kind) const {
-// Perform any per-CPU checks necessary to determine if this CPU is
-// acceptable.
-// FIXME: This results in terrible diagnostics. Clang just says the CPU is
-// invalid without explaining *why*.
-switch (Kind) {
-case CK_Generic:
-  // No processor selected!
-  return false;
-
-case CK_i386:
-case CK_i486:
-case CK_WinChipC6:
-case CK_WinChip2:
-case CK_C3:
-case CK_i586:
-case CK_Pentium:
-case CK_PentiumMMX:
-case CK_i686:
-case CK_PentiumPro:
-case CK_Pentium2:
-case CK_Pentium3:
-case CK_PentiumM:
-case CK_Yonah:
-case CK_C3_2:
-case CK_Pentium4:
-case CK_Lakemont:
-case CK_Prescott:
-case CK_K6:
-case CK_K6_2:
-case CK_K6_3:
-case CK_Athlon:
-case CK_AthlonXP:
-case CK_Geode:
-  // Only accept certain architectures when compiling in 32-bit mode.
-  if (getTriple().getArch() != llvm::Triple::x86)
-return false;
-
-  LLVM_FALLTHROUGH;
-case CK_Nocona:
-case CK_Core2:
-case CK_Penryn:
-case CK_Bonnell:
-case CK_Silvermont:
-case CK_Goldmont:
-case CK_Nehalem:
-case CK_Westmere:
-case CK_SandyBridge:
-case CK_IvyBridge:
-case CK_Haswell:
-case CK_Broadwell:
-case CK_SkylakeClient:
-case CK_SkylakeServer:
-case CK_Cannonlake:
-case CK_KNL:
-case CK_KNM:
-case CK_K8:
-case CK_K8SSE3:
-case CK_AMDFAM10:
-case CK_BTVER1:
-case CK_BTVER2:
-case CK_BDVER1:
-case CK_BDVER2:
-case CK_BDVER3:
-case CK_BDVER4:
-case CK_ZNVER1:
-case CK_x86_64:
-  return true;
-}
-llvm_unreachable("Unhandled CPU kind");
-  }
+  bool checkCPUKind(CPUKind Kind) const;
 
   CPUKind getCPUKind(StringRef CPU) const;
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.ll

r316405 - Fix template parameter default args missed if redecled

2017-10-23 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Oct 23 18:39:56 2017
New Revision: 316405

URL: http://llvm.org/viewvc/llvm-project?rev=316405&view=rev
Log:
Fix template parameter default args missed if redecled

This bug was found via self-build on lld, and worked around
here: https://reviews.llvm.org/rL316180

The issue is that the 'using' causes the lookup to pick up the
first decl. However, when setting inherited default parameters,
we only update 'forward', not 'backward'. SO, only the newest param
list has all the information about the default arguments.

This patch ensures that the list of parameters we look through checks
the newest decl's template parameter list so it doesn't miss a default.

Differential Revision: https://reviews.llvm.org/D39127

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=316405&r1=316404&r2=316405&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Oct 23 18:39:56 2017
@@ -4805,7 +4805,12 @@ bool Sema::CheckTemplateArgumentList(
   // template.
   TemplateArgumentListInfo NewArgs = TemplateArgs;
 
-  TemplateParameterList *Params = Template->getTemplateParameters();
+  // Make sure we get the template parameter list from the most
+  // recentdeclaration, since that is the only one that has is guaranteed to
+  // have all the default template argument information.
+  TemplateParameterList *Params =
+  cast(Template->getMostRecentDecl())
+  ->getTemplateParameters();
 
   SourceLocation RAngleLoc = NewArgs.getRAngleLoc();
 


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


r316437 - Add Forgotten test for: Fix template parameter default args missed if redecled

2017-10-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Oct 24 06:51:07 2017
New Revision: 316437

URL: http://llvm.org/viewvc/llvm-project?rev=316437&view=rev
Log:
Add Forgotten test for: Fix template parameter default args missed if redecled

Addendum to differential revision: https://reviews.llvm.org/D39127

Added:
cfe/trunk/test/SemaCXX/template-default-param-through-using.cpp

Added: cfe/trunk/test/SemaCXX/template-default-param-through-using.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/template-default-param-through-using.cpp?rev=316437&view=auto
==
--- cfe/trunk/test/SemaCXX/template-default-param-through-using.cpp (added)
+++ cfe/trunk/test/SemaCXX/template-default-param-through-using.cpp Tue Oct 24 
06:51:07 2017
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+namespace llvm {
+  template struct StringSet;
+  template struct Int;
+  template  class Outer>
+struct TemplTempl;
+}
+
+namespace lld {
+  using llvm::StringSet;
+  using llvm::Int;
+  using llvm::TemplTempl;
+};
+
+namespace llvm {
+  template struct StringSet;
+}
+
+template struct Temp{};
+
+namespace llvm {
+  template struct StringSet{};
+  template struct Int{};
+  template  class Outer = Temp>
+struct TemplTempl{};
+};
+
+namespace lld {
+  StringSet<> s;
+  Int<> i;
+  TemplTempl tt;
+}


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


r316447 - Fix spelling in comment, field is isMsStruct, not Strust

2017-10-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Oct 24 08:34:59 2017
New Revision: 316447

URL: http://llvm.org/viewvc/llvm-project?rev=316447&view=rev
Log:
Fix spelling in comment, field is isMsStruct, not Strust

Modified:
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=316447&r1=316446&r2=316447&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 24 08:34:59 2017
@@ -3540,7 +3540,7 @@ public:
 return K >= firstRecord && K <= lastRecord;
   }
 
-  /// isMsStrust - Get whether or not this is an ms_struct which can
+  /// isMsStruct - Get whether or not this is an ms_struct which can
   /// be turned on with an attribute, pragma, or -mms-bitfields
   /// commandline option.
   bool isMsStruct(const ASTContext &C) const;


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


r316453 - Remove repeated function name in doxygen comment.

2017-10-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Oct 24 09:16:34 2017
New Revision: 316453

URL: http://llvm.org/viewvc/llvm-project?rev=316453&view=rev
Log:
Remove repeated function name in doxygen comment.

Modified:
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=316453&r1=316452&r2=316453&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 24 09:16:34 2017
@@ -3540,7 +3540,7 @@ public:
 return K >= firstRecord && K <= lastRecord;
   }
 
-  /// isMsStruct - Get whether or not this is an ms_struct which can
+  /// \brief Get whether or not this is an ms_struct which can
   /// be turned on with an attribute, pragma, or -mms-bitfields
   /// commandline option.
   bool isMsStruct(const ASTContext &C) const;


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


r316518 - mplement __has_unique_object_representations

2017-10-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Oct 24 14:31:50 2017
New Revision: 316518

URL: http://llvm.org/viewvc/llvm-project?rev=316518&view=rev
Log:
mplement __has_unique_object_representations

A helper builtin to facilitate implementing the
std::has_unique_object_representations type trait.

Requested here: https://bugs.llvm.org/show_bug.cgi?id=34942
Also already exists in GCC and MSVC.

Differential Revision: https://reviews.llvm.org/D39064

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Basic/TypeTraits.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=316518&r1=316517&r2=316518&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Oct 24 14:31:50 2017
@@ -770,6 +770,10 @@ public:
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext &Context) const;
 
+  /// Return true if this has unique object representations according to (C++17
+  /// [meta.unary.prop]p9)
+  bool hasUniqueObjectRepresentations(const ASTContext &Context) const;
+
   // Don't promise in the API that anything besides 'const' can be
   // easily added.
 
@@ -1114,6 +1118,8 @@ public:
   QualType getAtomicUnqualifiedType() const;
 
 private:
+  bool unionHasUniqueObjectRepresentations(const ASTContext& Context) const;
+  bool structHasUniqueObjectRepresentations(const ASTContext& Context) const;
   // These methods are implemented in a separate translation unit;
   // "static"-ize them to avoid creating temporary QualTypes in the
   // caller.

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=316518&r1=316517&r2=316518&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Oct 24 14:31:50 2017
@@ -455,6 +455,8 @@ TYPE_TRAIT_1(__is_pod, IsPOD, KEYCXX)
 TYPE_TRAIT_1(__is_polymorphic, IsPolymorphic, KEYCXX)
 TYPE_TRAIT_1(__is_trivial, IsTrivial, KEYCXX)
 TYPE_TRAIT_1(__is_union, IsUnion, KEYCXX)
+TYPE_TRAIT_1(__has_unique_object_representations,
+ HasUniqueObjectRepresentations, KEYCXX)
 
 // Clang-only C++ Type Traits
 TYPE_TRAIT_N(__is_trivially_constructible, IsTriviallyConstructible, KEYCXX)

Modified: cfe/trunk/include/clang/Basic/TypeTraits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TypeTraits.h?rev=316518&r1=316517&r2=316518&view=diff
==
--- cfe/trunk/include/clang/Basic/TypeTraits.h (original)
+++ cfe/trunk/include/clang/Basic/TypeTraits.h Tue Oct 24 14:31:50 2017
@@ -70,7 +70,8 @@ namespace clang {
 UTT_IsUnsigned,
 UTT_IsVoid,
 UTT_IsVolatile,
-UTT_Last = UTT_IsVolatile,
+UTT_HasUniqueObjectRepresentations,
+UTT_Last = UTT_HasUniqueObjectRepresentations,
 BTT_IsBaseOf,
 BTT_IsConvertible,
 BTT_IsConvertibleTo,

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=316518&r1=316517&r2=316518&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Oct 24 14:31:50 2017
@@ -2166,6 +2166,152 @@ bool QualType::isTriviallyCopyableType(c
   return false;
 }
 
+bool QualType::unionHasUniqueObjectRepresentations(
+const ASTContext &Context) const {
+  assert((*this)->isUnionType() && "must be union type");
+  CharUnits UnionSize = Context.getTypeSizeInChars(*this);
+  const RecordDecl *Union = getTypePtr()->getAs()->getDecl();
+
+  for (const auto *Field : Union->fields()) {
+if (!Field->getType().hasUniqueObjectRepresentations(Context))
+  return false;
+CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
+if (FieldSize != UnionSize)
+  return false;
+  }
+  return true;
+}
+
+bool isStructEmpty(QualType Ty) {
+  assert(Ty.getTypePtr()->isStructureOrClassType() &&
+ "Must be struct or class");
+  const RecordDecl *RD = Ty.getTypePtr()->getAs()->getDecl();
+
+  if (!RD->field_empty())
+return false;
+
+  if (const CXXRecordDecl *ClassDecl = dyn_cast(RD)) {
+return ClassDecl->isEmpty();
+  }
+
+  return true;
+}
+
+bool QualType::structHasUniqueObjectRepresentations(
+const ASTContext &Context) const {
+  assert((*this)->isStructureOrClassType() && "Must be struct or class");
+  const RecordDecl *RD = getTypePtr()->getAs()->getDecl();
+

r316521 - Replaced unicode characters with ASCII, as introduced in r316518.

2017-10-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Oct 24 15:00:25 2017
New Revision: 316521

URL: http://llvm.org/viewvc/llvm-project?rev=316521&view=rev
Log:
Replaced unicode characters with ASCII, as introduced in r316518.

Modified:
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=316521&r1=316520&r2=316521&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Oct 24 15:00:25 2017
@@ -2260,8 +2260,8 @@ bool QualType::hasUniqueObjectRepresenta
   //   The predicate condition for a template specialization
   //   has_unique_object_representations shall be
   //   satisfied if and only if:
-  // (9.1) — T is trivially copyable, and
-  // (9.2) — any two objects of type T with the same value have the same
+  // (9.1) - T is trivially copyable, and
+  // (9.2) - any two objects of type T with the same value have the same
   // object representation, where two objects
   //   of array or non-union class type are considered to have the same value
   //   if their respective sequences of
@@ -2272,8 +2272,7 @@ bool QualType::hasUniqueObjectRepresenta
   //   The set of scalar types for which this condition holds is
   //   implementation-defined. [ Note: If a type has padding
   //   bits, the condition does not hold; otherwise, the condition holds true
-  //   for unsigned integral types. — end
-  //   note ]
+  //   for unsigned integral types. -- end note ]
   if (isNull())
 return false;
 
@@ -2282,7 +2281,7 @@ bool QualType::hasUniqueObjectRepresenta
 return Context.getBaseElementType(*this).hasUniqueObjectRepresentations(
 Context);
 
-  // (9.1) — T is trivially copyable, and
+  // (9.1) - T is trivially copyable, and
   if (!isTriviallyCopyableType(Context))
 return false;
 


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


r316528 - Correct behavior of fastcall when default CC is set.

2017-10-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Oct 24 16:12:01 2017
New Revision: 316528

URL: http://llvm.org/viewvc/llvm-project?rev=316528&view=rev
Log:
Correct behavior of fastcall when default CC is set.

Fastcall doesn't support variadic function calls, so
setting the default calling convention to Fastcall would
result in incorrect code being emitted for these conditions.

This patch adds a 'variadic' test to the default calling conv
test, as well as fixes the behavior of fastcall.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=316528&r1=316527&r2=316528&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Oct 24 16:12:01 2017
@@ -9269,7 +9269,7 @@ CallingConv ASTContext::getDefaultCallin
   case LangOptions::DCC_CDecl:
 return CC_C;
   case LangOptions::DCC_FastCall:
-if (getTargetInfo().hasFeature("sse2"))
+if (getTargetInfo().hasFeature("sse2") && !IsVariadic)
   return CC_X86FastCall;
 break;
   case LangOptions::DCC_StdCall:

Modified: cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp?rev=316528&r1=316527&r2=316528&view=diff
==
--- cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp Tue Oct 24 16:12:01 2017
@@ -10,6 +10,13 @@
 // VECTORCALL: define x86_vectorcallcc void @_Z5test1v
 void test1() {}
 
+// fastcall, stdcall, and vectorcall all do not support variadic functions.
+// CDECL: define void @_Z12testVariadicz
+// FASTCALL: define void @_Z12testVariadicz
+// STDCALL: define void @_Z12testVariadicz
+// VECTORCALL: define void @_Z12testVariadicz
+void testVariadic(...){}
+
 // ALL: define void @_Z5test2v
 void __attribute__((cdecl)) test2() {}
 


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


r341484 - Test Commit for git-svn-cleanup comment.

2018-09-05 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Sep  5 10:14:21 2018
New Revision: 341484

URL: http://llvm.org/viewvc/llvm-project?rev=341484&view=rev
Log:
Test Commit for git-svn-cleanup comment.

Removes the class name for the Expr class, which isn't necessary.

Modified:
cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=341484&r1=341483&r2=341484&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Sep  5 10:14:21 2018
@@ -99,10 +99,9 @@ struct SubobjectAdjustment {
   }
 };
 
-/// Expr - This represents one expression.  Note that Expr's are subclasses of
-/// Stmt.  This allows an expression to be transparently used any place a Stmt
-/// is required.
-///
+/// This represents one expression.  Note that Expr's are subclasses of Stmt.
+/// This allows an expression to be transparently used any place a Stmt is
+/// required.
 class Expr : public Stmt {
   QualType TR;
 


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


r341833 - Prevent cpu-specific/cpu-dispatch from giong on a lambda.

2018-09-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Sep 10 07:31:56 2018
New Revision: 341833

URL: http://llvm.org/viewvc/llvm-project?rev=341833&view=rev
Log:
Prevent cpu-specific/cpu-dispatch from giong on a lambda.

It is non-sensical to use cpu-specific/cpu-dispatch multiversioning
on a lambda, so prevent it when trying to add the attribute.

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=341833&r1=341832&r2=341833&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Sep 10 07:31:56 2018
@@ -1842,6 +1842,14 @@ static void handleRestrictAttr(Sema &S,
 
 static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   FunctionDecl *FD = cast(D);
+
+  if (const auto *MD = dyn_cast(D)) {
+if (MD->getParent()->isLambda()) {
+  S.Diag(AL.getLoc(), diag::err_attribute_dll_lambda) << AL;
+  return;
+}
+  }
+
   if (!checkAttributeAtLeastNumArgs(S, AL, 1))
 return;
 

Modified: cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp?rev=341833&r1=341832&r2=341833&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp Mon Sep 10 07:31:56 2018
@@ -109,3 +109,6 @@ int __attribute__((cpu_specific(sandybri
 
 // Ensure Cpp Spelling works.
 [[clang::cpu_specific(ivybridge,atom)]] int CppSpelling(){}
+
+// expected-error@+1 {{lambda cannot be declared 'cpu_dispatch'}}
+auto x = []() __attribute__((cpu_dispatch(atom))) {};


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


r341862 - Move AESNI generation to Skylake and Goldmont

2018-09-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Sep 10 14:12:21 2018
New Revision: 341862

URL: http://llvm.org/viewvc/llvm-project?rev=341862&view=rev
Log:
Move AESNI generation to Skylake and Goldmont

The instruction set first appeared with Westmere, but not all processors
in that and the next few generations have the instructions. According to
Wikipedia[1], the first generation in which all SKUs have AES
instructions are Skylake and Goldmont. I can't find any Skylake,
Kabylake, Kabylake-R or Cannon Lake currently listed at
https://ark.intel.com that says "Intel® AES New Instructions" "No".

This matches GCC commit
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01940.html

[1] https://en.wikipedia.org/wiki/AES_instruction_set

Patch By: thiagomacieira
Differential Revision: https://reviews.llvm.org/D51510

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=341862&r1=341861&r2=341862&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Mon Sep 10 14:12:21 2018
@@ -170,6 +170,7 @@ bool X86TargetInfo::initFeatureMap(
   setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
 setFeatureEnabledImpl(Features, "rtm", true);
+setFeatureEnabledImpl(Features, "aes", true);
 LLVM_FALLTHROUGH;
   case CK_Broadwell:
 setFeatureEnabledImpl(Features, "rdseed", true);
@@ -196,7 +197,6 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "xsaveopt", true);
 LLVM_FALLTHROUGH;
   case CK_Westmere:
-setFeatureEnabledImpl(Features, "aes", true);
 setFeatureEnabledImpl(Features, "pclmul", true);
 LLVM_FALLTHROUGH;
   case CK_Nehalem:
@@ -248,10 +248,10 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "clflushopt", true);
 setFeatureEnabledImpl(Features, "mpx", true);
 setFeatureEnabledImpl(Features, "fsgsbase", true);
+setFeatureEnabledImpl(Features, "aes", true);
 LLVM_FALLTHROUGH;
   case CK_Silvermont:
 setFeatureEnabledImpl(Features, "rdrnd", true);
-setFeatureEnabledImpl(Features, "aes", true);
 setFeatureEnabledImpl(Features, "pclmul", true);
 setFeatureEnabledImpl(Features, "sse4.2", true);
 setFeatureEnabledImpl(Features, "prfchw", true);


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


r341871 - Fix test regression in r341862

2018-09-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Sep 10 14:57:53 2018
New Revision: 341871

URL: http://llvm.org/viewvc/llvm-project?rev=341871&view=rev
Log:
Fix test regression in r341862

The commit updates when AES is enabled, but failed to update the tests.
This patch fixes them.

Modified:
cfe/trunk/test/CodeGen/attr-target-x86.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/test/CodeGen/attr-target-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=341871&r1=341870&r2=341871&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-x86.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-x86.c Mon Sep 10 14:57:53 2018
@@ -49,7 +49,7 @@ int __attribute__((target("arch=lakemont
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
 // CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+x87"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
 // CHECK: #2 = {{.*}}"target-cpu"="i686" 
"target-features"="+x87,-aes,-avx,-avx2,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vpopcntdq,-f16c,-fma,-fma4,-gfni,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-xop,-xsave,-xsaveopt"
 // CHECK: #3 = {{.*}}"target-cpu"="i686" 
"target-features"="+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 // CHECK: #4 = {{.*}}"target-cpu"="i686" 
"target-features"="+x87,-avx,-avx2,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vpopcntdq,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop,-xsave,-xsaveopt"

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=341871&r1=341870&r2=341871&view=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Mon Sep 10 14:57:53 
2018
@@ -417,7 +417,6 @@
 // RUN: %clang -march=corei7-avx -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M32
-// CHECK_COREI7_AVX_M32: #define __AES__ 1
 // CHECK_COREI7_AVX_M32: #define __AVX__ 1
 // CHECK_COREI7_AVX_M32: #define __MMX__ 1
 // CHECK_COREI7_AVX_M32: #define __PCLMUL__ 1
@@ -441,7 +440,6 @@
 // RUN: %clang -march=corei7-avx -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M64
-// CHECK_COREI7_AVX_M64: #define __AES__ 1
 // CHECK_COREI7_AVX_M64: #define __AVX__ 1
 // CHECK_COREI7_AVX_M64: #define __MMX__ 1
 // CHECK_COREI7_AVX_M64: #define __PCLMUL__ 1
@@ -468,7 +466,6 @@
 // RUN: %clang -march=core-avx-i -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE_AVX_I_M32
-// CHECK_CORE_AVX_I_M32: #define __AES__ 1
 // CHECK_CORE_AVX_I_M32: #define __AVX__ 1
 // CHECK_CORE_AVX_I_M32: #define __F16C__ 1
 // CHECK_CORE_AVX_I_M32: #define __MMX__ 1
@@ -492,7 +489,6 @@
 // RUN: %clang -march=core-avx-i -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE_AVX_I_M64
-// CHECK_CORE_AVX_I_M64: #define __AES__ 1
 // CHECK_CORE_AVX_I_M64: #define __AVX__ 1
 // CHECK_CORE_AVX_I_M64: #define __F16C__ 1
 // CHECK_CORE_AVX_I_M64: #define __MMX__ 1
@@ -519,7 +515,6 @@
 // RUN: %clang -march=core-avx2 -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE_AVX2_M32
-// CHECK_CORE_AVX2_M32: #define __AES__ 1
 // CHECK_CORE_AVX2_M32: #define __AVX2__ 1
 // CHECK_CORE_AVX2_M32: #define __AVX__ 1
 // CHECK_CORE_AVX2_M32: #define __BMI2__ 1
@@ -550,7 +545,6 @@
 // RUN: %clang -march=core-avx2 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE_AVX2_M64
-// CHECK_CORE_AVX2_M64: #define __AES__ 1
 // CHECK_CORE_AVX2_M64: #define __AVX2__ 1
 // CHECK_CORE_AVX2_M64: #define __AVX__ 1
 // CHECK_CORE_AVX2_M64: #define __BMI2__ 1
@@ -585,7 +579,6 @@
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_BROADWELL_M32
 // CHECK_BROADWELL_M32: #define __ADX__ 1
-

r342152 - [NFC]Refactor MultiVersion Resolver Emission to combine types

2018-09-13 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 13 09:58:24 2018
New Revision: 342152

URL: http://llvm.org/viewvc/llvm-project?rev=342152&view=rev
Log:
[NFC]Refactor MultiVersion Resolver Emission to combine types

Previously, both types (plus the future target-clones) of
multiversioning had a separate ResolverOption structure and emission
function.  This patch combines the two, at the expense of a slightly
more expensive sorting function.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=342152&r1=342151&r2=342152&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Sep 13 09:58:24 2018
@@ -1977,6 +1977,39 @@ def Target : InheritableAttr {
   return parse(getFeaturesStr());
 }
 
+StringRef getArchitecture() const {
+  StringRef Features = getFeaturesStr();
+  if (Features == "default") return {};
+
+  SmallVector AttrFeatures;
+  Features.split(AttrFeatures, ",");
+
+  for (auto &Feature : AttrFeatures) {
+Feature = Feature.trim();
+if (Feature.startswith("arch="))
+  return Feature.drop_front(sizeof("arch=") - 1);
+  }
+  return "";
+}
+
+// Gets the list of features as simple string-refs with no +/- or 'no-'.
+// Only adds the items to 'Out' that are additions.
+void getAddedFeatures(llvm::SmallVectorImpl &Out) const {
+  StringRef Features = getFeaturesStr();
+  if (Features == "default") return;
+
+  SmallVector AttrFeatures;
+  Features.split(AttrFeatures, ",");
+
+  for (auto &Feature : AttrFeatures) {
+Feature = Feature.trim();
+
+if (!Feature.startswith("no-") && !Feature.startswith("arch=") &&
+!Feature.startswith("fpmath=") && !Feature.startswith("tune="))
+  Out.push_back(Feature);
+  }
+}
+
 template
 ParsedTargetAttr parse(Compare cmp) const {
   ParsedTargetAttr Attrs = parse();

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=342152&r1=342151&r2=342152&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Sep 13 09:58:24 2018
@@ -2363,91 +2363,53 @@ void CodeGenFunction::EmitSanitizerStatR
   CGM.getSanStats().create(IRB, SSK);
 }
 
-llvm::Value *CodeGenFunction::FormResolverCondition(
-const TargetMultiVersionResolverOption &RO) {
-  llvm::Value *TrueCondition = nullptr;
-  if (!RO.ParsedAttribute.Architecture.empty())
-TrueCondition = EmitX86CpuIs(RO.ParsedAttribute.Architecture);
-
-  if (!RO.ParsedAttribute.Features.empty()) {
-SmallVector FeatureList;
-llvm::for_each(RO.ParsedAttribute.Features,
-   [&FeatureList](const std::string &Feature) {
- FeatureList.push_back(StringRef{Feature}.substr(1));
-   });
-llvm::Value *FeatureCmp = EmitX86CpuSupports(FeatureList);
-TrueCondition = TrueCondition ? Builder.CreateAnd(TrueCondition, 
FeatureCmp)
-  : FeatureCmp;
+llvm::Value *
+CodeGenFunction::FormResolverCondition(const MultiVersionResolverOption &RO) {
+  llvm::Value *Condition = nullptr;
+
+  if (!RO.Conditions.Architecture.empty())
+Condition = EmitX86CpuIs(RO.Conditions.Architecture);
+
+  if (!RO.Conditions.Features.empty()) {
+llvm::Value *FeatureCond = EmitX86CpuSupports(RO.Conditions.Features);
+Condition =
+Condition ? Builder.CreateAnd(Condition, FeatureCond) : FeatureCond;
   }
-  return TrueCondition;
+  return Condition;
 }
 
-void CodeGenFunction::EmitTargetMultiVersionResolver(
-llvm::Function *Resolver,
-ArrayRef Options) {
+void CodeGenFunction::EmitMultiVersionResolver(
+llvm::Function *Resolver, ArrayRef Options) {
   assert((getContext().getTargetInfo().getTriple().getArch() ==
   llvm::Triple::x86 ||
   getContext().getTargetInfo().getTriple().getArch() ==
   llvm::Triple::x86_64) &&
  "Only implemented for x86 targets");
-
-  // Main function's basic block.
-  llvm::BasicBlock *CurBlock = createBasicBlock("entry", Resolver);
-  Builder.SetInsertPoint(CurBlock);
-  EmitX86CpuInit();
-
-  llvm::Function *DefaultFunc = nullptr;
-  for (const TargetMultiVersionResolverOption &RO : Options) {
-Builder.SetInsertPoint(CurBlock);
-llvm::Value *TrueCondition = FormResolverCondition(RO);
-
-if (!TrueCondition) {
-  DefaultFunc = RO.Function;
-} else {
-  llvm::BasicBlock *RetBlock = createBasicBlock("ro_ret", 

r337454 - Enable C++2a Chrono Literals

2018-07-19 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Jul 19 06:36:57 2018
New Revision: 337454

URL: http://llvm.org/viewvc/llvm-project?rev=337454&view=rev
Log:
Enable C++2a Chrono Literals

C++2a via http://wg21.link/p0355 permits the library
literals of 'd' and 'y'. This patch enables them in the
Lexer so that they can be properly parsed.

Note that 'd' gets confused with the hex character, so
modifications to how octal, binary, and decimal numbers are
parsed were required. Since this is simply making previously
invalid code legal, this should be fine.

Hex still greedily parses the 'd' as a hexit, since it would
a: violate [lex.ext]p1
b: break existing code.

Differential Revision: https://reviews.llvm.org/D49504

Added:
cfe/trunk/test/SemaCXX/cxx2a-user-defined-literals.cpp
Modified:
cfe/trunk/lib/Lex/LiteralSupport.cpp

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=337454&r1=337453&r2=337454&view=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Thu Jul 19 06:36:57 2018
@@ -751,7 +751,8 @@ void NumericLiteralParser::ParseDecimalO
 
   // If we have a hex digit other than 'e' (which denotes a FP exponent) then
   // the code is using an incorrect base.
-  if (isHexDigit(*s) && *s != 'e' && *s != 'E') {
+  if (isHexDigit(*s) && *s != 'e' && *s != 'E' &&
+  !isValidUDSuffix(PP.getLangOpts(), StringRef(s, ThisTokEnd - s))) {
 PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
 diag::err_invalid_digit) << StringRef(s, 1) << (radix == 8 ? 1 : 
0);
 hadError = true;
@@ -804,12 +805,14 @@ bool NumericLiteralParser::isValidUDSuff
   if (!LangOpts.CPlusPlus14)
 return false;
 
-  // In C++1y, "s", "h", "min", "ms", "us", and "ns" are used in the library.
+  // In C++14, "s", "h", "min", "ms", "us", and "ns" are used in the library.
   // Per tweaked N3660, "il", "i", and "if" are also used in the library.
+  // In C++2a "d" and "y" are used in the library.
   return llvm::StringSwitch(Suffix)
   .Cases("h", "min", "s", true)
   .Cases("ms", "us", "ns", true)
   .Cases("il", "i", "if", true)
+  .Cases("d", "y", LangOpts.CPlusPlus2a)
   .Default(false);
 }
 
@@ -922,7 +925,9 @@ void NumericLiteralParser::ParseNumberSt
 s = SkipBinaryDigits(s);
 if (s == ThisTokEnd) {
   // Done.
-} else if (isHexDigit(*s)) {
+} else if (isHexDigit(*s) &&
+   !isValidUDSuffix(PP.getLangOpts(),
+StringRef(s, ThisTokEnd - s))) {
   PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
   diag::err_invalid_digit) << StringRef(s, 1) << 2;
   hadError = true;

Added: cfe/trunk/test/SemaCXX/cxx2a-user-defined-literals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-user-defined-literals.cpp?rev=337454&view=auto
==
--- cfe/trunk/test/SemaCXX/cxx2a-user-defined-literals.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx2a-user-defined-literals.cpp Thu Jul 19 06:36:57 
2018
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++2a %s -include %s -verify
+
+#ifndef INCLUDED
+#define INCLUDED
+
+#pragma clang system_header
+namespace std {
+  namespace chrono {
+struct day{};
+struct year{};
+  }
+  constexpr chrono::day operator"" d(unsigned long long d) noexcept;
+  constexpr chrono::year operator"" y(unsigned long long y) noexcept;
+}
+
+#else
+
+using namespace std;
+chrono::day dec_d = 5d;
+chrono::day oct_d = 05d;
+chrono::day bin_d = 0b011d;
+// expected-error@+3{{no viable conversion from 'int' to 'chrono::day'}}
+// expected-note@9{{candidate constructor (the implicit copy constructor)}}
+// expected-note@9{{candidate constructor (the implicit move constructor)}}
+chrono::day hex_d = 0x44d;
+chrono::year y  = 10y;
+#endif


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


r337473 - Fix unused variable warning.

2018-07-19 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Jul 19 10:19:16 2018
New Revision: 337473

URL: http://llvm.org/viewvc/llvm-project?rev=337473&view=rev
Log:
Fix unused variable warning.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=337473&r1=337472&r2=337473&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jul 19 10:19:16 2018
@@ -6932,7 +6932,7 @@ private:
 bool IsExpressionFirstInfo = true;
 Address BP = Address::invalid();
 
-if (const auto *ME = dyn_cast(I->getAssociatedExpression())) {
+if (isa(I->getAssociatedExpression())) {
   // The base is the 'this' pointer. The content of the pointer is going
   // to be the base of the field being mapped.
   BP = CGF.LoadCXXThisAddress();


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


r337552 - Implement cpu_dispatch/cpu_specific Multiversioning

2018-07-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jul 20 07:13:28 2018
New Revision: 337552

URL: http://llvm.org/viewvc/llvm-project?rev=337552&view=rev
Log:
Implement cpu_dispatch/cpu_specific Multiversioning

As documented here: https://software.intel.com/en-us/node/682969 and
https://software.intel.com/en-us/node/523346. cpu_dispatch multiversioning
is an ICC feature that provides for function multiversioning.

This feature is implemented with two attributes: First, cpu_specific,
which specifies the individual function versions. Second, cpu_dispatch,
which specifies the location of the resolver function and the list of
resolvable functions.

This is valuable since it provides a mechanism where the resolver's TU
can be specified in one location, and the individual implementions
each in their own translation units.

The goal of this patch is to be source-compatible with ICC, so this
implementation diverges from the ICC implementation in a few ways:
1- Linux x86/64 only: This implementation uses ifuncs in order to
properly dispatch functions. This is is a valuable performance benefit
over the ICC implementation. A future patch will be provided to enable
this feature on Windows, but it will obviously more closely fit ICC's
implementation.
2- CPU Identification functions: ICC uses a set of custom functions to identify
the feature list of the host processor. This patch uses the cpu_supports
functionality in order to better align with 'target' multiversioning.
1- cpu_dispatch function def/decl: ICC's cpu_dispatch requires that the function
marked cpu_dispatch be an empty definition. This patch supports that as well,
however declarations are also permitted, since the linker will solve the
issue of multiple emissions.

Differential Revision: https://reviews.llvm.org/D47474

Added:
cfe/trunk/test/CodeGen/attr-cpuspecific.c
cfe/trunk/test/Sema/attr-cpuspecific.c
cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Basic/X86Target.def
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=337552&r1=337551&r2=337552&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Jul 20 07:13:28 2018
@@ -2209,6 +2209,13 @@ public:
 getCanonicalDecl()->IsMultiVersion = V;
   }
 
+  /// True if this function is a multiversioned dispatch function as a part of
+  /// the cpu_specific/cpu_dispatch functionality.
+  bool isCPUDispatchMultiVersion() const;
+  /// True if this function is a multiversioned processor specific function as 
a
+  /// part of the cpu_specific/cpu_dispatch functionality.
+  bool isCPUSpecificMultiVersion() const;
+
   void setPreviousDeclaration(FunctionDecl * PrevDecl);
 
   FunctionDecl *getCanonicalDecl() override;

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=337552&r1=337551&r2=337552&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Jul 20 07:13:28 2018
@@ -168,6 +168,7 @@ class UnsignedArgument : Argument;
 class VariadicExprArgument : Argument;
 class VariadicStringArgument : Argument;
+class VariadicIdentifierArgument : Argument;
 
 // Like VariadicUnsignedArgument except values are ParamIdx.
 class VariadicParamIdxArgument : Argument;
@@ -845,6 +846,27 @@ def Constructor : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def CPUSpecific : InheritableAttr {
+  let Spellings = [Clang<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [CPUSpecificCPUDispatchDocs];
+  let AdditionalMembers = [{
+unsigned ActiveArgIndex = 0;
+
+IdentifierInfo *getCurCPUName() const {
+ 

r337585 - Prevent Scoped Enums from being Integral constant expressions:

2018-07-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jul 20 10:42:09 2018
New Revision: 337585

URL: http://llvm.org/viewvc/llvm-project?rev=337585&view=rev
Log:
Prevent Scoped Enums from being Integral constant expressions:

Discovered because of: https://bugs.llvm.org/show_bug.cgi?id=38235

It seems to me that a scoped enum should NOT be an integral constant expression
without a cast, so this seems like a sensical change.

Attributes that check for an integer parameter simply use this function to
ensure that they have an integer, so it was previously allowing a scoped enum.

Also added a test based on Richard's feedback to ensure that case labels still 
work.

Differential Revision: https://reviews.llvm.org/D49599

Added:
cfe/trunk/test/SemaCXX/PR38235.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=337585&r1=337584&r2=337585&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jul 20 10:42:09 2018
@@ -11142,7 +11142,7 @@ static bool EvaluateCPlusPlus11IntegralC
 const Expr *E,
 llvm::APSInt *Value,
 SourceLocation *Loc) {
-  if (!E->getType()->isIntegralOrEnumerationType()) {
+  if (!E->getType()->isIntegralOrUnscopedEnumerationType()) {
 if (Loc) *Loc = E->getExprLoc();
 return false;
   }

Added: cfe/trunk/test/SemaCXX/PR38235.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR38235.cpp?rev=337585&view=auto
==
--- cfe/trunk/test/SemaCXX/PR38235.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR38235.cpp Fri Jul 20 10:42:09 2018
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+enum class E { Foo, Bar = 97119 };
+
+void f() __attribute__((constructor(E::Foo))); // 
expected-error{{'constructor' attribute requires an integer constant}}
+void f2() __attribute__((constructor(E::Bar)));// 
expected-error{{'constructor' attribute requires an integer constant}}
+
+void switch_me(E e) {
+  switch (e) {
+case E::Foo:
+case E::Bar:
+  break;
+  }
+}


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


r337738 - Update to -r337585, allow scoped enum inits in -pedantic

2018-07-23 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Jul 23 14:08:13 2018
New Revision: 337738

URL: http://llvm.org/viewvc/llvm-project?rev=337738&view=rev
Log:
Update to -r337585, allow scoped enum inits in -pedantic

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/PR38235.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=337738&r1=337737&r2=337738&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Jul 23 14:08:13 2018
@@ -1784,6 +1784,9 @@ public:
   /// isComplexIntegerType() can be used to test for complex integers.
   bool isIntegerType() const; // C99 6.2.5p17 (int, char, bool, enum)
   bool isEnumeralType() const;
+
+  /// Determine whether this type is a scoped enumeration type.
+  bool isScopedEnumeralType() const;
   bool isBooleanType() const;
   bool isCharType() const;
   bool isWideCharType() const;

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=337738&r1=337737&r2=337738&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Jul 23 14:08:13 2018
@@ -481,6 +481,12 @@ bool Type::isComplexIntegerType() const
   return getAsComplexIntegerType();
 }
 
+bool Type::isScopedEnumeralType() const {
+  if (const auto *ET = getAs())
+return ET->getDecl()->isScoped();
+  return false;
+}
+
 const ComplexType *Type::getAsComplexIntegerType() const {
   if (const auto *Complex = getAs())
 if (Complex->getElementType()->isIntegerType())

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=337738&r1=337737&r2=337738&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jul 23 14:08:13 2018
@@ -11165,6 +11165,9 @@ void Sema::AddInitializerToDecl(Decl *Re
 ; // Nothing to check.
   else if (Init->isIntegerConstantExpr(Context, &Loc))
 ; // Ok, it's an ICE!
+  else if (Init->getType()->isScopedEnumeralType() &&
+   Init->isCXX11ConstantExpr(Context))
+; // Ok, it is a scoped-enum constant expression.
   else if (Init->isEvaluatable(Context)) {
 // If we can constant fold the initializer through heroics, accept it,
 // but report this as a use of an extension for -pedantic.

Modified: cfe/trunk/test/SemaCXX/PR38235.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR38235.cpp?rev=337738&r1=337737&r2=337738&view=diff
==
--- cfe/trunk/test/SemaCXX/PR38235.cpp (original)
+++ cfe/trunk/test/SemaCXX/PR38235.cpp Mon Jul 23 14:08:13 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
 
 enum class E { Foo, Bar = 97119 };
 
@@ -12,3 +12,9 @@ void switch_me(E e) {
   break;
   }
 }
+
+enum class E2;
+
+struct S {
+  static const E e = E::Foo;
+};


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


r337835 - Remove stale documentation from InternalsManual.rst

2018-07-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jul 24 09:11:30 2018
New Revision: 337835

URL: http://llvm.org/viewvc/llvm-project?rev=337835&view=rev
Log:
Remove stale documentation from InternalsManual.rst

The DuplicatesAllowedWhileMerging was removed a while ago,
but the documentation remained.

Modified:
cfe/trunk/docs/InternalsManual.rst

Modified: cfe/trunk/docs/InternalsManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/InternalsManual.rst?rev=337835&r1=337834&r2=337835&view=diff
==
--- cfe/trunk/docs/InternalsManual.rst (original)
+++ cfe/trunk/docs/InternalsManual.rst Tue Jul 24 09:11:30 2018
@@ -1891,11 +1891,6 @@ attribute classes. For instance, ``Parse
 parsed attribute kind, but ARMInterruptAttr and MSP430InterruptAttr are the
 semantic attributes generated.
 
-By default, when declarations are merging attributes, an attribute will not be
-duplicated. However, if an attribute can be duplicated during this merging
-stage, set ``DuplicatesAllowedWhileMerging`` to ``1``, and the attribute will
-be merged.
-
 By default, attribute arguments are parsed in an evaluated context. If the
 arguments for an attribute should be parsed in an unevaluated context (akin to
 the way the argument to a ``sizeof`` expression is parsed), set


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


r338630 - [AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into DeclContext

2018-08-01 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Aug  1 13:48:16 2018
New Revision: 338630

URL: http://llvm.org/viewvc/llvm-project?rev=338630&view=rev
Log:
[AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into 
DeclContext

DeclContext has a little less than 8 bytes free due to the alignment
requirements on 64 bits archs. This set of patches moves the
bit-fields from classes deriving from DeclContext into DeclContext.

On 32 bits archs this increases the size of DeclContext by 4 bytes
but this is balanced by an equal or larger reduction in the size
of the classes deriving from it.

On 64 bits archs the size of DeclContext stays the same but
most of the classes deriving from it shrink by 8/16 bytes.
(-print-stats diff here https://reviews.llvm.org/D49728)
When doing an -fsyntax-only on all of Boost this result
in a 3.6% reduction in the size of all Decls and
a 1% reduction in the run time due to the lower cache
miss rate.

For now CXXRecordDecl is not touched but there is
an easy 6 (if I count correctly) bytes gain available there
by moving some bits from DefinitionData into the free
space of DeclContext. This will be the subject of another patch.

This patch sequence also enable the possibility of refactoring
FunctionDecl: To save space some bits from classes deriving from
FunctionDecl were moved to FunctionDecl. This resulted in a
lot of stuff in FunctionDecl which do not belong logically to it.
After this set of patches however it is just a simple matter of
adding a SomethingDeclBitfields in DeclContext and moving the
bits to it from FunctionDecl.

This first patch introduces the anonymous union in DeclContext
and all the *DeclBitfields classes holding the bit-fields, and moves
the bits from TagDecl, EnumDecl and RecordDecl into DeclContext.

This patch is followed by https://reviews.llvm.org/D49732,
https://reviews.llvm.org/D49733 and https://reviews.llvm.org/D49734.

Differential Revision: https://reviews.llvm.org/D49729

Patch By: bricci


Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=338630&r1=338629&r2=338630&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Aug  1 13:48:16 2018
@@ -3014,64 +3014,16 @@ public:
 };
 
 /// Represents the declaration of a struct/union/class/enum.
-class TagDecl
-  : public TypeDecl, public DeclContext, public Redeclarable {
+class TagDecl : public TypeDecl,
+public DeclContext,
+public Redeclarable {
+  // This class stores some data in DeclContext::TagDeclBits
+  // to save some space. Use the provided accessors to access it.
 public:
   // This is really ugly.
   using TagKind = TagTypeKind;
 
 private:
-  // FIXME: This can be packed into the bitfields in Decl.
-  /// The TagKind enum.
-  unsigned TagDeclKind : 3;
-
-  /// True if this is a definition ("struct foo {};"), false if it is a
-  /// declaration ("struct foo;").  It is not considered a definition
-  /// until the definition has been fully processed.
-  unsigned IsCompleteDefinition : 1;
-
-protected:
-  /// True if this is currently being defined.
-  unsigned IsBeingDefined : 1;
-
-private:
-  /// True if this tag declaration is "embedded" (i.e., defined or declared
-  /// for the very first time) in the syntax of a declarator.
-  unsigned IsEmbeddedInDeclarator : 1;
-
-  /// True if this tag is free standing, e.g. "struct foo;".
-  unsigned IsFreeStanding : 1;
-
-protected:
-  // These are used by (and only defined for) EnumDecl.
-  unsigned NumPositiveBits : 8;
-  unsigned NumNegativeBits : 8;
-
-  /// True if this tag declaration is a scoped enumeration. Only
-  /// possible in C++11 mode.
-  unsigned IsScoped : 1;
-
-  /// If this tag declaration is a scoped enum,
-  /// then this is true if the scoped enum was declared using the class
-  /// tag, false if it was declared with the struct tag. No meaning is
-  /// associated if this tag declaration is not a scoped enum.
-  unsigned IsScopedUsingClassTag : 1;
-
-  /// True if this is an enumeration with fixed underlying type. Only
-  /// possible in C++11, Microsoft extensions, or Objective C mode.
-  unsigned IsFixed : 1;
-
-  /// Indicates whether it is possible for declarations of this kind
-  /// to have an out-of-date definition.
-  ///
-  /// This option is only enabled when modules are enabled.
-  unsigned MayHaveOutOfDateDef : 1;
-
-  /// Has the full definition of this type been required by a use somewhere in
-  /// the TU.
-  unsig

r338636 - [AST][2/4] Move the bit-fields from FunctionDecl and CXXConstructorDecl into DeclContext

2018-08-01 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Aug  1 14:02:40 2018
New Revision: 338636

URL: http://llvm.org/viewvc/llvm-project?rev=338636&view=rev
Log:
[AST][2/4] Move the bit-fields from FunctionDecl and CXXConstructorDecl into 
DeclContext

This patch follows https://reviews.llvm.org/D49729
and is followed by https://reviews.llvm.org/D49733
and https://reviews.llvm.org/D49734.

Move the bits from FunctionDecl and CXXConstructorDecl
into DeclContext.

Differential Revision: https://reviews.llvm.org/D49732

Patch By: bricci

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=338636&r1=338635&r2=338636&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Aug  1 14:02:40 2018
@@ -1711,8 +1711,11 @@ private:
 /// contains all of the information known about the function. Other,
 /// previous declarations of the function are available via the
 /// getPreviousDecl() chain.
-class FunctionDecl : public DeclaratorDecl, public DeclContext,
+class FunctionDecl : public DeclaratorDecl,
+ public DeclContext,
  public Redeclarable {
+  // This class stores some data in DeclContext::FunctionDeclBits
+  // to save some space. Use the provided accessors to access it.
 public:
   /// The kind of templated function a FunctionDecl can be.
   enum TemplatedKind {
@@ -1731,64 +1734,6 @@ private:
 
   LazyDeclStmtPtr Body;
 
-  // FIXME: This can be packed into the bitfields in DeclContext.
-  // NOTE: VC++ packs bitfields poorly if the types differ.
-  unsigned SClass : 3;
-  unsigned IsInline : 1;
-  unsigned IsInlineSpecified : 1;
-
-protected:
-  // This is shared by CXXConstructorDecl, CXXConversionDecl, and
-  // CXXDeductionGuideDecl.
-  unsigned IsExplicitSpecified : 1;
-
-private:
-  unsigned IsVirtualAsWritten : 1;
-  unsigned IsPure : 1;
-  unsigned HasInheritedPrototype : 1;
-  unsigned HasWrittenPrototype : 1;
-  unsigned IsDeleted : 1;
-  unsigned IsTrivial : 1; // sunk from CXXMethodDecl
-
-  /// This flag indicates whether this function is trivial for the purpose of
-  /// calls. This is meaningful only when this function is a copy/move
-  /// constructor or a destructor.
-  unsigned IsTrivialForCall : 1;
-
-  unsigned IsDefaulted : 1; // sunk from CXXMethoDecl
-  unsigned IsExplicitlyDefaulted : 1; //sunk from CXXMethodDecl
-  unsigned HasImplicitReturnZero : 1;
-  unsigned IsLateTemplateParsed : 1;
-  unsigned IsConstexpr : 1;
-  unsigned InstantiationIsPending : 1;
-
-  /// Indicates if the function uses __try.
-  unsigned UsesSEHTry : 1;
-
-  /// Indicates if the function was a definition but its body was
-  /// skipped.
-  unsigned HasSkippedBody : 1;
-
-  /// Indicates if the function declaration will have a body, once we're done
-  /// parsing it.
-  unsigned WillHaveBody : 1;
-
-  /// Indicates that this function is a multiversioned function using attribute
-  /// 'target'.
-  unsigned IsMultiVersion : 1;
-
-protected:
-  /// [C++17] Only used by CXXDeductionGuideDecl. Declared here to avoid
-  /// increasing the size of CXXDeductionGuideDecl by the size of an unsigned
-  /// int as opposed to adding a single bit to FunctionDecl.
-  /// Indicates that the Deduction Guide is the implicitly generated 'copy
-  /// deduction candidate' (is used during overload resolution).
-  unsigned IsCopyDeductionCandidate : 1;
-
-private:
-
-  /// Store the ODRHash after first calculation.
-  unsigned HasODRHash : 1;
   unsigned ODRHash;
 
   /// End part of this FunctionDecl's source range.
@@ -1858,25 +1803,22 @@ private:
 
   void setParams(ASTContext &C, ArrayRef NewParamInfo);
 
+  // This is unfortunately needed because ASTDeclWriter::VisitFunctionDecl
+  // need to access this bit but we want to avoid making ASTDeclWriter
+  // a friend of FunctionDeclBitfields just for this.
+  bool isDeletedBit() const { return FunctionDeclBits.IsDeleted; }
+
+  /// Whether an ODRHash has been stored.
+  bool hasODRHash() const { return FunctionDeclBits.HasODRHash; }
+
+  /// State that an ODRHash has been stored.
+  void setHasODRHash(bool B = true) { FunctionDeclBits.HasODRHash = B; }
+
 protected:
   FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation 
StartLoc,
const DeclarationNameInfo &NameInfo, QualType T,
TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified,
-   bool isConstexprSpecified)
-  : DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo,
-   StartLoc),
-DeclContext(DK), redeclarable_base(C), SClass(S),
-IsInl

r338639 - [AST][3/4] Move the bit-fields from BlockDecl, LinkageSpecDecl and OMPDeclareReductionDecl into DeclContext

2018-08-01 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Aug  1 14:16:54 2018
New Revision: 338639

URL: http://llvm.org/viewvc/llvm-project?rev=338639&view=rev
Log:
[AST][3/4] Move the bit-fields from BlockDecl, LinkageSpecDecl and 
OMPDeclareReductionDecl into DeclContext

This patch follows https://reviews.llvm.org/D49729
and https://reviews.llvm.org/D49732, and is
followed by https://reviews.llvm.org/D49734.

Move the bits from BlockDecl, LinkageSpecDecl and
OMPDeclareReductionDecl into DeclContext.

Differential Revision: https://reviews.llvm.org/D49733

Patch By: bricci

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclOpenMP.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclOpenMP.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=338639&r1=338638&r2=338639&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Aug  1 14:16:54 2018
@@ -3823,6 +3823,8 @@ public:
 /// unnamed FunctionDecl.  For example:
 /// ^{ statement-body }   or   ^(int arg1, float arg2){ statement-body }
 class BlockDecl : public Decl, public DeclContext {
+  // This class stores some data in DeclContext::BlockDeclBits
+  // to save some space. Use the provided accessors to access it.
 public:
   /// A class which contains all the information about a particular
   /// captured value.
@@ -3863,16 +3865,6 @@ public:
   };
 
 private:
-  // FIXME: This can be packed into the bitfields in Decl.
-  bool IsVariadic : 1;
-  bool CapturesCXXThis : 1;
-  bool BlockMissingReturnType : 1;
-  bool IsConversionFromLambda : 1;
-
-  /// A bit that indicates this block is passed directly to a function as a
-  /// non-escaping parameter.
-  bool DoesNotEscape : 1;
-
   /// A new[]'d array of pointers to ParmVarDecls for the formal
   /// parameters of this function.  This is null if a prototype or if there are
   /// no formals.
@@ -3889,10 +3881,7 @@ private:
   Decl *ManglingContextDecl = nullptr;
 
 protected:
-  BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
-  : Decl(Block, DC, CaretLoc), DeclContext(Block), IsVariadic(false),
-CapturesCXXThis(false), BlockMissingReturnType(true),
-IsConversionFromLambda(false), DoesNotEscape(false) {}
+  BlockDecl(DeclContext *DC, SourceLocation CaretLoc);
 
 public:
   static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L);
@@ -3900,8 +3889,8 @@ public:
 
   SourceLocation getCaretLocation() const { return getLocation(); }
 
-  bool isVariadic() const { return IsVariadic; }
-  void setIsVariadic(bool value) { IsVariadic = value; }
+  bool isVariadic() const { return BlockDeclBits.IsVariadic; }
+  void setIsVariadic(bool value) { BlockDeclBits.IsVariadic = value; }
 
   CompoundStmt *getCompoundBody() const { return (CompoundStmt*) Body; }
   Stmt *getBody() const override { return (Stmt*) Body; }
@@ -3944,7 +3933,7 @@ public:
 
   /// True if this block (or its nested blocks) captures
   /// anything of local storage from its enclosing scopes.
-  bool hasCaptures() const { return NumCaptures != 0 || CapturesCXXThis; }
+  bool hasCaptures() const { return NumCaptures || capturesCXXThis(); }
 
   /// Returns the number of captured variables.
   /// Does not include an entry for 'this'.
@@ -3957,15 +3946,27 @@ public:
   capture_const_iterator capture_begin() const { return captures().begin(); }
   capture_const_iterator capture_end() const { return captures().end(); }
 
-  bool capturesCXXThis() const { return CapturesCXXThis; }
-  bool blockMissingReturnType() const { return BlockMissingReturnType; }
-  void setBlockMissingReturnType(bool val) { BlockMissingReturnType = val; }
+  bool capturesCXXThis() const { return BlockDeclBits.CapturesCXXThis; }
+  void setCapturesCXXThis(bool B = true) { BlockDeclBits.CapturesCXXThis = B; }
+
+  bool blockMissingReturnType() const {
+return BlockDeclBits.BlockMissingReturnType;
+  }
+
+  void setBlockMissingReturnType(bool val = true) {
+BlockDeclBits.BlockMissingReturnType = val;
+  }
+
+  bool isConversionFromLambda() const {
+return BlockDeclBits.IsConversionFromLambda;
+  }
 
-  bool isConversionFromLambda() const { return IsConversionFromLambda; }
-  void setIsConversionFromLambda(bool val) { IsConversionFromLambda = val; }
+  void setIsConversionFromLambda(bool val = true) {
+BlockDeclBits.IsConversionFromLambda = val;
+  }
 
-  bool doesNotEscape() const { return DoesNotEscape; }
-  void setDoesNotEscape() { DoesNotEscape = true; }
+  bool doesNotEscape() const { return BlockDeclBits.DoesNotEscape; }
+  void setDoesNotEscape(bool B = true) { BlockDeclBits.DoesNotEscape = B; }
 
   bool capturesVariable(const VarDecl *var) const;
 

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/

r338641 - [AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into DeclContext

2018-08-01 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Aug  1 14:31:08 2018
New Revision: 338641

URL: http://llvm.org/viewvc/llvm-project?rev=338641&view=rev
Log:
[AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into 
DeclContext

This patch follows https://reviews.llvm.org/D49729,
https://reviews.llvm.org/D49732 and
https://reviews.llvm.org/D49733.

Move the bits from ObjCMethodDecl and ObjCContainerDecl
into DeclContext.

Differential Revision: https://reviews.llvm.org/D49734

Patch By: bricci

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=338641&r1=338640&r2=338641&view=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Aug  1 14:31:08 2018
@@ -141,58 +141,10 @@ public:
   enum ImplementationControl { None, Required, Optional };
 
 private:
-  // The conventional meaning of this method; an ObjCMethodFamily.
-  // This is not serialized; instead, it is computed on demand and
-  // cached.
-  mutable unsigned Family : ObjCMethodFamilyBitWidth;
-
-  /// instance (true) or class (false) method.
-  unsigned IsInstance : 1;
-  unsigned IsVariadic : 1;
-
-  /// True if this method is the getter or setter for an explicit property.
-  unsigned IsPropertyAccessor : 1;
-
-  // Method has a definition.
-  unsigned IsDefined : 1;
-
-  /// Method redeclaration in the same interface.
-  unsigned IsRedeclaration : 1;
-
-  /// Is redeclared in the same interface.
-  mutable unsigned HasRedeclaration : 1;
-
-  // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
-  /// \@required/\@optional
-  unsigned DeclImplementation : 2;
-
-  // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
-  /// in, inout, etc.
-  unsigned objcDeclQualifier : 7;
-
-  /// Indicates whether this method has a related result type.
-  unsigned RelatedResultType : 1;
-
-  /// Whether the locations of the selector identifiers are in a
-  /// "standard" position, a enum SelectorLocationsKind.
-  unsigned SelLocsKind : 2;
-
-  /// Whether this method overrides any other in the class hierarchy.
-  ///
-  /// A method is said to override any method in the class's
-  /// base classes, its protocols, or its categories' protocols, that has
-  /// the same selector and is of the same kind (class or instance).
-  /// A method in an implementation is not considered as overriding the same
-  /// method in the interface or its categories.
-  unsigned IsOverriding : 1;
-
-  /// Indicates if the method was a definition but its body was skipped.
-  unsigned HasSkippedBody : 1;
-
-  // Return type of this method.
+  /// Return type of this method.
   QualType MethodDeclType;
 
-  // Type source information for the return type.
+  /// Type source information for the return type.
   TypeSourceInfo *ReturnTInfo;
 
   /// Array of ParmVarDecls for the formal parameters of this method
@@ -203,7 +155,7 @@ private:
   /// List of attributes for this method declaration.
   SourceLocation DeclEndLoc; // the location of the ';' or '{'.
 
-  // The following are only used for method definitions, null otherwise.
+  /// The following are only used for method definitions, null otherwise.
   LazyDeclStmtPtr Body;
 
   /// SelfDecl - Decl for the implicit self parameter. This is lazily
@@ -220,21 +172,14 @@ private:
  bool isVariadic = false, bool isPropertyAccessor = false,
  bool isImplicitlyDeclared = false, bool isDefined = false,
  ImplementationControl impControl = None,
- bool HasRelatedResultType = false)
-  : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
-DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily),
-IsInstance(isInstance), IsVariadic(isVariadic),
-IsPropertyAccessor(isPropertyAccessor), IsDefined(isDefined),
-IsRedeclaration(0), HasRedeclaration(0), 
DeclImplementation(impControl),
-objcDeclQualifier(OBJC_TQ_None),
-RelatedResultType(HasRelatedResultType),
-SelLocsKind(SelLoc_StandardNoSpace), IsOverriding(0), 
HasSkippedBody(0),
-MethodDeclType(T), ReturnTInfo(ReturnTInfo), DeclEndLoc(endLoc) {
-setImplicit(isImplicitlyDeclared);
-  }
+ bool HasRelatedResultType = false);
 
   SelectorLocationsKind getSelLocsKind() const {
-return (SelectorLocationsKind)SelLocsKind;
+return static_cast(ObjCMethodDeclBits.SelLocsKind);
+  }
+
+  void setSelLocsKind(SelectorLocationsKind Kind) {
+ObjCMethodDeclBits.SelLocsKind = Kind;
   }
 
   bool hasStandardSelLocs() const {
@@ -244,10 +189,10 @@ private:
   /// Get

r338884 - [NFC] Silence unused variable warning in Attr.td/AttrParsedAttrImpl.inc

2018-08-03 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Aug  3 06:01:32 2018
New Revision: 338884

URL: http://llvm.org/viewvc/llvm-project?rev=338884&view=rev
Log:
[NFC] Silence unused variable warning in Attr.td/AttrParsedAttrImpl.inc

Modified:
cfe/trunk/include/clang/Basic/Attr.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=338884&r1=338883&r2=338884&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Aug  3 06:01:32 2018
@@ -145,7 +145,7 @@ def HasFunctionProto : SubsetSubject;
 
 // A single argument to an attribute


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


r338886 - [NFC] Fix unused expression warning introduced in r338884

2018-08-03 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Aug  3 06:23:04 2018
New Revision: 338886

URL: http://llvm.org/viewvc/llvm-project?rev=338886&view=rev
Log:
[NFC] Fix unused expression warning introduced in r338884

Modified:
cfe/trunk/include/clang/Basic/Attr.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=338886&r1=338885&r2=338886&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Aug  3 06:23:04 2018
@@ -145,8 +145,9 @@ def HasFunctionProto : SubsetSubject;
+def ImplicitObjectParameter
+: SubsetSubject(S), false} ],
+"implicit object parameters">;
 
 // A single argument to an attribute
 class Argument {


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


r338889 - [NFCI] My attempt to fix a warning in r338886 broke the build! Fix it.

2018-08-03 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Aug  3 06:51:35 2018
New Revision: 338889

URL: http://llvm.org/viewvc/llvm-project?rev=338889&view=rev
Log:
[NFCI] My attempt to fix a warning in r338886 broke the build! Fix it.

Clang format got the best of me... it introduced spaces around something 
in a table-genned file, so it was interpreted as an array and not a 
code block.  

Modified:
cfe/trunk/include/clang/Basic/Attr.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=338889&r1=33&r2=338889&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Aug  3 06:51:35 2018
@@ -146,7 +146,7 @@ def HasFunctionProto : SubsetSubject(S), false} ],
+: SubsetSubject(S), false}],
 "implicit object parameters">;
 
 // A single argument to an attribute


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


r338893 - revert r338831 - Fix unused variable warning in tablegen generated code

2018-08-03 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Aug  3 07:24:34 2018
New Revision: 338893

URL: http://llvm.org/viewvc/llvm-project?rev=338893&view=rev
Log:
revert r338831 - Fix unused variable warning in tablegen generated code

No longer necessary thanks to r338889 (and friends).

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=338893&r1=338892&r2=338893&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Fri Aug  3 07:24:34 2018
@@ -3274,15 +3274,11 @@ static std::string GenerateCustomApperta
 return "";
   }
 
-  const StringRef CheckCodeValue = Subject.getValueAsString("CheckCode");
-
   OS << "static bool " << FnName << "(const Decl *D) {\n";
-  if (CheckCodeValue != "false") {
-OS << "  if (const auto *S = dyn_cast<";
-OS << GetSubjectWithSuffix(Base);
-OS << ">(D))\n";
-OS << "return " << Subject.getValueAsString("CheckCode") << ";\n";
-  }
+  OS << "  if (const auto *S = dyn_cast<";
+  OS << GetSubjectWithSuffix(Base);
+  OS << ">(D))\n";
+  OS << "return " << Subject.getValueAsString("CheckCode") << ";\n";
   OS << "  return false;\n";
   OS << "}\n\n";
 


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


r338909 - [NFC] Initialize a variable to prevent future invalid deref.

2018-08-03 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Aug  3 11:08:36 2018
New Revision: 338909

URL: http://llvm.org/viewvc/llvm-project?rev=338909&view=rev
Log:
[NFC] Initialize a variable to prevent future invalid deref.

Found by KlockWorks, this variable is properly protected, however
the conditions in the test that initializes it and the one that uses
it could diverge, it seems to me that this is a 'free' init that will
prevent issues if one of the conditions is ever modified without the other.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=338909&r1=338908&r2=338909&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Aug  3 11:08:36 2018
@@ -1076,7 +1076,7 @@ RValue CodeGenFunction::EmitBlockCallExp
 E->getCallee()->getType()->getAs();
 
   llvm::Value *BlockPtr = EmitScalarExpr(E->getCallee());
-  llvm::Value *FuncPtr;
+  llvm::Value *FuncPtr = nullptr;
 
   if (!CGM.getLangOpts().OpenCL) {
 // Get a pointer to the generic block literal.


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


r324430 - [NFC] Correct a typo'ed comment and reworded, since it is awkward.

2018-02-06 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb  6 16:19:58 2018
New Revision: 324430

URL: http://llvm.org/viewvc/llvm-project?rev=324430&view=rev
Log:
[NFC] Correct a typo'ed comment and reworded, since it is awkward.


Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=324430&r1=324429&r2=324430&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Feb  6 16:19:58 2018
@@ -133,7 +133,7 @@ void Driver::ParseDriverMode(StringRef P
   setDriverModeFromOption(ClangNameParts.DriverMode);
 
   for (const char *ArgPtr : Args) {
-// Ingore nullptrs, they are response file's EOL markers
+// Ignore nullptrs, they are the response file's EOL markers.
 if (ArgPtr == nullptr)
   continue;
 const StringRef Arg = ArgPtr;


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


r324433 - [NFC] Change odd cast-through-unknown behavior to an Optional

2018-02-06 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb  6 16:37:19 2018
New Revision: 324433

URL: http://llvm.org/viewvc/llvm-project?rev=324433&view=rev
Log:
[NFC] Change odd cast-through-unknown behavior to an Optional

This bit of code in the driver uses '~0U' as a sentinel value.
The result is an odd mishmash of casts just to work.  This replaces
it with an optional,  which is a little less crazy looking.
--ehis line, and those below, will be ignored--

Mlib/Driver/Driver.cpp

Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=324433&r1=324432&r2=324433&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Feb  6 16:37:19 2018
@@ -148,15 +148,15 @@ void Driver::setDriverModeFromOption(Str
 return;
   StringRef Value = Opt.drop_front(OptName.size());
 
-  const unsigned M = llvm::StringSwitch(Value)
- .Case("gcc", GCCMode)
- .Case("g++", GXXMode)
- .Case("cpp", CPPMode)
- .Case("cl", CLMode)
- .Default(~0U);
+  auto M = llvm::StringSwitch>(Value)
+   .Case("gcc", GCCMode)
+   .Case("g++", GXXMode)
+   .Case("cpp", CPPMode)
+   .Case("cl", CLMode)
+   .Default(None);
 
-  if (M != ~0U)
-Mode = static_cast(M);
+  if (M)
+Mode = M.getValue();
   else
 Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
 }


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


r324540 - [NFCi] Replace a couple of usages of const StringRef& with StringRef

2018-02-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Feb  7 15:04:38 2018
New Revision: 324540

URL: http://llvm.org/viewvc/llvm-project?rev=324540&view=rev
Log:
[NFCi] Replace a couple of usages of const StringRef& with StringRef

No sense passing these by reference when a copy is about as free, and
saves on potential indirection later.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets/SystemZ.cpp
cfe/trunk/lib/Basic/Targets/SystemZ.h
cfe/trunk/lib/Basic/Targets/X86.h

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=324540&r1=324539&r2=324540&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Feb  7 15:04:38 2018
@@ -623,9 +623,9 @@ public:
   /// ReturnCanonical = true and Name = "rax", will return "ax".
   StringRef getNormalizedGCCRegisterName(StringRef Name,
  bool ReturnCanonical = false) const;
- 
-  virtual StringRef getConstraintRegister(const StringRef &Constraint,
-  const StringRef &Expression) const {
+
+  virtual StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const {
 return "";
   }
 

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.cpp?rev=324540&r1=324539&r2=324540&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.cpp Wed Feb  7 15:04:38 2018
@@ -83,7 +83,7 @@ bool SystemZTargetInfo::validateAsmConst
   }
 }
 
-int SystemZTargetInfo::getISARevision(const StringRef &Name) const {
+int SystemZTargetInfo::getISARevision(StringRef Name) const {
   return llvm::StringSwitch(Name)
   .Cases("arch8", "z10", 8)
   .Cases("arch9", "z196", 9)

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.h?rev=324540&r1=324539&r2=324540&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.h (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.h Wed Feb  7 15:04:38 2018
@@ -76,7 +76,7 @@ public:
 return TargetInfo::SystemZBuiltinVaList;
   }
 
-  int getISARevision(const StringRef &Name) const;
+  int getISARevision(StringRef Name) const;
 
   bool isValidCPUName(StringRef Name) const override {
 return getISARevision(Name) != -1;

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=324540&r1=324539&r2=324540&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Wed Feb  7 15:04:38 2018
@@ -175,8 +175,8 @@ public:
 return "~{dirflag},~{fpsr},~{flags}";
   }
 
-  StringRef getConstraintRegister(const StringRef &Constraint,
-  const StringRef &Expression) const override {
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
 StringRef::iterator I, E;
 for (I = Constraint.begin(), E = Constraint.end(); I != E; ++I) {
   if (isalpha(*I))


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


r324644 - Fix improper indentation issue in CodeGenModule [NFC]

2018-02-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Feb  8 12:04:22 2018
New Revision: 324644

URL: http://llvm.org/viewvc/llvm-project?rev=324644&view=rev
Log:
Fix improper indentation issue in CodeGenModule [NFC]

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324644&r1=324643&r2=324644&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Feb  8 12:04:22 2018
@@ -1264,8 +1264,8 @@ void CodeGenModule::setNonAliasAttribute
 
 if (auto *F = dyn_cast(GO)) {
   if (auto *SA = D->getAttr())
-   if (!D->getAttr())
- F->addFnAttr("implicit-section-name", SA->getName());
+if (!D->getAttr())
+  F->addFnAttr("implicit-section-name", SA->getName());
 }
 
 if (const SectionAttr *SA = D->getAttr())


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


r324673 - Make march/target-cpu print a note with the list of valid values for ARM

2018-02-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Feb  8 15:14:15 2018
New Revision: 324673

URL: http://llvm.org/viewvc/llvm-project?rev=324673&view=rev
Log:
Make march/target-cpu print a note with the list of valid values for ARM

When rejecting a march= or target-cpu command line parameter,
the message is quite lacking. This patch adds a note that prints
all possible values for the current target, if the target supports it.

This adds support for the ARM/AArch64 targets (more to come!). 

Differential Revision: https://reviews.llvm.org/D42978 

Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/AArch64.h
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Basic/Targets/ARM.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=324673&r1=324672&r2=324673&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Feb  8 15:14:15 
2018
@@ -188,6 +188,7 @@ def note_invalid_subexpr_in_const_expr :
 def err_target_unknown_triple : Error<
   "unknown target triple '%0', please use -triple or -arch">;
 def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
+def note_valid_options : Note<"valid target CPU values are: %0">;
 def err_target_unsupported_cpu_for_micromips : Error<
   "micromips is not supported for target CPU '%0'">;
 def err_target_unknown_abi : Error<"unknown target ABI '%0'">;

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=324673&r1=324672&r2=324673&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Feb  8 15:14:15 2018
@@ -867,6 +867,9 @@ public:
 return false;
   }
 
+  /// Fill a SmallVectorImpl with the valid values to setCPU.
+  virtual void fillValidCPUList(SmallVectorImpl &Values) const {}
+
   /// brief Determine whether this TargetInfo supports the given CPU name.
   virtual bool isValidCPUName(StringRef Name) const {
 return true;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=324673&r1=324672&r2=324673&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Feb  8 15:14:15 2018
@@ -38,6 +38,7 @@
 #include "Targets/X86.h"
 #include "Targets/XCore.h"
 #include "clang/Basic/Diagnostic.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Triple.h"
 
 using namespace clang;
@@ -607,6 +608,10 @@ TargetInfo::CreateTargetInfo(Diagnostics
   // Set the target CPU if specified.
   if (!Opts->CPU.empty() && !Target->setCPU(Opts->CPU)) {
 Diags.Report(diag::err_target_unknown_cpu) << Opts->CPU;
+SmallVector ValidList;
+Target->fillValidCPUList(ValidList);
+if (!ValidList.empty())
+  Diags.Report(diag::note_valid_options) << llvm::join(ValidList, ", ");
 return nullptr;
   }
 

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=324673&r1=324672&r2=324673&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Thu Feb  8 15:14:15 2018
@@ -101,6 +101,11 @@ bool AArch64TargetInfo::setCPU(const std
   return isValidCPUName(Name);
 }
 
+void AArch64TargetInfo::fillValidCPUList(
+SmallVectorImpl &Values) const {
+  llvm::AArch64::fillValidCPUArchList(Values);
+}
+
 void AArch64TargetInfo::getTargetDefinesARMV81A(const LangOptions &Opts,
 MacroBuilder &Builder) const {
   Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");

Modified: cfe/trunk/lib/Basic/Targets/AArch64.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.h?rev=324673&r1=324672&r2=324673&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.h (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.h Thu Feb  8 15:14:15 2018
@@ -46,6 +46,7 @@ public:
   bool setABI(const std::string &Name) override;
 
   bool isValidCPUName(StringRef Name) const override;
+  void fillValidCPUList(SmallVectorImpl &Values) const override;
   bool setCPU(const std::string &Name) override;
 
   bool useFP16ConversionIntrinsics() const override {

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
htt

r324674 - Add X86 Support to ValidCPUList (enabling march notes)

2018-02-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Feb  8 15:15:02 2018
New Revision: 324674

URL: http://llvm.org/viewvc/llvm-project?rev=324674&view=rev
Log:
Add X86 Support to ValidCPUList (enabling march notes)

A followup to: https://reviews.llvm.org/D42978
This patch adds X86 and X86_64 support for
enabling the march notes.

Differential Revision: https://reviews.llvm.org/D43041


Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=324674&r1=324673&r2=324674&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Thu Feb  8 15:15:02 2018
@@ -15,6 +15,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/TargetBuiltins.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/TargetParser.h"
@@ -1648,8 +1649,6 @@ std::string X86TargetInfo::convertConstr
 bool X86TargetInfo::checkCPUKind(CPUKind Kind) const {
   // Perform any per-CPU checks necessary to determine if this CPU is
   // acceptable.
-  // FIXME: This results in terrible diagnostics. Clang just says the CPU is
-  // invalid without explaining *why*.
   switch (Kind) {
   case CK_Generic:
 // No processor selected!
@@ -1662,6 +1661,18 @@ bool X86TargetInfo::checkCPUKind(CPUKind
   llvm_unreachable("Unhandled CPU kind");
 }
 
+void X86TargetInfo::fillValidCPUList(SmallVectorImpl &Values) const 
{
+#define PROC(ENUM, STRING, IS64BIT)
\
+  if (IS64BIT || getTriple().getArch() == llvm::Triple::x86)   
\
+Values.emplace_back(STRING);
+  // Go through CPUKind checking to ensure that the alias is de-aliased and 
+  // 64 bit-ness is checked.
+#define PROC_ALIAS(ENUM, ALIAS)
\
+  if (checkCPUKind(getCPUKind(ALIAS))) 
\
+Values.emplace_back(ALIAS);
+#include "clang/Basic/X86Target.def"
+}
+
 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
   return llvm::StringSwitch(CPU)
 #define PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=324674&r1=324673&r2=324674&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Thu Feb  8 15:15:02 2018
@@ -264,6 +264,8 @@ public:
 return checkCPUKind(getCPUKind(Name));
   }
 
+  void fillValidCPUList(SmallVectorImpl &Values) const override;
+
   bool setCPU(const std::string &Name) override {
 return checkCPUKind(CPU = getCPUKind(Name));
   }


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


r324675 - Add NVPTX Support to ValidCPUList (enabling march notes)

2018-02-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Feb  8 15:16:00 2018
New Revision: 324675

URL: http://llvm.org/viewvc/llvm-project?rev=324675&view=rev
Log:
Add NVPTX Support to ValidCPUList (enabling march notes)

A followup to: https://reviews.llvm.org/D42978
This patch adds NVPTX support for
enabling the march notes.

Differential Revision: https://reviews.llvm.org/D43045


Modified:
cfe/trunk/include/clang/Basic/Cuda.h
cfe/trunk/lib/Basic/Cuda.cpp
cfe/trunk/lib/Basic/Targets/NVPTX.cpp
cfe/trunk/lib/Basic/Targets/NVPTX.h

Modified: cfe/trunk/include/clang/Basic/Cuda.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Cuda.h?rev=324675&r1=324674&r2=324675&view=diff
==
--- cfe/trunk/include/clang/Basic/Cuda.h (original)
+++ cfe/trunk/include/clang/Basic/Cuda.h Thu Feb  8 15:16:00 2018
@@ -46,6 +46,7 @@ enum class CudaArch {
   SM_62,
   SM_70,
   SM_72,
+  LAST,
 };
 const char *CudaArchToString(CudaArch A);
 

Modified: cfe/trunk/lib/Basic/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Cuda.cpp?rev=324675&r1=324674&r2=324675&view=diff
==
--- cfe/trunk/lib/Basic/Cuda.cpp (original)
+++ cfe/trunk/lib/Basic/Cuda.cpp Thu Feb  8 15:16:00 2018
@@ -26,6 +26,8 @@ const char *CudaVersionToString(CudaVers
 
 const char *CudaArchToString(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return "unknown";
   case CudaArch::SM_20:
@@ -133,6 +135,8 @@ CudaVirtualArch StringToCudaVirtualArch(
 
 CudaVirtualArch VirtualArchForCudaArch(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return CudaVirtualArch::UNKNOWN;
   case CudaArch::SM_20:
@@ -168,6 +172,8 @@ CudaVirtualArch VirtualArchForCudaArch(C
 
 CudaVersion MinVersionForCudaArch(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return CudaVersion::UNKNOWN;
   case CudaArch::SM_20:

Modified: cfe/trunk/lib/Basic/Targets/NVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/NVPTX.cpp?rev=324675&r1=324674&r2=324675&view=diff
==
--- cfe/trunk/lib/Basic/Targets/NVPTX.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/NVPTX.cpp Thu Feb  8 15:16:00 2018
@@ -157,6 +157,8 @@ void NVPTXTargetInfo::getTargetDefines(c
 // Set __CUDA_ARCH__ for the GPU specified.
 std::string CUDAArchCode = [this] {
   switch (GPU) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 assert(false && "No GPU arch when compiling CUDA device code.");
 return "";

Modified: cfe/trunk/lib/Basic/Targets/NVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/NVPTX.h?rev=324675&r1=324674&r2=324675&view=diff
==
--- cfe/trunk/lib/Basic/Targets/NVPTX.h (original)
+++ cfe/trunk/lib/Basic/Targets/NVPTX.h Thu Feb  8 15:16:00 2018
@@ -98,6 +98,12 @@ public:
 return StringToCudaArch(Name) != CudaArch::UNKNOWN;
   }
 
+  void fillValidCPUList(SmallVectorImpl &Values) const override {
+for (int i = static_cast(CudaArch::SM_20);
+ i < static_cast(CudaArch::LAST); ++i)
+  Values.emplace_back(CudaArchToString(static_cast(i)));
+  }
+
   bool setCPU(const std::string &Name) override {
 GPU = StringToCudaArch(Name);
 return GPU != CudaArch::UNKNOWN;


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


r324676 - Add Rest of Targets Support to ValidCPUList (enabling march notes)

2018-02-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Feb  8 15:16:55 2018
New Revision: 324676

URL: http://llvm.org/viewvc/llvm-project?rev=324676&view=rev
Log:
Add Rest of Targets Support to ValidCPUList (enabling march notes)

A followup to: https://reviews.llvm.org/D42978

Most of the rest of the Targets were pretty rote, so this
patch knocks them all out at once. 

Differential Revision: https://reviews.llvm.org/D43057


Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/lib/Basic/Targets/AVR.cpp
cfe/trunk/lib/Basic/Targets/AVR.h
cfe/trunk/lib/Basic/Targets/BPF.cpp
cfe/trunk/lib/Basic/Targets/BPF.h
cfe/trunk/lib/Basic/Targets/Hexagon.cpp
cfe/trunk/lib/Basic/Targets/Hexagon.h
cfe/trunk/lib/Basic/Targets/Lanai.cpp
cfe/trunk/lib/Basic/Targets/Lanai.h
cfe/trunk/lib/Basic/Targets/Mips.cpp
cfe/trunk/lib/Basic/Targets/Mips.h
cfe/trunk/lib/Basic/Targets/Nios2.h
cfe/trunk/lib/Basic/Targets/PPC.cpp
cfe/trunk/lib/Basic/Targets/PPC.h
cfe/trunk/lib/Basic/Targets/Sparc.cpp
cfe/trunk/lib/Basic/Targets/Sparc.h
cfe/trunk/lib/Basic/Targets/SystemZ.cpp
cfe/trunk/lib/Basic/Targets/SystemZ.h
cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
cfe/trunk/lib/Basic/Targets/WebAssembly.h

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=324676&r1=324675&r2=324676&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Thu Feb  8 15:16:55 2018
@@ -228,72 +228,37 @@ void AMDGPUTargetInfo::adjustTargetOptio
 TargetOpts.Features.push_back("+fp64-fp16-denormals");
 }
 
+
+constexpr AMDGPUTargetInfo::NameGPUKind AMDGPUTargetInfo::R600Names[];
+constexpr AMDGPUTargetInfo::NameGPUKind AMDGPUTargetInfo::AMDGCNNames[];
 AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseR600Name(StringRef Name) {
-  return llvm::StringSwitch(Name)
-  .Case("r600", GK_R600)
-  .Case("rv610", GK_R600)
-  .Case("rv620", GK_R600)
-  .Case("rv630", GK_R600)
-  .Case("rv635", GK_R600)
-  .Case("rs780", GK_R600)
-  .Case("rs880", GK_R600)
-  .Case("rv670", GK_R600_DOUBLE_OPS)
-  .Case("rv710", GK_R700)
-  .Case("rv730", GK_R700)
-  .Case("rv740", GK_R700_DOUBLE_OPS)
-  .Case("rv770", GK_R700_DOUBLE_OPS)
-  .Case("palm", GK_EVERGREEN)
-  .Case("cedar", GK_EVERGREEN)
-  .Case("sumo", GK_EVERGREEN)
-  .Case("sumo2", GK_EVERGREEN)
-  .Case("redwood", GK_EVERGREEN)
-  .Case("juniper", GK_EVERGREEN)
-  .Case("hemlock", GK_EVERGREEN_DOUBLE_OPS)
-  .Case("cypress", GK_EVERGREEN_DOUBLE_OPS)
-  .Case("barts", GK_NORTHERN_ISLANDS)
-  .Case("turks", GK_NORTHERN_ISLANDS)
-  .Case("caicos", GK_NORTHERN_ISLANDS)
-  .Case("cayman", GK_CAYMAN)
-  .Case("aruba", GK_CAYMAN)
-  .Default(GK_NONE);
+  const auto *Result = llvm::find_if(
+  R600Names, [Name](const NameGPUKind &Kind) { return Kind.Name == Name; 
});
+
+  if (Result == std::end(R600Names))
+return GK_NONE;
+  return Result->Kind;
 }
 
 AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
-  return llvm::StringSwitch(Name)
-  .Case("gfx600", GK_GFX6)
-  .Case("tahiti", GK_GFX6)
-  .Case("gfx601", GK_GFX6)
-  .Case("pitcairn", GK_GFX6)
-  .Case("verde", GK_GFX6)
-  .Case("oland", GK_GFX6)
-  .Case("hainan", GK_GFX6)
-  .Case("gfx700", GK_GFX7)
-  .Case("bonaire", GK_GFX7)
-  .Case("kaveri", GK_GFX7)
-  .Case("gfx701", GK_GFX7)
-  .Case("hawaii", GK_GFX7)
-  .Case("gfx702", GK_GFX7)
-  .Case("gfx703", GK_GFX7)
-  .Case("kabini", GK_GFX7)
-  .Case("mullins", GK_GFX7)
-  .Case("gfx800", GK_GFX8)
-  .Case("iceland", GK_GFX8)
-  .Case("gfx801", GK_GFX8)
-  .Case("carrizo", GK_GFX8)
-  .Case("gfx802", GK_GFX8)
-  .Case("tonga", GK_GFX8)
-  .Case("gfx803", GK_GFX8)
-  .Case("fiji", GK_GFX8)
-  .Case("polaris10", GK_GFX8)
-  .Case("polaris11", GK_GFX8)
-  .Case("gfx804", GK_GFX8)
-  .Case("gfx810", GK_GFX8)
-  .Case("stoney", GK_GFX8)
-  .Case("gfx900", GK_GFX9)
-  .Case("gfx901", GK_GFX9)
-  .Case("gfx902", GK_GFX9)
-  .Case("gfx903", GK_GFX9)
-  .Default(GK_NONE);
+  const auto *Result =
+  llvm::find_if(AMDGCNNames, [Name](const NameGPUKind &Kind) {
+return Kind.Name == Name;
+  });
+
+  if (Result == std::end(AMDGCNNames))
+return GK_NONE;
+  return Result->Kind;
+}
+
+void AMDGPUTargetInfo::fillValidCPUList(
+SmallVectorImpl &Values) const {
+  if (getTriple().getArch() == llvm::Triple::amdgcn)
+llvm::for_each(AMDGCNNames, [&Values](const NameGPUKind &Kind) {
+   Values.emplace_back(Kind.Name);});
+  else
+llvm::for_each(R600Names, [&Values](const NameGPUKind &Kind) {
+   Values.empl

r324682 - Add size to constexpr Arrays

2018-02-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Feb  8 15:49:40 2018
New Revision: 324682

URL: http://llvm.org/viewvc/llvm-project?rev=324682&view=rev
Log:
Add size to constexpr Arrays

What seems to be a bug in older versions of MSVC, constexpr
member arrays with a redefinition (to force emission) require
their initial definition to have the size between the brackets.

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.h

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=324682&r1=324681&r2=324682&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.h (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.h Thu Feb  8 15:49:40 2018
@@ -69,7 +69,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTarg
 AMDGPUTargetInfo::GPUKind Kind;
   };
 
-  static constexpr NameGPUKind R600Names[] = {
+  static constexpr NameGPUKind R600Names[25] = {
   {{"r600"}, GK_R600},
   {{"rv610"}, GK_R600},
   {{"rv620"}, GK_R600},
@@ -96,7 +96,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTarg
   {{"cayman"}, GK_CAYMAN},
   {{"aruba"}, GK_CAYMAN},
   };
-  static constexpr NameGPUKind AMDGCNNames[] = {
+  static constexpr NameGPUKind AMDGCNNames[33] = {
   {{"gfx600"}, GK_GFX6},{{"tahiti"}, GK_GFX6},
   {{"gfx601"}, GK_GFX6},{{"pitcairn"}, GK_GFX6},
   {{"verde"}, GK_GFX6}, {{"oland"}, GK_GFX6},


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


r324687 - Fix UBSan issue with PPC::isValidCPUName

2018-02-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Feb  8 16:13:49 2018
New Revision: 324687

URL: http://llvm.org/viewvc/llvm-project?rev=324687&view=rev
Log:
Fix UBSan issue with PPC::isValidCPUName

Apparently storing the pointer to a StringLiteral as
a StringRef caused this section of code to issue a ubsan
warning.  This will hopefully fix that.

Modified:
cfe/trunk/lib/Basic/Targets/PPC.cpp

Modified: cfe/trunk/lib/Basic/Targets/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.cpp?rev=324687&r1=324686&r2=324687&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp Thu Feb  8 16:13:49 2018
@@ -493,8 +493,7 @@ static constexpr llvm::StringLiteral Val
 };
 
 bool PPCTargetInfo::isValidCPUName(StringRef Name) const {
-  const StringRef *FoundName = llvm::find(ValidCPUNames, Name);
-  return FoundName != std::end(ValidCPUNames);
+  return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
 }
 
 void PPCTargetInfo::fillValidCPUList(SmallVectorImpl &Values) const 
{


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


r324902 - Add Invalid-note test negllected in R324673, 324674, 324675, 324676

2018-02-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Feb 12 08:24:08 2018
New Revision: 324902

URL: http://llvm.org/viewvc/llvm-project?rev=324902&view=rev
Log:
Add Invalid-note test negllected in R324673,324674,324675,324676

Added:
cfe/trunk/test/Misc/target-invalid-cpu-note.c

Added: cfe/trunk/test/Misc/target-invalid-cpu-note.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/target-invalid-cpu-note.c?rev=324902&view=auto
==
--- cfe/trunk/test/Misc/target-invalid-cpu-note.c (added)
+++ cfe/trunk/test/Misc/target-invalid-cpu-note.c Mon Feb 12 08:24:08 2018
@@ -0,0 +1,162 @@
+// RUN: not %clang_cc1 -triple armv5--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix ARM
+// ARM: error: unknown target CPU 'not-a-cpu'
+// ARM: note: valid target CPU values are:
+// ARM-SAME: arm2
+
+// RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
+// AARCH64: error: unknown target CPU 'not-a-cpu'
+// AARCH64: note: valid target CPU values are:
+// AARCH64-SAME: cortex-a35,
+
+// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix X86
+// X86: error: unknown target CPU 'not-a-cpu'
+// X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, 
c3,
+// X86-SAME: i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3,
+// X86-SAME: pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott,
+// X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont,
+// X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
+// X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, 
skylake-avx512,
+// X86-SAME: skx, cannonlake, icelake, knl, knm, lakemont, k6, k6-2, k6-3,
+// X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, 
athlon64,
+// X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, 
amdfam10,
+// X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1,
+// X86-SAME: x86-64, geode
+
+// RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix X86_64
+// X86_64: error: unknown target CPU 'not-a-cpu'
+// X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell,
+// X86_64-SAME: atom, silvermont, slm, goldmont, nehalem, corei7, westmere,
+// X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
+// X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cannonlake,
+// X86_64-SAME: icelake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
+// X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
+// X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
+
+// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix NVPTX
+// NVPTX: error: unknown target CPU 'not-a-cpu'
+// NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35,
+// NVPTX-SAME: sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72
+
+// RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix R600
+// R600: error: unknown target CPU 'not-a-cpu'
+// R600: note: valid target CPU values are: r600, rv610, rv620, rv630, rv635,
+// R600-SAME: rs780, rs880, rv670, rv710, rv730, rv740, rv770, palm, cedar,
+// R600-SAME: sumo, sumo2, redwood, juniper, hemlock, cypress, barts, turks,
+// R600-SAME: caicos, cayman, aruba
+
+
+// RUN: not %clang_cc1 -triple amdgcn--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix AMDGCN
+// AMDGCN: error: unknown target CPU 'not-a-cpu'
+// AMDGCN: note: valid target CPU values are: gfx600, tahiti, gfx601, pitcairn,
+// AMDGCN-SAME: verde, oland, hainan, gfx700, bonaire, kaveri, gfx701, hawaii,
+// AMDGCN-SAME: gfx702, gfx703, kabini, mullins, gfx800, iceland, gfx801,
+// AMDGCN-SAME: carrizo, gfx802, tonga, gfx803, fiji, polaris10, polaris11,
+// AMDGCN-SAME: gfx804, gfx810, stoney, gfx900, gfx901, gfx902, gfx903
+
+// RUN: not %clang_cc1 -triple wasm64--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix WEBASM
+// WEBASM: error: unknown target CPU 'not-a-cpu'
+// WEBASM: note: valid target CPU values are: mvp, bleeding-edge, generic
+
+// RUN: not %clang_cc1 -triple systemz--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix SYSTEMZ
+// SYSTEMZ: error: unknown target CPU 'not-a-cpu'
+// SYSTEMZ: note: valid target CPU values are: arch8, z10, arch9, z196, arch10,
+// SYSTEMZ-SAME: zEC12, arch11, z13, arch12, z14
+
+// RUN: not %clang_cc1 -triple sparc--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix SPARC
+// SPARC: error: unknown target CPU 'not-a-cpu'
+// SPARC: note: valid target CPU values are: v8, supersparc, sparclite, f93

r324907 - Make attribute-target on a Definition-after-use update the LLVM attributes

2018-02-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Feb 12 09:01:41 2018
New Revision: 324907

URL: http://llvm.org/viewvc/llvm-project?rev=324907&view=rev
Log:
Make attribute-target on a Definition-after-use update the LLVM attributes

As reported here: https://bugs.llvm.org/show_bug.cgi?id=36301
The issue is that the 'use' causes the plain declaration to emit
the attributes to LLVM-IR. However, if the definition added it
later, these would silently disappear.

This commit extracts that logic to its own function in CodeGenModule,
and has the attribute-applications done during 'definition' update
the attributes properly.

Differential Revision: https://reviews.llvm.org/D43095

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGen/attr-target-x86.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=324907&r1=324906&r2=324907&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Feb 12 09:01:41 2018
@@ -1877,46 +1877,7 @@ void CodeGenModule::ConstructAttributeLi
 TargetDecl->hasAttr()));
 FuncAttrs.addAttribute("disable-tail-calls",
llvm::toStringRef(DisableTailCalls));
-
-// Add target-cpu and target-features attributes to functions. If
-// we have a decl for the function and it has a target attribute then
-// parse that and add it to the feature set.
-StringRef TargetCPU = getTarget().getTargetOpts().CPU;
-std::vector Features;
-const FunctionDecl *FD = dyn_cast_or_null(TargetDecl);
-if (FD && FD->hasAttr()) {
-  llvm::StringMap FeatureMap;
-  getFunctionFeatureMap(FeatureMap, FD);
-
-  // Produce the canonical string for this set of features.
-  for (llvm::StringMap::const_iterator it = FeatureMap.begin(),
- ie = FeatureMap.end();
-   it != ie; ++it)
-Features.push_back((it->second ? "+" : "-") + it->first().str());
-
-  // Now add the target-cpu and target-features to the function.
-  // While we populated the feature map above, we still need to
-  // get and parse the target attribute so we can get the cpu for
-  // the function.
-  const auto *TD = FD->getAttr();
-  TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
-  if (ParsedAttr.Architecture != "" &&
-  getTarget().isValidCPUName(ParsedAttr.Architecture))
-TargetCPU = ParsedAttr.Architecture;
-} else {
-  // Otherwise just add the existing target cpu and target features to the
-  // function.
-  Features = getTarget().getTargetOpts().Features;
-}
-
-if (TargetCPU != "")
-  FuncAttrs.addAttribute("target-cpu", TargetCPU);
-if (!Features.empty()) {
-  std::sort(Features.begin(), Features.end());
-  FuncAttrs.addAttribute(
-  "target-features",
-  llvm::join(Features, ","));
-}
+GetCPUAndFeaturesAttributes(TargetDecl, FuncAttrs);
   }
 
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324907&r1=324906&r2=324907&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Feb 12 09:01:41 2018
@@ -1248,6 +1248,52 @@ void CodeGenModule::setAliasAttributes(c
 GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
 }
 
+bool CodeGenModule::GetCPUAndFeaturesAttributes(const Decl *D,
+llvm::AttrBuilder &Attrs) {
+  // Add target-cpu and target-features attributes to functions. If
+  // we have a decl for the function and it has a target attribute then
+  // parse that and add it to the feature set.
+  StringRef TargetCPU = getTarget().getTargetOpts().CPU;
+  std::vector Features;
+  const auto *FD = dyn_cast_or_null(D);
+  FD = FD ? FD->getMostRecentDecl() : FD;
+  const auto *TD = FD ? FD->getAttr() : nullptr;
+  bool AddedAttr = false;
+  if (TD) {
+llvm::StringMap FeatureMap;
+getFunctionFeatureMap(FeatureMap, FD);
+
+// Produce the canonical string for this set of features.
+for (const llvm::StringMap::value_type &Entry : FeatureMap)
+  Features.push_back((Entry.getValue() ? "+" : "-") + 
Entry.getKey().str());
+
+// Now add the target-cpu and target-features to the function.
+// While we populated the feature map above, we still need to
+// get and parse the target attribute so we can get the cpu for
+// the function.
+TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
+if (ParsedAttr.Architecture != "" &&
+getTarget()

r324909 - Update target-note-test to be current with the AMDGPU changes

2018-02-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Feb 12 09:19:57 2018
New Revision: 324909

URL: http://llvm.org/viewvc/llvm-project?rev=324909&view=rev
Log:
Update target-note-test to be current with the AMDGPU changes

Modified:
cfe/trunk/test/Misc/target-invalid-cpu-note.c

Modified: cfe/trunk/test/Misc/target-invalid-cpu-note.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/target-invalid-cpu-note.c?rev=324909&r1=324908&r2=324909&view=diff
==
--- cfe/trunk/test/Misc/target-invalid-cpu-note.c (original)
+++ cfe/trunk/test/Misc/target-invalid-cpu-note.c Mon Feb 12 09:19:57 2018
@@ -39,19 +39,19 @@
 
 // RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix R600
 // R600: error: unknown target CPU 'not-a-cpu'
-// R600: note: valid target CPU values are: r600, rv610, rv620, rv630, rv635,
-// R600-SAME: rs780, rs880, rv670, rv710, rv730, rv740, rv770, palm, cedar,
-// R600-SAME: sumo, sumo2, redwood, juniper, hemlock, cypress, barts, turks,
-// R600-SAME: caicos, cayman, aruba
+// R600: note: valid target CPU values are: r600, rv630, rv635, r630, rs780, 
+// R600-SAME: rs880, rv610, rv620, rv670, rv710, rv730, rv740, rv770, cedar, 
+// R600-SAME: palm, cypress, hemlock, juniper, redwood, sumo, sumo2, barts, 
+// R600-SAME: caicos, turks, aruba, cayman
 
 
 // RUN: not %clang_cc1 -triple amdgcn--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix AMDGCN
 // AMDGCN: error: unknown target CPU 'not-a-cpu'
-// AMDGCN: note: valid target CPU values are: gfx600, tahiti, gfx601, pitcairn,
-// AMDGCN-SAME: verde, oland, hainan, gfx700, bonaire, kaveri, gfx701, hawaii,
-// AMDGCN-SAME: gfx702, gfx703, kabini, mullins, gfx800, iceland, gfx801,
-// AMDGCN-SAME: carrizo, gfx802, tonga, gfx803, fiji, polaris10, polaris11,
-// AMDGCN-SAME: gfx804, gfx810, stoney, gfx900, gfx901, gfx902, gfx903
+// AMDGCN: note: valid target CPU values are: gfx600, tahiti, gfx601, hainan,
+// AMDGCN-SAME: oland, pitcairn, verde, gfx700, kaveri, gfx701, hawaii, gfx702,
+// AMDGCN-SAME: gfx703, kabini, mullins, gfx704, bonaire, gfx801, carrizo, 
+// AMDGCN-SAME: gfx802, iceland, tonga, gfx803, fiji, polaris10, polaris11,
+// AMDGCN-SAME: gfx810, stoney, gfx900, gfx902
 
 // RUN: not %clang_cc1 -triple wasm64--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix WEBASM
 // WEBASM: error: unknown target CPU 'not-a-cpu'


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


r324915 - Further cleanup to Driver mode code, as suggested by dblaikie [NFC]

2018-02-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Feb 12 09:47:01 2018
New Revision: 324915

URL: http://llvm.org/viewvc/llvm-project?rev=324915&view=rev
Log:
Further cleanup to Driver mode code, as suggested by dblaikie [NFC]

Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=324915&r1=324914&r2=324915&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Feb 12 09:47:01 2018
@@ -148,15 +148,13 @@ void Driver::setDriverModeFromOption(Str
 return;
   StringRef Value = Opt.drop_front(OptName.size());
 
-  auto M = llvm::StringSwitch>(Value)
-   .Case("gcc", GCCMode)
-   .Case("g++", GXXMode)
-   .Case("cpp", CPPMode)
-   .Case("cl", CLMode)
-   .Default(None);
-
-  if (M)
-Mode = M.getValue();
+  if (auto M = llvm::StringSwitch>(Value)
+   .Case("gcc", GCCMode)
+   .Case("g++", GXXMode)
+   .Case("cpp", CPPMode)
+   .Case("cl", CLMode)
+   .Default(None))
+Mode = *M;
   else
 Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
 }


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


r325081 - Implement function attribute artificial

2018-02-13 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb 13 16:14:07 2018
New Revision: 325081

URL: http://llvm.org/viewvc/llvm-project?rev=325081&view=rev
Log:
Implement function attribute artificial

Added support in clang for GCC function attribute 'artificial'. This attribute 
is used to control stepping behavior of debugger with respect to inline 
functions.

Patch By: Elizabeth Andrews (eandrews)

Differential Revision: https://reviews.llvm.org/D43259


Added:
cfe/trunk/test/CodeGen/artificial.c
cfe/trunk/test/Sema/artificial.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 13 16:14:07 2018
@@ -111,6 +111,9 @@ def SharedVar : SubsetSubjecthasGlobalStorage()}], "global variables">;
 
+def InlineFunction : SubsetSubjectisInlineSpecified()}], "inline functions">;
+
 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
 // type to be a class, not a definition. This makes it impossible to create an
 // attribute subject which accepts a Decl. Normally, this is not a problem,
@@ -588,6 +591,12 @@ def AlwaysInline : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def Artificial : InheritableAttr {
+  let Spellings = [GCC<"artificial">];
+  let Subjects = SubjectList<[InlineFunction], WarnDiag>;
+  let Documentation = [ArtificialDocs];
+}
+
 def XRayInstrument : InheritableAttr {
   let Spellings = [Clang<"xray_always_instrument">,
Clang<"xray_never_instrument">];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Feb 13 16:14:07 2018
@@ -3273,3 +3273,13 @@ For more information see
 or `msvc documentation `_.
 }];
 }
+
+def ArtificialDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``artificial`` attribute is used with inline functions to treat the inline 
+function as a unit while debugging. For more information see GCC_ 
documentation.
+
+.. _GCC: https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html
+  }];
+}

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb 13 16:14:07 2018
@@ -3235,7 +3235,7 @@ void CGDebugInfo::EmitFunctionStart(Glob
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Feb 13 16:14:07 2018
@@ -6057,6 +6057,9 @@ static void ProcessDeclAttribute(Sema &S
   case AttributeList::AT_AlwaysInline:
 handleAlwaysInlineAttr(S, D, Attr);
 break;
+  case AttributeList::AT_Artificial:
+handleSimpleAttribute(S, D, Attr);
+break;
   case AttributeList::AT_AnalyzerNoReturn:
 handleAnalyzerNoReturnAttr(S, D, Attr);
 break;

Added: cfe/trunk/test/CodeGen/artificial.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/artificial.c?rev=325081&view=auto
==
--- cfe/trunk/test/CodeGen/artificial.c (added)
+++ cfe/trunk/test/CodeGen/artificial.c Tue Feb 13 16:14:07 2018
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck %s
+
+extern void foo();
+// CHECK: !DISubprogram(name: "foo"
+// CHECK-SAME: flags: DIFlagArtificial
+inline void __attribute__((artificial)) foo() {}
+
+void baz() {
+  foo();
+}

Added: cfe/trunk/test/Sema/artificial.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/artificial.c?rev=325081&view=auto
==

r325186 - Improve documentation for attribute artificial

2018-02-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Feb 14 15:00:31 2018
New Revision: 325186

URL: http://llvm.org/viewvc/llvm-project?rev=325186&view=rev
Log:
Improve documentation for attribute artificial

This patch is related to https://reviews.llvm.org/rC325081

The patch improves documentation for the attribute and removes reference to GCC 
documentation.

Patch By: Elizabeth Andrews (eandrews)
Differential Revision: https://reviews.llvm.org/D43321

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=325186&r1=325185&r2=325186&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Feb 14 15:00:31 2018
@@ -3277,9 +3277,9 @@ or `msvc documentation 

r325364 - Clean up 'target' attribute diagnostics

2018-02-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Feb 16 09:31:59 2018
New Revision: 325364

URL: http://llvm.org/viewvc/llvm-project?rev=325364&view=rev
Log:
Clean up 'target' attribute diagnostics

There were a few issues previously with the target
attribute diagnostics implementation that lead to the
attribute being added to the AST despite having an error
in it.

This patch changes that, and adds a test to ensure it
does not get added to the AST.

Differential Revision: https://reviews.llvm.org/D43359

Added:
cfe/trunk/test/Sema/attr-target-ast.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-target.c
cfe/trunk/test/SemaCXX/attr-target-mv.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=325364&r1=325363&r2=325364&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb 16 09:31:59 
2018
@@ -2445,8 +2445,8 @@ def err_attribute_requires_positive_inte
 def err_attribute_requires_opencl_version : Error<
   "%0 attribute requires OpenCL version %1%select{| or above}2">;
 def warn_unsupported_target_attribute
-: Warning<"ignoring %select{unsupported|duplicate}0"
-  "%select{| architecture}1 '%2' in the target attribute string">,
+: Warning<"%select{unsupported|duplicate}0%select{| architecture}1 '%2' in"
+  " the 'target' attribute string; 'target' attribute ignored">,
   InGroup;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported for this target">;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=325364&r1=325363&r2=325364&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Feb 16 09:31:59 2018
@@ -3024,15 +3024,16 @@ bool Sema::checkTargetAttr(SourceLocatio
  << Unsupported << None << CurFeature;
   }
 
-  return true;
+  return false;
 }
 
 static void handleTargetAttr(Sema &S, Decl *D, const AttributeList &AL) {
   StringRef Str;
   SourceLocation LiteralLoc;
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc) ||
-  !S.checkTargetAttr(LiteralLoc, Str))
+  S.checkTargetAttr(LiteralLoc, Str))
 return;
+
   unsigned Index = AL.getAttributeSpellingListIndex();
   TargetAttr *NewAttr =
   ::new (S.Context) TargetAttr(AL.getRange(), S.Context, Str, Index);

Added: cfe/trunk/test/Sema/attr-target-ast.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-target-ast.c?rev=325364&view=auto
==
--- cfe/trunk/test/Sema/attr-target-ast.c (added)
+++ cfe/trunk/test/Sema/attr-target-ast.c Fri Feb 16 09:31:59 2018
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ast-dump %s | FileCheck %s
+
+int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; }
+// CHECK-NOT: arch=hiss
+// CHECK-NOT: arch=woof

Modified: cfe/trunk/test/Sema/attr-target.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-target.c?rev=325364&r1=325363&r2=325364&view=diff
==
--- cfe/trunk/test/Sema/attr-target.c (original)
+++ cfe/trunk/test/Sema/attr-target.c Fri Feb 16 09:31:59 2018
@@ -1,14 +1,21 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo() { return 4; }
-int __attribute__((target())) bar() { return 4; } //expected-error {{'target' 
attribute takes one argument}}
-int __attribute__((target("tune=sandybridge"))) baz() { return 4; } 
//expected-warning {{ignoring unsupported 'tune=' in the target attribute 
string}}
-int __attribute__((target("fpmath=387"))) walrus() { return 4; } 
//expected-warning {{ignoring unsupported 'fpmath=' in the target attribute 
string}}
-int __attribute__((target("avx,sse4.2,arch=hiss"))) meow() {  return 4; 
}//expected-warning {{ignoring unsupported architecture 'hiss' in the target 
attribute string}}
-int __attribute__((target("woof"))) bark() {  return 4; }//expected-warning 
{{ignoring unsupported 'woof' in the target attribute string}}
-int __attribute__((target("arch="))) turtle() { return 4; } // no warning, 
same as saying 'nothing'.
-int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; } 
//expected-warning {{ignoring unsupported architecture 'hiss' in the target 
attribute string}}
-int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 
4; } //expected-warning {{ignoring duplicate 'arch=' in the targ

r325610 - Correct multiversion unsupported target behavior, add a test.

2018-02-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb 20 10:44:50 2018
New Revision: 325610

URL: http://llvm.org/viewvc/llvm-project?rev=325610&view=rev
Log:
Correct multiversion unsupported target behavior, add a test.

Multiversioning SEMA failed to set the declaration as invalid on unsupported
targets.  This patch does that.

Additionally, I noticed that there is no test to validate this error message.
This patch adds one, and uses 'mips' as the test architecture.  

Added:
cfe/trunk/test/Sema/attr-target-unsupported.c
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=325610&r1=325609&r2=325610&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 20 10:44:50 2018
@@ -9365,6 +9365,7 @@ static bool CheckMultiVersionFunction(Se
   }
   if (!S.getASTContext().getTargetInfo().supportsMultiVersioning()) {
 S.Diag(NewFD->getLocation(), diag::err_multiversion_not_supported);
+NewFD->setInvalidDecl();
 return true;
   }
 
@@ -9407,6 +9408,7 @@ static bool CheckMultiVersionFunction(Se
 if (!S.getASTContext().getTargetInfo().supportsMultiVersioning()) {
   S.Diag(NewFD->getLocation(), diag::err_multiversion_not_supported);
   S.Diag(OldFD->getLocation(), diag::note_previous_declaration);
+  NewFD->setInvalidDecl();
   return true;
 }
 

Added: cfe/trunk/test/Sema/attr-target-unsupported.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-target-unsupported.c?rev=325610&view=auto
==
--- cfe/trunk/test/Sema/attr-target-unsupported.c (added)
+++ cfe/trunk/test/Sema/attr-target-unsupported.c Tue Feb 20 10:44:50 2018
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu  -fsyntax-only -verify %s
+
+void __attribute__((target("arch=mips1")))
+foo(void) {}
+// expected-error@+3 {{function multiversioning is not supported on the 
current target}}
+// expected-note@-2 {{previous declaration is here}}
+void __attribute__((target("arch=mips2")))
+foo(void) {}
+
+// expected-error@+2 {{function multiversioning is not supported on the 
current target}}
+void __attribute__((target("default")))
+bar(void){}


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


r325633 - [NFC] In Multiversion Check function, switch to return Diag

2018-02-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb 20 14:25:28 2018
New Revision: 325633

URL: http://llvm.org/viewvc/llvm-project?rev=325633&view=rev
Log:
[NFC] In Multiversion Check function, switch to return Diag

This function did a lot of 'Diag, return true' stuff.  This resulted in needing
to introduce scopes in quite a few places.  This patch replaces useages of a
single "S.Diag" followed by return true with simply "return S.Diag".

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=325633&r1=325632&r2=325633&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 20 14:25:28 2018
@@ -9225,62 +9225,49 @@ static bool CheckMultiVersionAdditionalR
 return true;
   }
 
-  if (std::distance(NewFD->attr_begin(), NewFD->attr_end()) != 1) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_no_other_attrs);
-return true;
-  }
-
-  if (NewFD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
-<< FuncTemplates;
-return true;
-  }
+  if (std::distance(NewFD->attr_begin(), NewFD->attr_end()) != 1)
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_no_other_attrs);
 
+  if (NewFD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate)
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << FuncTemplates;
 
   if (const auto *NewCXXFD = dyn_cast(NewFD)) {
-if (NewCXXFD->isVirtual()) {
-  S.Diag(NewCXXFD->getLocation(), diag::err_multiversion_doesnt_support)
-  << VirtFuncs;
-  return true;
-}
-
-if (const auto *NewCXXCtor = dyn_cast(NewFD)) {
-  S.Diag(NewCXXCtor->getLocation(), diag::err_multiversion_doesnt_support)
-  << Constructors;
-  return true;
-}
-
-if (const auto *NewCXXDtor = dyn_cast(NewFD)) {
-  S.Diag(NewCXXDtor->getLocation(), diag::err_multiversion_doesnt_support)
-  << Destructors;
-  return true;
-}
-  }
-
-  if (NewFD->isDeleted()) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
-  << DeletedFuncs;
-  }
-  if (NewFD->isDefaulted()) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
-  << DefaultedFuncs;
-  }
+if (NewCXXFD->isVirtual())
+  return S.Diag(NewCXXFD->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << VirtFuncs;
+
+if (const auto *NewCXXCtor = dyn_cast(NewFD))
+  return S.Diag(NewCXXCtor->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << Constructors;
+
+if (const auto *NewCXXDtor = dyn_cast(NewFD))
+  return S.Diag(NewCXXDtor->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << Destructors;
+  }
+
+  if (NewFD->isDeleted())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DeletedFuncs;
+
+  if (NewFD->isDefaulted())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DefaultedFuncs;
 
   QualType NewQType = S.getASTContext().getCanonicalType(NewFD->getType());
   const auto *NewType = cast(NewQType);
   QualType NewReturnType = NewType->getReturnType();
 
-  if (NewReturnType->isUndeducedType()) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
-<< DeducedReturn;
-return true;
-  }
+  if (NewReturnType->isUndeducedType())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DeducedReturn;
 
   // Only allow transition to MultiVersion if it hasn't been used.
-  if (OldFD && CausesMV && OldFD->isUsed(false)) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used);
-return true;
-  }
+  if (OldFD && CausesMV && OldFD->isUsed(false))
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used);
 
   // Ensure the return type is identical.
   if (OldFD) {
@@ -9289,38 +9276,31 @@ static bool CheckMultiVersionAdditionalR
 FunctionType::ExtInfo OldTypeInfo = OldType->getExtInfo();
 FunctionType::ExtInfo NewTypeInfo = NewType->getExtInfo();
 
-if (OldTypeInfo.getCC() != NewTypeInfo.getCC()) {
-  S.Diag(NewFD->getLocation(), diag::err_multiversion_diff) << CallingConv;
-  return true;
-}
+if (OldTypeInfo.getCC() != NewTypeInfo.getCC())
+  return S.Diag(NewFD->getLocation(), diag::err_multiversion_diff)
+ << CallingConv;
 
 QualType OldReturnType = OldType->getReturnType();
 
-if (OldReturnType != NewReturnType) {
-  S.Diag(NewFD->getLocation(), diag::err_multiversion_diff) << ReturnType;
-  return true;
-}
-
-if (OldFD->isConstexpr() != NewFD->isConstexpr()) {
-  S.Diag(NewF

r325716 - Replace incorrect usage of isInvalidDecl with intended setInvalidDecl

2018-02-21 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Feb 21 12:29:05 2018
New Revision: 325716

URL: http://llvm.org/viewvc/llvm-project?rev=325716&view=rev
Log:
Replace incorrect usage of isInvalidDecl with intended setInvalidDecl 

This typo would cause an attempt to multiversion 'main' to issue an
error, but not mark the function as invalid.  This patch fixes it.


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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=325716&r1=325715&r2=325716&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Feb 21 12:29:05 2018
@@ -9324,7 +9324,7 @@ static bool CheckMultiVersionFunction(Se
   if (NewFD->isMain()) {
 if (NewTA && NewTA->isDefaultVersion()) {
   S.Diag(NewFD->getLocation(), diag::err_multiversion_not_allowed_on_main);
-  NewFD->isInvalidDecl();
+  NewFD->setInvalidDecl();
   return true;
 }
 return false;


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


r303798 - For Microsoft compatibility, set fno_operator_names

2017-05-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed May 24 14:31:19 2017
New Revision: 303798

URL: http://llvm.org/viewvc/llvm-project?rev=303798&view=rev
Log:
For Microsoft compatibility, set fno_operator_names

There's a Microsoft header in the Windows SDK which won't 
compile with clang because it uses an operator name (and) 
as a field name. This patch allows that file to compile by 
setting the option which disables operator names. 
The header which doesn't compile  C:/Program Files (x86)/
Windows Kits/10/include/10.0.14393.0/um\Query.h:259:40: 
error: expected member name or ';' after declaration specifiers

  /* [case()] */ NODERESTRICTION or;
   ~~~ ^

   1 error generated.

Contributed for Melanie Blower

Differential Revision:https://reviews.llvm.org/D33505

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May 24 14:31:19 2017
@@ -1882,7 +1882,7 @@ static void ParseLangArgs(LangOptions &O
   Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
   Opts.GNUKeywords);
 
-  if (Args.hasArg(OPT_fno_operator_names))
+  if (Args.hasArg(OPT_fno_operator_names) || 
Args.hasArg(OPT_fms_compatibility))
 Opts.CXXOperatorNames = 0;
 
   if (Args.hasArg(OPT_fcuda_is_device))

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Wed May 24 14:31:19 2017
@@ -261,9 +261,8 @@ int __identifier(else} = __identifier(fo
 #define identifier_weird(x) __identifier(x
 int k = identifier_weird(if)); // expected-error {{use of undeclared 
identifier 'if'}}
 
-// This is a bit weird, but the alternative tokens aren't keywords, and this
-// behavior matches MSVC. FIXME: Consider supporting this anyway.
-extern int __identifier(and) r; // expected-error {{cannot convert '&&' token 
to an identifier}}
+// 'and' is not an operator name with Microsoft compatibility.
+extern int __identifier(and) r; // expected-error {{expected ';' after top 
level declarator}}
 
 void f() {
   __identifier(() // expected-error {{cannot convert '(' token to an 
identifier}}
@@ -355,7 +354,6 @@ void TestProperty() {
   ++sp.V11;
 }
 
-//expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro name}}
 #define and foo
 
 struct __declspec(uuid("---C000-0046")) 
__declspec(novtable) IUnknown {};

Modified: cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp (original)
+++ cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp Wed May 24 14:31:19 2017
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
 // RUN: %clang_cc1 %s -E -verify -fno-operator-names
+// RUN: %clang_cc1 %s-verify -DTESTWIN -fms-compatibility
 
 #ifndef OPERATOR_NAMES
 //expected-error@+3 {{token is not a valid binary operator in a preprocessor 
subexpression}}
@@ -29,3 +30,14 @@
 #ifdef and
 #warning and is defined
 #endif
+
+#ifdef TESTWIN
+// For cl compatibility, fno-operator-names is enabled by default.
+int and;
+int bitand;
+int bitor;
+int compl;
+int not;
+int or;
+int xor;
+#endif


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


[clang-tools-extra] r303872 - Disable MSVC-Compat mode for two tests that use C++Operator Names

2017-05-25 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu May 25 10:39:24 2017
New Revision: 303872

URL: http://llvm.org/viewvc/llvm-project?rev=303872&view=rev
Log:
Disable MSVC-Compat mode for two tests that use C++Operator Names

MSVC doesn't support C++ operator names (using 'or' instead of ||, 
'not' instead of '!', etc), so this was disabled in MSVC mode in r303798.
This fixes the regression noticed on the buildbots.

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp?rev=303872&r1=303871&r2=303872&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
 Thu May 25 10:39:24 2017
@@ -2,7 +2,7 @@
 // RUN: -config='{CheckOptions: \
 // RUN:  [{key: readability-implicit-bool-cast.AllowConditionalIntegerCasts, 
value: 1}, \
 // RUN:   {key: readability-implicit-bool-cast.AllowConditionalPointerCasts, 
value: 1}]}' \
-// RUN: -- -std=c++11
+// RUN: -- -std=c++11 -fno-ms-compatibility
 
 template
 void functionTaking(T);

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp?rev=303872&r1=303871&r2=303872&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
Thu May 25 10:39:24 2017
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-implicit-bool-cast %t
+// RUN: %check_clang_tidy %s -fno-ms-compatibility 
readability-implicit-bool-cast %t
 
 // We need NULL macro, but some buildbots don't like including  header
 // This is a portable way of getting it to work


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


[clang-tools-extra] r303877 - Clang-tidy doesn't understand -fno-ms-compatibility, so just removing 'not'

2017-05-25 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu May 25 11:07:19 2017
New Revision: 303877

URL: http://llvm.org/viewvc/llvm-project?rev=303877&view=rev
Log:
Clang-tidy doesn't understand -fno-ms-compatibility, so just removing 'not' 

Modified:
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp?rev=303877&r1=303876&r2=303877&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
Thu May 25 11:07:19 2017
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s -fno-ms-compatibility 
readability-implicit-bool-cast %t
+// RUN: %check_clang_tidy %s readability-implicit-bool-cast %t
 
 // We need NULL macro, but some buildbots don't like including  header
 // This is a portable way of getting it to work
@@ -264,7 +264,7 @@ void implicitCastInNegationExpressions()
   // CHECK-FIXES: bool boolComingFromNegatedChar = (character == 0);
 
   int* pointer = nullptr;
-  bool boolComingFromNegatedPointer = not pointer;
+  bool boolComingFromNegatedPointer = ! pointer;
   // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: implicit cast 'int *' -> bool
   // CHECK-FIXES: bool boolComingFromNegatedPointer = pointer == nullptr;
 }


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


[clang-tools-extra] r303881 - Revert 303872/303877 since the patch that caused these issues

2017-05-25 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu May 25 11:23:00 2017
New Revision: 303881

URL: http://llvm.org/viewvc/llvm-project?rev=303881&view=rev
Log:
Revert 303872/303877 since the patch that caused these issues 
is also being reverted.

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp?rev=303881&r1=303880&r2=303881&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
 Thu May 25 11:23:00 2017
@@ -2,7 +2,7 @@
 // RUN: -config='{CheckOptions: \
 // RUN:  [{key: readability-implicit-bool-cast.AllowConditionalIntegerCasts, 
value: 1}, \
 // RUN:   {key: readability-implicit-bool-cast.AllowConditionalPointerCasts, 
value: 1}]}' \
-// RUN: -- -std=c++11 -fno-ms-compatibility
+// RUN: -- -std=c++11
 
 template
 void functionTaking(T);

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp?rev=303881&r1=303880&r2=303881&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
Thu May 25 11:23:00 2017
@@ -264,7 +264,7 @@ void implicitCastInNegationExpressions()
   // CHECK-FIXES: bool boolComingFromNegatedChar = (character == 0);
 
   int* pointer = nullptr;
-  bool boolComingFromNegatedPointer = ! pointer;
+  bool boolComingFromNegatedPointer = not  pointer;
   // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: implicit cast 'int *' -> bool
   // CHECK-FIXES: bool boolComingFromNegatedPointer = pointer == nullptr;
 }


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


r303882 - Revert MSVC CXXOperatorNames patch due to issues with Chromium

2017-05-25 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu May 25 11:24:49 2017
New Revision: 303882

URL: http://llvm.org/viewvc/llvm-project?rev=303882&view=rev
Log:
Revert MSVC CXXOperatorNames patch due to issues with Chromium

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=303882&r1=303881&r2=303882&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu May 25 11:24:49 2017
@@ -1882,7 +1882,7 @@ static void ParseLangArgs(LangOptions &O
   Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
   Opts.GNUKeywords);
 
-  if (Args.hasArg(OPT_fno_operator_names) || 
Args.hasArg(OPT_fms_compatibility))
+  if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
   if (Args.hasArg(OPT_fcuda_is_device))

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=303882&r1=303881&r2=303882&view=diff
==
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Thu May 25 11:24:49 2017
@@ -261,8 +261,9 @@ int __identifier(else} = __identifier(fo
 #define identifier_weird(x) __identifier(x
 int k = identifier_weird(if)); // expected-error {{use of undeclared 
identifier 'if'}}
 
-// 'and' is not an operator name with Microsoft compatibility.
-extern int __identifier(and) r; // expected-error {{expected ';' after top 
level declarator}}
+// This is a bit weird, but the alternative tokens aren't keywords, and this
+// behavior matches MSVC. FIXME: Consider supporting this anyway.
+extern int __identifier(and) r; // expected-error {{cannot convert '&&' token 
to an identifier}}
 
 void f() {
   __identifier(() // expected-error {{cannot convert '(' token to an 
identifier}}
@@ -354,6 +355,7 @@ void TestProperty() {
   ++sp.V11;
 }
 
+//expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro name}}
 #define and foo
 
 struct __declspec(uuid("---C000-0046")) 
__declspec(novtable) IUnknown {};

Modified: cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp?rev=303882&r1=303881&r2=303882&view=diff
==
--- cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp (original)
+++ cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp Thu May 25 11:24:49 2017
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
 // RUN: %clang_cc1 %s -E -verify -fno-operator-names
-// RUN: %clang_cc1 %s-verify -DTESTWIN -fms-compatibility
 
 #ifndef OPERATOR_NAMES
 //expected-error@+3 {{token is not a valid binary operator in a preprocessor 
subexpression}}
@@ -30,14 +29,3 @@
 #ifdef and
 #warning and is defined
 #endif
-
-#ifdef TESTWIN
-// For cl compatibility, fno-operator-names is enabled by default.
-int and;
-int bitand;
-int bitor;
-int compl;
-int not;
-int or;
-int xor;
-#endif


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


[clang-tools-extra] r303909 - Earlier revert introduced an extra space, remove it.

2017-05-25 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu May 25 15:29:17 2017
New Revision: 303909

URL: http://llvm.org/viewvc/llvm-project?rev=303909&view=rev
Log:
Earlier revert introduced an extra space, remove it.

Modified:
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp?rev=303909&r1=303908&r2=303909&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
Thu May 25 15:29:17 2017
@@ -264,7 +264,7 @@ void implicitCastInNegationExpressions()
   // CHECK-FIXES: bool boolComingFromNegatedChar = (character == 0);
 
   int* pointer = nullptr;
-  bool boolComingFromNegatedPointer = not  pointer;
+  bool boolComingFromNegatedPointer = not pointer;
   // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: implicit cast 'int *' -> bool
   // CHECK-FIXES: bool boolComingFromNegatedPointer = pointer == nullptr;
 }


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


r305087 - support operator keywords used in Windows SDK

2017-06-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jun  9 11:29:35 2017
New Revision: 305087

URL: http://llvm.org/viewvc/llvm-project?rev=305087&view=rev
Log:
support operator keywords used in Windows SDK

to support operator keywords used in Windows SDK, alter token type when 
seen in system headers

Hello, I submitted D33505 to address this problem, but the 
proposal was rejected as too big a hammer.
This change will allow clang to parse the WindowsSDK header  
which uses the operator name "or" as a field name. Treat cpp operator 
keywords as ordinary identifiers inside the Microsoft headers, but 
treat them as usual in the user's program.

Original Submitter: Melanie Blower (mibintc)

Differential Revision: https://reviews.llvm.org/D33782



Added:
cfe/trunk/test/Headers/ms-cppoperkey.cpp
cfe/trunk/test/Headers/ms-cppoperkey1.cpp
cfe/trunk/test/Headers/ms-cppoperkey2.cpp
Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=305087&r1=305086&r2=305087&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Jun  9 11:29:35 2017
@@ -580,7 +580,11 @@ IdentifierInfo *Preprocessor::LookUpIden
 
   // Update the token info (identifier info and appropriate token kind).
   Identifier.setIdentifierInfo(II);
-  Identifier.setKind(II->getTokenID());
+  if (getLangOpts().MSVCCompat && II->isCPlusPlusOperatorKeyword() &&
+  getSourceManager().isInSystemHeader(Identifier.getLocation()))
+Identifier.setKind(clang::tok::identifier);
+  else
+Identifier.setKind(II->getTokenID());
 
   return II;
 }

Added: cfe/trunk/test/Headers/ms-cppoperkey.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-cppoperkey.cpp?rev=305087&view=auto
==
--- cfe/trunk/test/Headers/ms-cppoperkey.cpp (added)
+++ cfe/trunk/test/Headers/ms-cppoperkey.cpp Fri Jun  9 11:29:35 2017
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 \
+// RUN: -fms-compatibility -x c++-cpp-output \
+// RUN: -ffreestanding -fsyntax-only -Werror \
+// RUN: %s -verify
+// expected-no-diagnostics
+# 1 "t.cpp"
+# 1 "query.h" 1 3
+// MS header  uses operator keyword as field name.  
+// Compile without syntax errors.
+struct tagRESTRICTION
+  {
+   union _URes 
+ {
+   int or; // Note use of cpp operator token
+ } res;
+  };

Added: cfe/trunk/test/Headers/ms-cppoperkey1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-cppoperkey1.cpp?rev=305087&view=auto
==
--- cfe/trunk/test/Headers/ms-cppoperkey1.cpp (added)
+++ cfe/trunk/test/Headers/ms-cppoperkey1.cpp Fri Jun  9 11:29:35 2017
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 \
+// RUN: -fms-compatibility -x c++-cpp-output \
+// RUN: -ffreestanding -fsyntax-only -Werror \
+// RUN: %s -verify
+
+
+# 1 "t.cpp"
+# 1 "query.h" 1 3 4
+// MS header  uses operator keyword as field name.  
+// Compile without syntax errors.
+struct tagRESTRICTION
+  {
+   union _URes 
+ {
+   int or; // Note use of cpp operator token
+ } res;
+  };
+   ;
+
+int aa ( int x)
+{
+  // In system header code, treat operator keyword as identifier.
+  if ( // expected-note{{to match this '('}}
+x>1 or x<0) return 1; // expected-error{{expected ')'}}
+  else return 0;  
+}
+

Added: cfe/trunk/test/Headers/ms-cppoperkey2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-cppoperkey2.cpp?rev=305087&view=auto
==
--- cfe/trunk/test/Headers/ms-cppoperkey2.cpp (added)
+++ cfe/trunk/test/Headers/ms-cppoperkey2.cpp Fri Jun  9 11:29:35 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1  -triple x86_64-pc-win32 -fms-compatibility \
+// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
+// RUN: %clang_cc1 \
+// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
+// expected-no-diagnostics
+int bb ( int x)
+{
+  // In user code, treat operator keyword as operator keyword.
+  if ( x>1 or x<0) return 1;
+  else return 0;  
+}


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


r305128 - Support operator keywords used in Windows SDK(fix ubsan)

2017-06-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jun  9 17:50:02 2017
New Revision: 305128

URL: http://llvm.org/viewvc/llvm-project?rev=305128&view=rev
Log:
Support operator keywords used in Windows SDK(fix ubsan)

UBSan found an issue with a nullptr being assigned to a reference.
This was because a following function went back and checked the 
identifier in the CPPOperatorName case.  This patch corrects that
location with the original logic as well.

Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=305128&r1=305127&r2=305128&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Jun  9 17:50:02 2017
@@ -713,7 +713,9 @@ bool Preprocessor::HandleIdentifier(Toke
   // C++ 2.11p2: If this is an alternative representation of a C++ operator,
   // then we act as if it is the actual operator and not the textual
   // representation of it.
-  if (II.isCPlusPlusOperatorKeyword())
+  if (II.isCPlusPlusOperatorKeyword() &&
+  !(getLangOpts().MSVCCompat &&
+getSourceManager().isInSystemHeader(Identifier.getLocation(
 Identifier.setIdentifierInfo(nullptr);
 
   // If this is an extension token, diagnose its use.


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


r305425 - [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments,

2017-06-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 14 18:09:01 2017
New Revision: 305425

URL: http://llvm.org/viewvc/llvm-project?rev=305425&view=rev
Log:
[Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, 
correct getNumArguments

StringifiedArguments is allocated (resized) based on the size the 
getNumArguments function. However, this function ACTUALLY currently 
returns the amount of total UnexpArgTokens which is minimum the same as 
the new implementation of getNumMacroArguments, since empty/omitted arguments 
result in 1 UnexpArgToken, and included ones at minimum include 2 
(1 for the arg itself, 1 for eof).

This patch renames the otherwise unused getNumArguments to be more clear 
that it is the number of arguments that the Macro expects, and thus the maximum 
number that can be stringified. This patch also replaces the explicit memset 
(which results in value instantiation of the new tokens, PLUS clearing the 
memory) with brace initialization.

Differential Revision: https://reviews.llvm.org/D32046

Modified:
cfe/trunk/include/clang/Lex/MacroArgs.h
cfe/trunk/lib/Lex/MacroArgs.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/include/clang/Lex/MacroArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroArgs.h?rev=305425&r1=305424&r2=305425&view=diff
==
--- cfe/trunk/include/clang/Lex/MacroArgs.h (original)
+++ cfe/trunk/include/clang/Lex/MacroArgs.h Wed Jun 14 18:09:01 2017
@@ -53,9 +53,12 @@ class MacroArgs {
   /// Preprocessor owns which we use to avoid thrashing malloc/free.
   MacroArgs *ArgCache;
 
-  MacroArgs(unsigned NumToks, bool varargsElided)
-: NumUnexpArgTokens(NumToks), VarargsElided(varargsElided),
-  ArgCache(nullptr) {}
+  /// MacroArgs - The number of arguments the invoked macro expects.
+  unsigned NumMacroArgs;
+
+  MacroArgs(unsigned NumToks, bool varargsElided, unsigned MacroArgs)
+  : NumUnexpArgTokens(NumToks), VarargsElided(varargsElided),
+ArgCache(nullptr), NumMacroArgs(MacroArgs) {}
   ~MacroArgs() = default;
 
 public:
@@ -94,10 +97,9 @@ public:
   SourceLocation ExpansionLocStart,
   SourceLocation ExpansionLocEnd);
 
-  /// getNumArguments - Return the number of arguments passed into this macro
-  /// invocation.
-  unsigned getNumArguments() const { return NumUnexpArgTokens; }
-
+  /// getNumMacroArguments - Return the number of arguments the invoked macro
+  /// expects.
+  unsigned getNumMacroArguments() const { return NumMacroArgs; }
 
   /// isVarargsElidedUse - Return true if this is a C99 style varargs macro
   /// invocation and there was no argument specified for the "..." argument.  
If

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=305425&r1=305424&r2=305425&view=diff
==
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Wed Jun 14 18:09:01 2017
@@ -44,20 +44,22 @@ MacroArgs *MacroArgs::create(const Macro
   // Otherwise, use the best fit.
   ClosestMatch = (*Entry)->NumUnexpArgTokens;
 }
-  
+
   MacroArgs *Result;
   if (!ResultEnt) {
 // Allocate memory for a MacroArgs object with the lexer tokens at the end.
-Result = (MacroArgs*)malloc(sizeof(MacroArgs) + 
-UnexpArgTokens.size() * sizeof(Token));
+Result = (MacroArgs *)malloc(sizeof(MacroArgs) +
+ UnexpArgTokens.size() * sizeof(Token));
 // Construct the MacroArgs object.
-new (Result) MacroArgs(UnexpArgTokens.size(), VarargsElided);
+new (Result)
+MacroArgs(UnexpArgTokens.size(), VarargsElided, MI->getNumArgs());
   } else {
 Result = *ResultEnt;
 // Unlink this node from the preprocessors singly linked list.
 *ResultEnt = Result->ArgCache;
 Result->NumUnexpArgTokens = UnexpArgTokens.size();
 Result->VarargsElided = VarargsElided;
+Result->NumMacroArgs = MI->getNumArgs();
   }
 
   // Copy the actual unexpanded tokens to immediately after the result ptr.
@@ -298,12 +300,10 @@ const Token &MacroArgs::getStringifiedAr
Preprocessor &PP,
SourceLocation 
ExpansionLocStart,
SourceLocation ExpansionLocEnd) 
{
-  assert(ArgNo < NumUnexpArgTokens && "Invalid argument number!");
-  if (StringifiedArgs.empty()) {
-StringifiedArgs.resize(getNumArguments());
-memset((void*)&StringifiedArgs[0], 0,
-   sizeof(StringifiedArgs[0])*getNumArguments());
-  }
+  assert(ArgNo < getNumMacroArguments() && "Invalid argument number!");
+  if (StringifiedArgs.empty())
+StringifiedArgs.resize(getNumMacroArguments(), {});
+
   if (StringifiedAr

[clang-tools-extra] r305426 - Update callbacks tracker to match change in 305425

2017-06-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 14 18:15:51 2017
New Revision: 305426

URL: http://llvm.org/viewvc/llvm-project?rev=305426&view=rev
Log:
Update callbacks tracker to match change in 305425

Modified:
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=305426&r1=305425&r2=305426&view=diff
==
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Wed Jun 14 18:15:51 
2017
@@ -590,7 +590,7 @@ void PPCallbacksTracker::appendArgument(
   SS << "[";
   // The argument tokens might include end tokens, so we reflect how
   // how getUnexpArgument provides the arguments.
-  for (int I = 0, E = Value->getNumArguments(); I < E; ++I) {
+  for (int I = 0, E = Value->getNumMacroArguments(); I < E; ++I) {
 const clang::Token *Current = Value->getUnexpArgument(I);
 int TokenCount = Value->getArgLength(Current) + 1; // include EOF
 E -= TokenCount;


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


[clang-tools-extra] r305434 - Update Append Argument to more efficiently traverse tokens

2017-06-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 14 19:27:23 2017
New Revision: 305434

URL: http://llvm.org/viewvc/llvm-project?rev=305434&view=rev
Log:
Update Append Argument to more efficiently traverse tokens

This function was previously making (correct) assumptions
without complete knowledge of MacroArgs guarantees for
Arguments.  After going through Macro Args a bunch, I'd
corrected the getNumArguments (and changed its name), 
however didn't realize this was depending on the behavior.

This patch has version that depends on the corrected 
getNumMacroArguments's behavior, with the rest checked against
my knowledge of the MacroArgs' token list.  Commiting no-wait
since the test is broken.

Modified:
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=305434&r1=305433&r2=305434&view=diff
==
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Wed Jun 14 19:27:23 
2017
@@ -588,19 +588,16 @@ void PPCallbacksTracker::appendArgument(
   std::string Str;
   llvm::raw_string_ostream SS(Str);
   SS << "[";
-  // The argument tokens might include end tokens, so we reflect how
-  // how getUnexpArgument provides the arguments.
-  for (int I = 0, E = Value->getNumMacroArguments(); I < E; ++I) {
+
+  // Each argument is is a series of contiguous Tokens, terminated by a eof.
+  // Go through each argument printing tokens until we reach eof.
+  for (unsigned I = 0; I < Value->getNumMacroArguments(); ++I) {
 const clang::Token *Current = Value->getUnexpArgument(I);
-int TokenCount = Value->getArgLength(Current) + 1; // include EOF
-E -= TokenCount;
 if (I)
   SS << ", ";
-// We're assuming tokens are contiguous, as otherwise we have no
-// other way to get at them.
---TokenCount;
-for (int TokenIndex = 0; TokenIndex < TokenCount; ++TokenIndex, ++Current) 
{
-  if (TokenIndex)
+bool First = true;
+while (Current->isNot(clang::tok::eof)) {
+  if (!First)
 SS << " ";
   // We need to be careful here because the arguments might not be legal in
   // YAML, so we use the token name for anything but identifiers and
@@ -611,6 +608,8 @@ void PPCallbacksTracker::appendArgument(
   } else {
 SS << "<" << Current->getName() << ">";
   }
+  ++Current;
+  First = false;
 }
   }
   SS << "]";


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


r305435 - Fix LexerTest signed/unsigned comparison.

2017-06-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 14 19:28:13 2017
New Revision: 305435

URL: http://llvm.org/viewvc/llvm-project?rev=305435&view=rev
Log:
Fix LexerTest signed/unsigned comparison.

Werror was catching a signed/unsigned compare in 
an assert, correct the signed 'expected' value to be
unsigned.

Modified:
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/unittests/Lex/LexerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=305435&r1=305434&r2=305435&view=diff
==
--- cfe/trunk/unittests/Lex/LexerTest.cpp (original)
+++ cfe/trunk/unittests/Lex/LexerTest.cpp Wed Jun 14 19:28:13 2017
@@ -383,7 +383,7 @@ TEST_F(LexerTest, DontOverallocateString
   MacroInfo *MI = PP->AllocateMacroInfo({});
   MI->setIsFunctionLike();
   MI->setArgumentList(ArgList, Allocator);
-  EXPECT_EQ(3, MI->getNumArgs());
+  EXPECT_EQ(3u, MI->getNumArgs());
   EXPECT_TRUE(MI->isFunctionLike());
 
   Token Eof;


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


r305491 - LexerTest memory leak fix-

2017-06-15 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Jun 15 13:34:47 2017
New Revision: 305491

URL: http://llvm.org/viewvc/llvm-project?rev=305491&view=rev
Log:
LexerTest memory leak fix-

A new LexerTest unittest introduced a memory leak.  This patch
uses a unique_ptr with a custom deleter to ensure it is properly
deleted.

Modified:
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/unittests/Lex/LexerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=305491&r1=305490&r2=305491&view=diff
==
--- cfe/trunk/unittests/Lex/LexerTest.cpp (original)
+++ cfe/trunk/unittests/Lex/LexerTest.cpp Thu Jun 15 13:34:47 2017
@@ -402,7 +402,9 @@ TEST_F(LexerTest, DontOverallocateString
   ArgTokens.push_back(tok);
   }
 
-  MacroArgs *MA = MacroArgs::create(MI, ArgTokens, false, *PP);
+  auto MacroArgsDeleter = [&PP](MacroArgs *M) { M->destroy(*PP); };
+  std::unique_ptr MA(
+  MacroArgs::create(MI, ArgTokens, false, *PP), MacroArgsDeleter);
   Token Result = MA->getStringifiedArgument(0, *PP, {}, {});
   EXPECT_EQ(tok::string_literal, Result.getKind());
   EXPECT_STREQ("\"\\\"StrArg\\\"\"", Result.getLiteralData());


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


r305812 - Fix for Bug 33471: Preventing operator auto from resolving to a template operator.

2017-06-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jun 20 12:38:07 2017
New Revision: 305812

URL: http://llvm.org/viewvc/llvm-project?rev=305812&view=rev
Log:
Fix for Bug 33471: Preventing operator auto from resolving to a template 
operator.

As the bug report says,
struct A
{

  template operator T();

};

void foo()
{

  A().operator auto();

}

causes: "undeduced type in IR-generation
UNREACHABLE executed at llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp:208!"

The problem is that in this case, "T" is being deduced as "auto", 
which I believe is incorrect.

The 'operator auto' implementation in Clang is standards compliant, however 
there is a defect report against core (1670).

Differential Revision: https://reviews.llvm.org/D34370

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=305812&r1=305811&r2=305812&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Jun 20 12:38:07 2017
@@ -862,6 +862,16 @@ static bool LookupDirect(Sema &S, Lookup
   if (!Record->isCompleteDefinition())
 return Found;
 
+  // For conversion operators, 'operator auto' should only match
+  // 'operator auto'.  Since 'auto' is not a type, it shouldn't be considered
+  // as a candidate for template substitution.
+  auto *ContainedDeducedType =
+  R.getLookupName().getCXXNameType()->getContainedDeducedType();
+  if (R.getLookupName().getNameKind() ==
+  DeclarationName::CXXConversionFunctionName &&
+  ContainedDeducedType && ContainedDeducedType->isUndeducedType())
+return Found;
+
   for (CXXRecordDecl::conversion_iterator U = Record->conversion_begin(),
  UEnd = Record->conversion_end(); U != UEnd; ++U) {
 FunctionTemplateDecl *ConvTemplate = dyn_cast(*U);

Modified: cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp?rev=305812&r1=305811&r2=305812&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp Tue Jun 20 12:38:07 
2017
@@ -55,6 +55,25 @@ auto b(bool k) {
   return "goodbye";
 }
 
+// Allow 'operator auto' to call only the explicit operator auto.
+struct BothOps {
+  template  operator T();
+  template  operator T *();
+  operator auto() { return 0; }
+  operator auto *() { return this; }
+};
+struct JustTemplateOp {
+  template  operator T();
+  template  operator T *();
+};
+
+auto c() {
+  BothOps().operator auto(); // ok
+  BothOps().operator auto *(); // ok
+  JustTemplateOp().operator auto(); // expected-error {{no member named 
'operator auto' in 'JustTemplateOp'}}
+  JustTemplateOp().operator auto *(); // expected-error {{no member named 
'operator auto *' in 'JustTemplateOp'}}
+}
+
 auto *ptr_1() {
   return 100; // expected-error {{cannot deduce return type 'auto *' from 
returned value of type 'int'}}
 }


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


r305928 - Correct VectorCall x86 (32 bit) behavior for SSE Register Assignment

2017-06-21 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 21 11:37:22 2017
New Revision: 305928

URL: http://llvm.org/viewvc/llvm-project?rev=305928&view=rev
Log:
Correct VectorCall x86 (32 bit) behavior for SSE Register Assignment

In running some internal vectorcall tests in 32 bit mode, we discovered that 
the 
behavior I'd previously implemented for x64 (and applied to x32) regarding the 
assignment of SSE registers was incorrect. See spec here: 
https://msdn.microsoft.com/en-us/library/dn375768.aspx

My previous implementation applied register argument position from the x64 
version to both. This isn't correct for x86, so this removes and refactors that 
section. Additionally, it corrects the integer/int-pointer assignments. Unlike 
x64, x86 permits integers to be assigned independent of position.

Finally, the code for 32 bit was cleaned up a little to clarify the intent, 
as well as given a descriptive comment.

Differential Revision: https://reviews.llvm.org/D34455

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/vectorcall.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=305928&r1=305927&r2=305928&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jun 21 11:37:22 2017
@@ -951,8 +951,7 @@ class X86_32ABIInfo : public SwiftABIInf
   Class classify(QualType Ty) const;
   ABIArgInfo classifyReturnType(QualType RetTy, CCState &State) const;
   ABIArgInfo classifyArgumentType(QualType RetTy, CCState &State) const;
-  ABIArgInfo reclassifyHvaArgType(QualType RetTy, CCState &State, 
-  const ABIArgInfo& current) const;
+
   /// \brief Updates the number of available free registers, returns 
   /// true if any registers were allocated.
   bool updateFreeRegs(QualType Ty, CCState &State) const;
@@ -1536,27 +1535,6 @@ bool X86_32ABIInfo::shouldPrimitiveUseIn
   return true;
 }
 
-ABIArgInfo
-X86_32ABIInfo::reclassifyHvaArgType(QualType Ty, CCState &State,
-const ABIArgInfo ¤t) const {
-  // Assumes vectorCall calling convention.
-  const Type *Base = nullptr;
-  uint64_t NumElts = 0;
-
-  if (!Ty->isBuiltinType() && !Ty->isVectorType() &&
-  isHomogeneousAggregate(Ty, Base, NumElts)) {
-if (State.FreeSSERegs >= NumElts) {
-  // HVA types get passed directly in registers if there is room.
-  State.FreeSSERegs -= NumElts;
-  return getDirectX86Hva();
-}
-// If there's no room, the HVA gets passed as normal indirect
-// structure.
-return getIndirectResult(Ty, /*ByVal=*/false, State);
-  } 
-  return current;
-}
-
 ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
CCState &State) const {
   // FIXME: Set alignment on indirect arguments.
@@ -1575,35 +1553,20 @@ ABIArgInfo X86_32ABIInfo::classifyArgume
 }
   }
 
-  // vectorcall adds the concept of a homogenous vector aggregate, similar
-  // to other targets, regcall uses some of the HVA rules.
+  // Regcall uses the concept of a homogenous vector aggregate, similar
+  // to other targets.
   const Type *Base = nullptr;
   uint64_t NumElts = 0;
-  if ((State.CC == llvm::CallingConv::X86_VectorCall ||
-   State.CC == llvm::CallingConv::X86_RegCall) &&
+  if (State.CC == llvm::CallingConv::X86_RegCall &&
   isHomogeneousAggregate(Ty, Base, NumElts)) {
 
-if (State.CC == llvm::CallingConv::X86_RegCall) {
-  if (State.FreeSSERegs >= NumElts) {
-State.FreeSSERegs -= NumElts;
-if (Ty->isBuiltinType() || Ty->isVectorType())
-  return ABIArgInfo::getDirect();
-return ABIArgInfo::getExpand();
-
-  }
-  return getIndirectResult(Ty, /*ByVal=*/false, State);
-} else if (State.CC == llvm::CallingConv::X86_VectorCall) {
-  if (State.FreeSSERegs >= NumElts && (Ty->isBuiltinType() || 
Ty->isVectorType())) {
-// Actual floating-point types get registers first time through if
-// there is registers available
-State.FreeSSERegs -= NumElts;
+if (State.FreeSSERegs >= NumElts) {
+  State.FreeSSERegs -= NumElts;
+  if (Ty->isBuiltinType() || Ty->isVectorType())
 return ABIArgInfo::getDirect();
-  }  else if (!Ty->isBuiltinType() && !Ty->isVectorType()) {
-// HVA Types only get registers after everything else has been
-// set, so it gets set as indirect for now.
-return ABIArgInfo::getIndirect(getContext().getTypeAlignInChars(Ty));
-  }
+  return ABIArgInfo::getExpand();
 }
+return getIndirectResult(Ty, /*ByVal=*/false, State);
   }
 
   if (isAggregateTypeForABI(Ty)) {
@@ -1684,31 +1647,53 @@ ABIArgInfo X86_32ABIInfo::classifyArgume
 
 void X86_32ABIInfo::computeVectorCallArgs(CGFunctionInfo &FI, CCState &State,
 

r306149 - Emit warning when throw exception in destruct or dealloc functions which has a

2017-06-23 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jun 23 15:22:19 2017
New Revision: 306149

URL: http://llvm.org/viewvc/llvm-project?rev=306149&view=rev
Log:
Emit warning when throw exception in destruct or dealloc functions which has a 
(possible implicit) noexcept specifier

Throwing in the destructor is not good (C++11 change try to not allow see 
below).
 But in reality, those codes are exist.
C++11 [class.dtor]p3:

A declaration of a destructor that does not have an exception-specification is 
implicitly considered to have the same exception specification as an implicit 
declaration.

With this change, the application worked before may now run into runtime 
termination. My goal here is to emit a warning to provide only possible info to 
where the code may need to be changed.

First there is no way, in compile time to identify the “throw” really throw out 
of the function. Things like the call which throw out… To keep this simple, 
when “throw” is seen, checking its enclosing function(only destructor and 
dealloc functions) with noexcept(true) specifier emit warning.

Here is implementation detail:
A new member function CheckCXXThrowInNonThrowingFunc is added for class Sema 
in Sema.h. It is used in the call to both BuildCXXThrow and 
TransformCXXThrowExpr.

The function basic check if the enclosing function with non-throwing noexcept 
specifer, if so emit warning for it.

The example of warning message like:
k1.cpp:18:3: warning: ''~dependent_warn'' has a (possible implicit) non-throwing

noexcept specifier. Throwing exception may cause termination.
[-Wthrow-in-dtor]
throw 1;
^

k1.cpp:43:30: note: in instantiation of member function

'dependent_warn::~dependent_warn' requested here

dependent_warn f; // cause warning

Differential Revision: https://reviews.llvm.org/D3


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/CXX/except/except.spec/p11.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=306149&r1=306148&r2=306149&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 23 15:22:19 
2017
@@ -6351,6 +6351,15 @@ def err_exceptions_disabled : Error<
   "cannot use '%0' with exceptions disabled">;
 def err_objc_exceptions_disabled : Error<
   "cannot use '%0' with Objective-C exceptions disabled">;
+def warn_throw_in_noexcept_func 
+: Warning<"%0 has a non-throwing exception specification but can still "
+  "throw, resulting in unexpected program termination">,
+  InGroup;
+def note_throw_in_dtor 
+: Note<"destructor or deallocator has a (possibly implicit) non-throwing "
+  "excepton specification">;
+def note_throw_in_function 
+: Note<"non-throwing function declare here">;
 def err_seh_try_outside_functions : Error<
   "cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls">;
 def err_mixing_cxx_try_seh_try : Error<

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=306149&r1=306148&r2=306149&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Fri Jun 23 15:22:19 2017
@@ -279,6 +279,150 @@ static void checkRecursiveFunction(Sema
 }
 
 
//===--===//
+// Check for throw in a non-throwing function.
+//===--===//
+enum ThrowState {
+  FoundNoPathForThrow,
+  FoundPathForThrow,
+  FoundPathWithNoThrowOutFunction,
+};
+
+static bool isThrowCaught(const CXXThrowExpr *Throw,
+  const CXXCatchStmt *Catch) {
+  const Type *ThrowType = nullptr;
+  if (Throw->getSubExpr())
+ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
+  if (!ThrowType)
+return false;
+  const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+  if (!CaughtType)
+return true;
+  if (ThrowType->isReferenceType())
+ThrowType = ThrowType->castAs()
+->getPointeeType()
+->getUnqualifiedDesugaredType();
+  if (CaughtType->isReferenceType())
+CaughtType = CaughtType->castAs()
+ ->getPointeeType()
+ ->getUnqualifiedDesugaredType();
+  if (CaughtType == ThrowType)
+return true;
+  const CXXRecordDecl *CaughtAsRecordType =
+  CaughtType->getPointeeCXXRecordDecl();
+  const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl();
+  if (CaughtAsRecordType && ThrowType

  1   2   3   4   5   6   7   8   9   10   >