r326501 - [NFC] Move CommentOpts checks to the call sites that depend on it.

2018-03-01 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Mar  1 14:41:53 2018
New Revision: 326501

URL: http://llvm.org/viewvc/llvm-project?rev=326501&view=rev
Log:
[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

 1. All comments are saved during parsing, regardless of whether they are doc
comments or not.
 2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of
marking them as ordinary comments. The maybe-doc type of comment is never
saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
 3. All comments are treated as doc comments in ASTContext, even if they are
ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Reviewers: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RawCommentList.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RawCommentList.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=326501&r1=326500&r2=326501&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Mar  1 14:41:53 2018
@@ -784,7 +784,7 @@ public:
   void addComment(const RawComment &RC) {
 assert(LangOpts.RetainCommentsFromSystemHeaders ||
!SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
-Comments.addComment(RC, BumpAlloc);
+Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
   }
 
   /// \brief Return the documentation comment attached to a given declaration.

Modified: cfe/trunk/include/clang/AST/RawCommentList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=326501&r1=326500&r2=326501&view=diff
==
--- cfe/trunk/include/clang/AST/RawCommentList.h (original)
+++ cfe/trunk/include/clang/AST/RawCommentList.h Thu Mar  1 14:41:53 2018
@@ -41,7 +41,7 @@ public:
   RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
 
   RawComment(const SourceManager &SourceMgr, SourceRange SR,
- bool Merged, bool ParseAllComments);
+ const CommentOptions &CommentOpts, bool Merged);
 
   CommentKind getKind() const LLVM_READONLY {
 return (CommentKind) Kind;
@@ -83,8 +83,7 @@ public:
 
   /// Returns true if this comment is not a documentation comment.
   bool isOrdinary() const LLVM_READONLY {
-return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&
-!ParseAllComments;
+return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC));
   }
 
   /// Returns true if this comment any kind of a documentation comment.
@@ -92,11 +91,6 @@ public:
 return !isInvalid() && !isOrdinary();
   }
 
-  /// Returns whether we are parsing all comments.
-  bool isParseAllComments() const LLVM_READONLY {
-return ParseAllComments;
-  }
-
   /// Returns raw comment text with comment markers.
   StringRef getRawText(const SourceManager &SourceMgr) const {
 if (RawTextValid)
@@ -139,18 +133,12 @@ private:
   bool IsTrailingComment : 1;
   bool IsAlmostTrailingComment : 1;
 
-  /// When true, ordinary comments starting with "//" and "/*" will be
-  /// considered as documentation comments.
-  bool ParseAllComments : 1;
-
   /// \brief Constructor for AST deserialization.
   RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
- bool IsAlmostTrailingComment,
- bool ParseAllComments) :
+ bool IsAlmostTrailingComment) :
 Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
 IsAttached(false), IsTrailingComment(IsTrailingComment),
-IsAlmostTrailingComment(IsAlmostTrailingComment),
-ParseAllComments(ParseAllComments)
+IsAlmostTrailingComment(IsAlmostTrailingComment)
   { }
 
   StringRef getRawTextSlow(const SourceManager &SourceMgr) const;
@@ -183,7 +171,8 @@ class RawCommentList {
 public:
   RawCommentList(SourceManager &SourceMgr) : SourceMgr(SourceMgr) {}
 
-  void addComment(const RawComment &RC, llvm::BumpPtrAllocator &Allocator);
+  void addComment(const RawComment &RC, const CommentOptions &CommentOpts,
+  llvm::BumpPtrAllocator &Allocator);
 
   ArrayRef getComments() const {
 return Comments;

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AS

r326508 - Revert r326501 due to buildbot breakage.

2018-03-01 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Mar  1 15:14:00 2018
New Revision: 326508

URL: http://llvm.org/viewvc/llvm-project?rev=326508&view=rev
Log:
Revert r326501 due to buildbot breakage.

Original change:

[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc 
comments or not.
2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of 
marking them as ordinary comments. The maybe-doc type of comment is never saved 
otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are 
ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.



Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RawCommentList.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RawCommentList.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=326508&r1=326507&r2=326508&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Mar  1 15:14:00 2018
@@ -784,7 +784,7 @@ public:
   void addComment(const RawComment &RC) {
 assert(LangOpts.RetainCommentsFromSystemHeaders ||
!SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
-Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
+Comments.addComment(RC, BumpAlloc);
   }
 
   /// \brief Return the documentation comment attached to a given declaration.

Modified: cfe/trunk/include/clang/AST/RawCommentList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=326508&r1=326507&r2=326508&view=diff
==
--- cfe/trunk/include/clang/AST/RawCommentList.h (original)
+++ cfe/trunk/include/clang/AST/RawCommentList.h Thu Mar  1 15:14:00 2018
@@ -41,7 +41,7 @@ public:
   RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
 
   RawComment(const SourceManager &SourceMgr, SourceRange SR,
- const CommentOptions &CommentOpts, bool Merged);
+ bool Merged, bool ParseAllComments);
 
   CommentKind getKind() const LLVM_READONLY {
 return (CommentKind) Kind;
@@ -83,7 +83,8 @@ public:
 
   /// Returns true if this comment is not a documentation comment.
   bool isOrdinary() const LLVM_READONLY {
-return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC));
+return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&
+!ParseAllComments;
   }
 
   /// Returns true if this comment any kind of a documentation comment.
@@ -91,6 +92,11 @@ public:
 return !isInvalid() && !isOrdinary();
   }
 
+  /// Returns whether we are parsing all comments.
+  bool isParseAllComments() const LLVM_READONLY {
+return ParseAllComments;
+  }
+
   /// Returns raw comment text with comment markers.
   StringRef getRawText(const SourceManager &SourceMgr) const {
 if (RawTextValid)
@@ -133,12 +139,18 @@ private:
   bool IsTrailingComment : 1;
   bool IsAlmostTrailingComment : 1;
 
+  /// When true, ordinary comments starting with "//" and "/*" will be
+  /// considered as documentation comments.
+  bool ParseAllComments : 1;
+
   /// \brief Constructor for AST deserialization.
   RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
- bool IsAlmostTrailingComment) :
+ bool IsAlmostTrailingComment,
+ bool ParseAllComments) :
 Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
 IsAttached(false), IsTrailingComment(IsTrailingComment),
-IsAlmostTrailingComment(IsAlmostTrailingComment)
+IsAlmostTrailingComment(IsAlmostTrailingComment),
+ParseAllComments(ParseAllComments)
   { }
 
   StringRef getRawTextSlow(const SourceManager &SourceMgr) const;
@@ -171,8 +183,7 @@ class RawCommentList {
 public:
   RawCommentList(SourceManager &SourceMgr) : SourceMgr(SourceMgr) {}
 
-  void addComment(const RawComment &RC, const CommentOptions &CommentOpts,
-  llvm::BumpPtrAllocator &Allocator);
+  void addComment(const RawComment &RC, llvm::BumpPtrAllocator &Allocator);
 
   ArrayRef getComments() const {
 return Comments;

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=326508&r1=326507&r2=326508&view=d

r326512 - [NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying r326501.)

2018-03-01 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Mar  1 16:07:45 2018
New Revision: 326512

URL: http://llvm.org/viewvc/llvm-project?rev=326512&view=rev
Log:
[NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying 
r326501.)

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc
   comments or not.
2. "Maybe-doc" comments, like <, !, etc, are saved as such, instead of marking
   them as ordinary comments. The maybe-doc type of comment is never saved
   otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are 
ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Subscribers: cfe-commits

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RawCommentList.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RawCommentList.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=326512&r1=326511&r2=326512&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Mar  1 16:07:45 2018
@@ -784,7 +784,7 @@ public:
   void addComment(const RawComment &RC) {
 assert(LangOpts.RetainCommentsFromSystemHeaders ||
!SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
-Comments.addComment(RC, BumpAlloc);
+Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
   }
 
   /// \brief Return the documentation comment attached to a given declaration.

Modified: cfe/trunk/include/clang/AST/RawCommentList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=326512&r1=326511&r2=326512&view=diff
==
--- cfe/trunk/include/clang/AST/RawCommentList.h (original)
+++ cfe/trunk/include/clang/AST/RawCommentList.h Thu Mar  1 16:07:45 2018
@@ -41,7 +41,7 @@ public:
   RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
 
   RawComment(const SourceManager &SourceMgr, SourceRange SR,
- bool Merged, bool ParseAllComments);
+ const CommentOptions &CommentOpts, bool Merged);
 
   CommentKind getKind() const LLVM_READONLY {
 return (CommentKind) Kind;
@@ -70,7 +70,6 @@ public:
   /// \code /**< stuff */ \endcode
   /// \code /*!< stuff */ \endcode
   bool isTrailingComment() const LLVM_READONLY {
-assert(isDocumentation());
 return IsTrailingComment;
   }
 
@@ -83,8 +82,7 @@ public:
 
   /// Returns true if this comment is not a documentation comment.
   bool isOrdinary() const LLVM_READONLY {
-return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&
-!ParseAllComments;
+return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC));
   }
 
   /// Returns true if this comment any kind of a documentation comment.
@@ -92,11 +90,6 @@ public:
 return !isInvalid() && !isOrdinary();
   }
 
-  /// Returns whether we are parsing all comments.
-  bool isParseAllComments() const LLVM_READONLY {
-return ParseAllComments;
-  }
-
   /// Returns raw comment text with comment markers.
   StringRef getRawText(const SourceManager &SourceMgr) const {
 if (RawTextValid)
@@ -139,18 +132,12 @@ private:
   bool IsTrailingComment : 1;
   bool IsAlmostTrailingComment : 1;
 
-  /// When true, ordinary comments starting with "//" and "/*" will be
-  /// considered as documentation comments.
-  bool ParseAllComments : 1;
-
   /// \brief Constructor for AST deserialization.
   RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
- bool IsAlmostTrailingComment,
- bool ParseAllComments) :
+ bool IsAlmostTrailingComment) :
 Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
 IsAttached(false), IsTrailingComment(IsTrailingComment),
-IsAlmostTrailingComment(IsAlmostTrailingComment),
-ParseAllComments(ParseAllComments)
+IsAlmostTrailingComment(IsAlmostTrailingComment)
   { }
 
   StringRef getRawTextSlow(const SourceManager &SourceMgr) const;
@@ -183,7 +170,8 @@ class RawCommentList {
 public:
   RawCommentList(SourceManager &SourceMgr) : SourceMgr(SourceMgr) {}
 
-  void addComment(const RawComment &RC, llvm::BumpPtrAllocator &Allocator);
+  void addComment(const RawComment &RC, const CommentOptions &CommentOpts,
+  llvm::BumpPtrAllocator &Allocator);
 
   A

r334801 - [Format] Do not use a global static value for EOF within ScopedMacroState.

2018-06-14 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Jun 14 23:08:54 2018
New Revision: 334801

URL: http://llvm.org/viewvc/llvm-project?rev=334801&view=rev
Log:
[Format] Do not use a global static value for EOF within ScopedMacroState.

ScopedMacroState injects its own EOF token under certain conditions, and the
returned token may be modified in several different locations. If multiple
reformat operations are started in different threads, then they will both see
the same fake EOF token, and may both try to modify it. This is a data race.

This bug was caught with tsan.

Reviewers: klimek

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=334801&r1=334800&r2=334801&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Jun 14 23:08:54 2018
@@ -83,6 +83,8 @@ public:
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
 Token(nullptr), PreviousToken(nullptr) {
+FakeEOF.Tok.startToken();
+FakeEOF.Tok.setKind(tok::eof);
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -102,7 +104,7 @@ public:
 PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
-  return getFakeEOF();
+  return &FakeEOF;
 return Token;
   }
 
@@ -121,17 +123,7 @@ private:
  /*MinColumnToken=*/PreviousToken);
   }
 
-  FormatToken *getFakeEOF() {
-static bool EOFInitialized = false;
-static FormatToken FormatTok;
-if (!EOFInitialized) {
-  FormatTok.Tok.startToken();
-  FormatTok.Tok.setKind(tok::eof);
-  EOFInitialized = true;
-}
-return &FormatTok;
-  }
-
+  FormatToken FakeEOF;
   UnwrappedLine &Line;
   FormatTokenSource *&TokenSource;
   FormatToken *&ResetToken;


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


r334929 - [ASTMatchers] Don't assert-fail in specifiesTypeLoc().

2018-06-18 Thread David L. Jones via cfe-commits
Author: dlj
Date: Mon Jun 18 01:59:16 2018
New Revision: 334929

URL: http://llvm.org/viewvc/llvm-project?rev=334929&view=rev
Log:
[ASTMatchers] Don't assert-fail in specifiesTypeLoc().

The specifiesTypeLoc() matcher narrows a nestedNameSpecifier matcher based on a
typeloc within the NNS. However, the matcher does not guard against NNS which
are a namespace, and cause getTypeLoc to assert-fail.

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=334929&r1=334928&r2=334929&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Jun 18 01:59:16 2018
@@ -5536,7 +5536,8 @@ AST_MATCHER_P(NestedNameSpecifier, speci
 ///   matches "A::"
 AST_MATCHER_P(NestedNameSpecifierLoc, specifiesTypeLoc,
   internal::Matcher, InnerMatcher) {
-  return Node && InnerMatcher.matches(Node.getTypeLoc(), Finder, Builder);
+  return Node && Node.getNestedNameSpecifier()->getAsType() &&
+ InnerMatcher.matches(Node.getTypeLoc(), Finder, Builder);
 }
 
 /// Matches on the prefix of a \c NestedNameSpecifier.

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=334929&r1=334928&r2=334929&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Mon Jun 18 01:59:16 
2018
@@ -1450,6 +1450,10 @@ TEST(NNS, MatchesNestedNameSpecifierPref
 "struct A { struct B { struct C {}; }; }; A::B::C c;",
 nestedNameSpecifierLoc(hasPrefix(
   specifiesTypeLoc(loc(qualType(asString("struct A";
+  EXPECT_TRUE(matches(
+"namespace N { struct A { struct B { struct C {}; }; }; } N::A::B::C c;",
+nestedNameSpecifierLoc(hasPrefix(
+  specifiesTypeLoc(loc(qualType(asString("struct N::A";
 }
 
 


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


r334930 - [ASTMatchers] Add support for matching the type of a friend decl.

2018-06-18 Thread David L. Jones via cfe-commits
Author: dlj
Date: Mon Jun 18 02:23:08 2018
New Revision: 334930

URL: http://llvm.org/viewvc/llvm-project?rev=334930&view=rev
Log:
[ASTMatchers] Add support for matching the type of a friend decl.

This allows matchers like:

  friendDecl(hasType(cxxRecordDecl(...)))
  friendDecl(hasType(asString(...)))

It seems that hasType is probably the most reasonable narrowing matcher to
overload, since it is already used to narrow to other declaration kinds.

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

Reviewers: klimek, aaron.ballman

Subscribers: cfe-commits

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=334930&r1=334929&r2=334930&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Jun 18 02:23:08 2018
@@ -2860,13 +2860,17 @@ AST_MATCHER_P_OVERLOAD(CallExpr, callee,
 /// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")
 /// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")
 /// and U (matcher = typedefDecl(hasType(asString("int")))
+/// and friend class X (matcher = friendDecl(hasType("X"))
 /// \code
 ///  class X {};
 ///  void y(X &x) { x; X z; }
 ///  typedef int U;
+///  class Y { friend class X; };
 /// \endcode
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
-hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, TypedefNameDecl, ValueDecl),
+hasType,
+AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, TypedefNameDecl,
+ValueDecl),
 internal::Matcher, InnerMatcher, 0) {
   QualType QT = internal::getUnderlyingType(Node);
   if (!QT.isNull())
@@ -2885,18 +2889,21 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
 ///
 /// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")
 /// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")
+/// and friend class X (matcher = friendDecl(hasType("X"))
 /// \code
 ///  class X {};
 ///  void y(X &x) { x; X z; }
+///  class Y { friend class X; };
 /// \endcode
 ///
 /// Usable as: Matcher, Matcher
-AST_POLYMORPHIC_MATCHER_P_OVERLOAD(hasType,
-   AST_POLYMORPHIC_SUPPORTED_TYPES(Expr,
-   ValueDecl),
-   internal::Matcher, InnerMatcher, 1) {
-  return qualType(hasDeclaration(InnerMatcher))
-  .matches(Node.getType(), Finder, Builder);
+AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
+hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl),
+internal::Matcher, InnerMatcher, 1) {
+  QualType QT = internal::getUnderlyingType(Node);
+  if (!QT.isNull())
+return qualType(hasDeclaration(InnerMatcher)).matches(QT, Finder, Builder);
+  return false;
 }
 
 /// Matches if the type location of the declarator decl's type matches

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=334930&r1=334929&r2=334930&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Mon Jun 18 
02:23:08 2018
@@ -38,6 +38,7 @@
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -120,10 +121,14 @@ inline QualType getUnderlyingType(const
 inline QualType getUnderlyingType(const ValueDecl &Node) {
   return Node.getType();
 }
-
 inline QualType getUnderlyingType(const TypedefNameDecl &Node) {
   return Node.getUnderlyingType();
 }
+inline QualType getUnderlyingType(const FriendDecl &Node) {
+  if (const TypeSourceInfo *TSI = Node.getFriendType())
+return TSI->getType();
+  return QualType();
+}
 
 /// Unifies obtaining the FunctionProtoType pointer from both
 /// FunctionProtoType and FunctionDecl nodes..

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=334930&r1=334929&r2=334930&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Mon Jun 18 02:23:08 
2018
@@ -160,6 +160,16 @@ TEST(ValueDecl, Matches) {
   

r347133 - Fix unused variable warning.

2018-11-16 Thread David L. Jones via cfe-commits
Author: dlj
Date: Fri Nov 16 20:48:54 2018
New Revision: 347133

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

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=347133&r1=347132&r2=347133&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Nov 16 20:48:54 2018
@@ -4000,7 +4000,9 @@ void CGOpenMPRuntimeNVPTX::emitReduction
 return;
 
   bool ParallelReduction = isOpenMPParallelDirective(Options.ReductionKind);
+#ifndef NDEBUG
   bool TeamsReduction = isOpenMPTeamsDirective(Options.ReductionKind);
+#endif
 
   if (Options.SimpleReduction) {
 assert(!TeamsReduction && !ParallelReduction &&


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


r357667 - Revert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)'

2019-04-03 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Apr  3 19:27:57 2019
New Revision: 357667

URL: http://llvm.org/viewvc/llvm-project?rev=357667&view=rev
Log:
Revert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink 
function calls without used results (PR41259)'

This revision causes tests to fail under ASAN. Since the cause of the failures
is not clear (could be ASAN, could be a Clang bug, could be a bug in this
revision), the safest course of action seems to be to revert while 
investigating.


Modified:
cfe/trunk/test/CodeGenCXX/nrvo.cpp
cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp
cfe/trunk/test/CodeGenObjC/exceptions.m

Modified: cfe/trunk/test/CodeGenCXX/nrvo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/nrvo.cpp?rev=357667&r1=357666&r2=357667&view=diff
==
--- cfe/trunk/test/CodeGenCXX/nrvo.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/nrvo.cpp Wed Apr  3 19:27:57 2019
@@ -60,6 +60,7 @@ X test2(bool B) {
   // CHECK-NEXT: call void @llvm.lifetime.start
   // CHECK-NEXT: call {{.*}} @_ZN1XC1Ev
   // CHECK: call {{.*}} @_ZN1XC1ERKS_
+  // CHECK: call {{.*}} @_ZN1XC1ERKS_
   // CHECK: call {{.*}} @_ZN1XD1Ev
   // CHECK-NEXT: call void @llvm.lifetime.end
   // CHECK: call {{.*}} @_ZN1XD1Ev

Modified: cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp?rev=357667&r1=357666&r2=357667&view=diff
==
--- cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp Wed Apr  3 19:27:57 
2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -o - -emit-llvm -O1 \
-// RUN: -fexceptions -fcxx-exceptions -mllvm 
-simplifycfg-sink-common=false | FileCheck %s
+// RUN: -fexceptions -fcxx-exceptions | FileCheck %s
 //
 // We should emit lifetime.ends for these temporaries in both the 'exception'
 // and 'normal' paths in functions.

Modified: cfe/trunk/test/CodeGenObjC/exceptions.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/exceptions.m?rev=357667&r1=357666&r2=357667&view=diff
==
--- cfe/trunk/test/CodeGenObjC/exceptions.m (original)
+++ cfe/trunk/test/CodeGenObjC/exceptions.m Wed Apr  3 19:27:57 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -mllvm 
-simplifycfg-sink-common=false -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -O2 -o - %s | 
FileCheck %s
 //
 //  [irgen] [eh] Exception code built with clang 
(x86_64) crashes
 


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


r353599 - [StaticAnalyzer] Add missing include to SMTAPI.h. [NFC]

2019-02-08 Thread David L. Jones via cfe-commits
Author: dlj
Date: Fri Feb  8 18:41:55 2019
New Revision: 353599

URL: http://llvm.org/viewvc/llvm-project?rev=353599&view=rev
Log:
[StaticAnalyzer] Add missing include to SMTAPI.h. [NFC]

This include is needed for types within SMTAPI.h. (It's very possible that
compilation would succeed without it, but that's only by chance.)

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTAPI.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTAPI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTAPI.h?rev=353599&r1=353598&r2=353599&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTAPI.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTAPI.h Fri Feb  
8 18:41:55 2019
@@ -16,6 +16,7 @@
 
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/FoldingSet.h"
 
 namespace clang {
 namespace ento {


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


r363220 - Revert r361811: 'Re-commit r357452 (take 2): "SimplifyCFG SinkCommonCodeFromPredecessors ...'

2019-06-12 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Jun 12 19:04:45 2019
New Revision: 363220

URL: http://llvm.org/viewvc/llvm-project?rev=363220&view=rev
Log:
Revert r361811: 'Re-commit r357452 (take 2): "SimplifyCFG 
SinkCommonCodeFromPredecessors ...'

We have observed some failures with internal builds with this revision.

- Performance regressions:
  - llvm's SingleSource/Misc evalloop shows performance regressions (although 
these may be red herrings).
  - Benchmarks for Abseil's SwissTable.
- Correctness:
  - Failures for particular libicu tests when building the Google AppEngine SDK 
(for PHP).

hwennborg has already been notified, and is aware of reproducer failures.


Modified:
cfe/trunk/test/CodeGenCXX/nrvo.cpp
cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp
cfe/trunk/test/CodeGenObjC/exceptions.m

Modified: cfe/trunk/test/CodeGenCXX/nrvo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/nrvo.cpp?rev=363220&r1=363219&r2=363220&view=diff
==
--- cfe/trunk/test/CodeGenCXX/nrvo.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/nrvo.cpp Wed Jun 12 19:04:45 2019
@@ -60,6 +60,7 @@ X test2(bool B) {
   // CHECK-NEXT: call void @llvm.lifetime.start
   // CHECK-NEXT: call {{.*}} @_ZN1XC1Ev
   // CHECK: call {{.*}} @_ZN1XC1ERKS_
+  // CHECK: call {{.*}} @_ZN1XC1ERKS_
   // CHECK: call {{.*}} @_ZN1XD1Ev
   // CHECK-NEXT: call void @llvm.lifetime.end
   // CHECK: call {{.*}} @_ZN1XD1Ev

Modified: cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp?rev=363220&r1=363219&r2=363220&view=diff
==
--- cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp Wed Jun 12 19:04:45 
2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -o - -emit-llvm -O1 \
-// RUN: -fexceptions -fcxx-exceptions -mllvm 
-simplifycfg-sink-common=false | FileCheck %s
+// RUN: -fexceptions -fcxx-exceptions | FileCheck %s
 //
 // We should emit lifetime.ends for these temporaries in both the 'exception'
 // and 'normal' paths in functions.

Modified: cfe/trunk/test/CodeGenObjC/exceptions.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/exceptions.m?rev=363220&r1=363219&r2=363220&view=diff
==
--- cfe/trunk/test/CodeGenObjC/exceptions.m (original)
+++ cfe/trunk/test/CodeGenObjC/exceptions.m Wed Jun 12 19:04:45 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -mllvm 
-simplifycfg-sink-common=false -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -O2 -o - %s | 
FileCheck %s
 //
 //  [irgen] [eh] Exception code built with clang 
(x86_64) crashes
 


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


r368958 - [Tooling] Add a hack to work around issues with matcher binding in r368681.

2019-08-14 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Aug 14 21:10:11 2019
New Revision: 368958

URL: http://llvm.org/viewvc/llvm-project?rev=368958&view=rev
Log:
[Tooling] Add a hack to work around issues with matcher binding in r368681.

The change in r368681 contains a (probably unintentional) behavioral change for
rewrite rules with a single matcher. Previously, the single matcher would not
need to be bound (`joinCaseMatchers` returned it directly), even though a final
DynTypeMatcher was created and bound by `buildMatcher`. With the new change, a
single matcher will be bound, in addition to the final binding (which is now in
`buildMatchers`, but happens roughly at the same point in the overall flow).

This patch simply duplicates the "final matcher" trick: it creates an extra
DynTypedMatcher for each rewrite rule case matcher, and unconditionally makes it
bindable. This is probably not the right long-term fix, but it does allow
existing code to continue to work with this interface.

Subscribers: cfe-commits, gribozavr, ymandel

Tags: #clang

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

Modified:
cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp?rev=368958&r1=368957&r2=368958&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp Wed Aug 14 21:10:11 2019
@@ -98,8 +98,10 @@ static std::vector tagg
   Matchers.reserve(Cases.size());
   for (const auto &Case : Cases) {
 std::string Tag = (TagBase + Twine(Case.first)).str();
-auto M = Case.second.Matcher.tryBind(Tag);
-assert(M && "RewriteRule matchers should be bindable.");
+// HACK: Many matchers are not bindable, so ensure that tryBind will work.
+DynTypedMatcher BoundMatcher(Case.second.Matcher);
+BoundMatcher.setAllowBind(true);
+auto M = BoundMatcher.tryBind(Tag);
 Matchers.push_back(*std::move(M));
   }
   return Matchers;


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


r360939 - [clang/test] Add missing dependency on llvm-cxxfilt.

2019-05-16 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu May 16 14:13:59 2019
New Revision: 360939

URL: http://llvm.org/viewvc/llvm-project?rev=360939&view=rev
Log:
[clang/test] Add missing dependency on llvm-cxxfilt.

This tool is needed by clang/test/CodeGen/Output/ppc-mmintrin.c.

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=360939&r1=360938&r2=360939&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Thu May 16 14:13:59 2019
@@ -107,6 +107,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-as
 llvm-bcanalyzer
 llvm-cat
+llvm-cxxfilt
 llvm-dis
 llvm-lto2
 llvm-modextract


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


[clang] 93cc9dd - Revert "Properly convert all declaration non-type template arguments when"

2019-12-04 Thread David L. Jones via cfe-commits

Author: David L. Jones
Date: 2019-12-04T22:12:15-08:00
New Revision: 93cc982f9e971f382ade6acf6634c5914966

URL: 
https://github.com/llvm/llvm-project/commit/93cc982f9e971f382ade6acf6634c5914966
DIFF: 
https://github.com/llvm/llvm-project/commit/93cc982f9e971f382ade6acf6634c5914966.diff

LOG: Revert "Properly convert all declaration non-type template arguments when"

This reverts commit 11d10527852b4d3ed738aa90d8bec0f398160593.

This change is problematic with function pointer template parameters. For
example, building libcxxabi with futexes (-D_LIBCXXABI_USE_FUTEX) produces this
diagnostic:

In file included from .../llvm-project/libcxxabi/src/cxa_guard.cpp:15:
.../llvm-project/libcxxabi/src/cxa_guard_impl.h:416:54: error: address of 
function 'PlatformThreadID' will always evaluate to 'true' 
[-Werror,-Wpointer-bool-conversion]
has_thread_id_support(this->thread_id_address && GetThreadIDArg),
  ~~ ^~
.../llvm-project/libcxxabi/src/cxa_guard.cpp:38:26: note: in instantiation 
of member function '__cxxabiv1::(anonymous 
namespace)::InitByteFutex<&__cxxabiv1::(anonymous 
namespace)::PlatformFutexWait, &__cxxabiv1::(anonymous 
namespace)::PlatformFutexWake, &__cxxabiv1::(anonymous 
namespace)::PlatformThreadID>::InitByteFutex' requested here
  SelectedImplementation imp(raw_guard_object);
 ^
.../llvm-project/libcxxabi/src/cxa_guard_impl.h:416:54: note: prefix with 
the address-of operator to silence this warning
has_thread_id_support(this->thread_id_address && GetThreadIDArg),
 ^
 &
1 error generated.

The diagnostic is incorrect: adding the address-of operator also fails ("cannot
take the address of an rvalue of type 'uint32_t (*)()' (aka 'unsigned int
(*)()')").

Added: 


Modified: 
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaCXX/exceptions-seh.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 85240e1aeec8..e800f7fe7424 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -6968,77 +6968,100 @@ Sema::BuildExpressionFromDeclTemplateArgument(const 
TemplateArgument &Arg,
 
   ValueDecl *VD = Arg.getAsDecl();
 
-  CXXScopeSpec SS;
-  if (ParamType->isMemberPointerType()) {
-// If this is a pointer to member, we need to use a qualified name to
-// form a suitable pointer-to-member constant.
-assert(VD->getDeclContext()->isRecord() &&
-   (isa(VD) || isa(VD) ||
-isa(VD)));
-QualType ClassType
-  = Context.getTypeDeclType(cast(VD->getDeclContext()));
-NestedNameSpecifier *Qualifier
-  = NestedNameSpecifier::Create(Context, nullptr, false,
-ClassType.getTypePtr());
-SS.MakeTrivial(Context, Qualifier, Loc);
-  }
-
-  ExprResult RefExpr = BuildDeclarationNameExpr(
-  SS, DeclarationNameInfo(VD->getDeclName(), Loc), VD);
-  if (RefExpr.isInvalid())
-return ExprError();
+  if (VD->getDeclContext()->isRecord() &&
+  (isa(VD) || isa(VD) ||
+   isa(VD))) {
+// If the value is a class member, we might have a pointer-to-member.
+// Determine whether the non-type template template parameter is of
+// pointer-to-member type. If so, we need to build an appropriate
+// expression for a pointer-to-member, since a "normal" DeclRefExpr
+// would refer to the member itself.
+if (ParamType->isMemberPointerType()) {
+  QualType ClassType
+= Context.getTypeDeclType(cast(VD->getDeclContext()));
+  NestedNameSpecifier *Qualifier
+= NestedNameSpecifier::Create(Context, nullptr, false,
+  ClassType.getTypePtr());
+  CXXScopeSpec SS;
+  SS.MakeTrivial(Context, Qualifier, Loc);
+
+  // The actual value-ness of this is unimportant, but for
+  // internal consistency's sake, references to instance methods
+  // are r-values.
+  ExprValueKind VK = VK_LValue;
+  if (isa(VD) && cast(VD)->isInstance())
+VK = VK_RValue;
+
+  ExprResult RefExpr = BuildDeclRefExpr(VD,
+
VD->getType().getNonReferenceType(),
+VK,
+Loc,
+&SS);
+  if (RefExpr.isInvalid())
+return ExprError();
 
-  // For a pointer, the argument declaration is the pointee. Take its address.
-  QualType T = RefExpr.get()->getType();
-  bool ObjCLifetimeConversion;
-  if (ParamType->isPointerType() &&
-  (T->isFunctionType() ||
-   (T->isArrayType() &&
-!Context.hasSameUnqual

r317716 - Add a missing "REQUIRES: system-windows" to a Windows-only test.

2017-11-08 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Nov  8 12:03:11 2017
New Revision: 317716

URL: http://llvm.org/viewvc/llvm-project?rev=317716&view=rev
Log:
Add a missing "REQUIRES: system-windows" to a Windows-only test.

This un-breaks builds on other platforms. Otherwise, they fail due to warnings 
like:

warning: unable to find a Visual Studio installation; try running Clang from a 
developer command prompt [-Wmsvc-not-found]

Modified:
cfe/trunk/test/Driver/coverage.c

Modified: cfe/trunk/test/Driver/coverage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/coverage.c?rev=317716&r1=317715&r2=317716&view=diff
==
--- cfe/trunk/test/Driver/coverage.c (original)
+++ cfe/trunk/test/Driver/coverage.c Wed Nov  8 12:03:11 2017
@@ -1,4 +1,5 @@
 // Test coverage flag.
+// REQUIRES: system-windows
 //
 // RUN: %clang_cl -### -coverage %s -o foo/bar.o 2>&1 | FileCheck 
-check-prefix=CLANG-CL-COVERAGE %s
 // CLANG-CL-COVERAGE-NOT: error:


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


r290236 - Rename several methods on ASTRecordReader to follow LLVM style (lowerCamelCase).

2016-12-20 Thread David L. Jones via cfe-commits
Author: dlj
Date: Tue Dec 20 22:34:52 2016
New Revision: 290236

URL: http://llvm.org/viewvc/llvm-project?rev=290236&view=rev
Log:
Rename several methods on ASTRecordReader to follow LLVM style (lowerCamelCase).

Summary:
This follows up to r290217, and makes functions on ASTRecordReader consistent
and valid style.

Reviewers: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=290236&r1=290235&r2=290236&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Dec 20 22:34:52 2016
@@ -2250,13 +2250,13 @@ public:
   }
 
   /// \brief Read the record that describes the lexical contents of a DC.
-  bool ReadLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC) {
+  bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC) {
 return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor, Offset,
  DC);
   }
 
   /// \brief Read the record that describes the visible contents of a DC.
-  bool ReadVisibleDeclContextStorage(uint64_t Offset,
+  bool readVisibleDeclContextStorage(uint64_t Offset,
  serialization::DeclID ID) {
 return Reader->ReadVisibleDeclContextStorage(*F, F->DeclsCursor, Offset,
  ID);
@@ -2273,37 +2273,37 @@ public:
   }
 
   /// \brief Reads a statement.
-  Stmt *ReadStmt() { return Reader->ReadStmt(*F); }
+  Stmt *readStmt() { return Reader->ReadStmt(*F); }
 
   /// \brief Reads an expression.
-  Expr *ReadExpr() { return Reader->ReadExpr(*F); }
+  Expr *readExpr() { return Reader->ReadExpr(*F); }
 
   /// \brief Reads a sub-statement operand during statement reading.
-  Stmt *ReadSubStmt() { return Reader->ReadSubStmt(); }
+  Stmt *readSubStmt() { return Reader->ReadSubStmt(); }
 
   /// \brief Reads a sub-expression operand during statement reading.
-  Expr *ReadSubExpr() { return Reader->ReadSubExpr(); }
+  Expr *readSubExpr() { return Reader->ReadSubExpr(); }
 
   /// \brief Reads a TemplateArgumentLocInfo appropriate for the
   /// given TemplateArgument kind, advancing Idx.
   TemplateArgumentLocInfo
-  GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
+  getTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
 return Reader->GetTemplateArgumentLocInfo(*F, Kind, Record, Idx);
   }
 
   /// \brief Reads a TemplateArgumentLoc, advancing Idx.
   TemplateArgumentLoc
-  ReadTemplateArgumentLoc() {
+  readTemplateArgumentLoc() {
 return Reader->ReadTemplateArgumentLoc(*F, Record, Idx);
   }
 
   const ASTTemplateArgumentListInfo*
-  ReadASTTemplateArgumentListInfo() {
+  readASTTemplateArgumentListInfo() {
 return Reader->ReadASTTemplateArgumentListInfo(*F, Record, Idx);
   }
 
   /// \brief Reads a declarator info from the given record, advancing Idx.
-  TypeSourceInfo *GetTypeSourceInfo() {
+  TypeSourceInfo *getTypeSourceInfo() {
 return Reader->GetTypeSourceInfo(*F, Record, Idx);
   }
 
@@ -2320,13 +2320,13 @@ public:
   /// \brief Reads a declaration ID from the given position in this record.
   ///
   /// \returns The declaration ID read from the record, adjusted to a global 
ID.
-  serialization::DeclID ReadDeclID() {
+  serialization::DeclID readDeclID() {
 return Reader->ReadDeclID(*F, Record, Idx);
   }
 
   /// \brief Reads a declaration from the given position in a record in the
   /// given module, advancing Idx.
-  Decl *ReadDecl() {
+  Decl *readDecl() {
 return Reader->ReadDecl(*F, Record, Idx);
   }
 
@@ -2336,134 +2336,134 @@ public:
   /// \returns The declaration read from this location, casted to the given
   /// result type.
   template
-  T *ReadDeclAs() {
+  T *readDeclAs() {
 return Reader->ReadDeclAs(*F, Record, Idx);
   }
 
-  IdentifierInfo *GetIdentifierInfo() {
+  IdentifierInfo *getIdentifierInfo() {
 return Reader->GetIdentifierInfo(*F, Record, Idx);
   }
 
   /// \brief Read a selector from the Record, advancing Idx.
-  Selector ReadSelector() {
+  Selector readSelector() {
 return Reader->ReadSelector(*F, Record, Idx);
   }
 
   /// \brief Read a declaration name, advancing Idx.
-  DeclarationName ReadDeclarationName() {
+  DeclarationName readDeclarationName() {
 return Reader->ReadDeclarationName(*F, Record, Idx);
   }
-  void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name) 
{
+  void readDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name) 
{
 return Reader->ReadDeclarationNameLoc(*F, DNLoc, Name, Re

r291480 - Allow constexpr construction of subobjects unconditionally, not just in C++14.

2017-01-09 Thread David L. Jones via cfe-commits
Author: dlj
Date: Mon Jan  9 15:38:07 2017
New Revision: 291480

URL: http://llvm.org/viewvc/llvm-project?rev=291480&view=rev
Log:
Allow constexpr construction of subobjects unconditionally, not just in C++14.

Summary:
Per https://wg21.link/CWG1677, the C++11 standard did not clarify that constant
initialization of an object allowed constexpr brace-or-equal initialization of
subobjects:

  struct foo_t { union { int i; volatile int j; } u; };

  __attribute__((__require_constant_initialization__))
  static const foo_t x = {{0}};

Because foo_t::u has a volatile member, the initializer for x fails. However,
there is really no good reason, because this:

  union foo_u { int i; volatile int j; };
  __attribute__((__require_constant_initialization__))
  static const foo_u x = {0};

does have a constant initializer.

(This was triggered by musl's pthread_mutex_t type when building under C++11.)

Reviewers: rsmith

Subscribers: EricWF, cfe-commits

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

Added:
cfe/trunk/test/CXX/basic/basic.start/basic.start.init/p2.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CodeGenCXX/global-array-destruction.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=291480&r1=291479&r2=291480&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jan  9 15:38:07 2017
@@ -1627,8 +1627,17 @@ static bool CheckLiteralType(EvalInfo &I
   // C++1y: A constant initializer for an object o [...] may also invoke
   // constexpr constructors for o and its subobjects even if those objects
   // are of non-literal class types.
-  if (Info.getLangOpts().CPlusPlus14 && This &&
-  Info.EvaluatingDecl == This->getLValueBase())
+  //
+  // C++11 missed this detail for aggregates, so classes like this:
+  //   struct foo_t { union { int i; volatile int j; } u; };
+  // are not (obviously) initializable like so:
+  //   __attribute__((__require_constant_initialization__))
+  //   static const foo_t x = {{0}};
+  // because "i" is a subobject with non-literal initialization (due to the
+  // volatile member of the union). See:
+  //   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677
+  // Therefore, we use the C++1y behavior.
+  if (This && Info.EvaluatingDecl == This->getLValueBase())
 return true;
 
   // Prvalue constant expressions must be of literal types.

Added: cfe/trunk/test/CXX/basic/basic.start/basic.start.init/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.start/basic.start.init/p2.cpp?rev=291480&view=auto
==
--- cfe/trunk/test/CXX/basic/basic.start/basic.start.init/p2.cpp (added)
+++ cfe/trunk/test/CXX/basic/basic.start/basic.start.init/p2.cpp Mon Jan  9 
15:38:07 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11
+// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++14
+// expected-no-diagnostics
+
+struct foo_t {
+  union {
+int i;
+volatile int j;
+  } u;
+};
+
+__attribute__((__require_constant_initialization__))
+static const foo_t x = {{0}};
+
+union foo_u {
+  int i;
+  volatile int j;
+};
+
+__attribute__((__require_constant_initialization__))
+static const foo_u y = {0};

Modified: cfe/trunk/test/CodeGenCXX/global-array-destruction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/global-array-destruction.cpp?rev=291480&r1=291479&r2=291480&view=diff
==
--- cfe/trunk/test/CodeGenCXX/global-array-destruction.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/global-array-destruction.cpp Mon Jan  9 15:38:07 
2017
@@ -39,7 +39,7 @@ struct T {
 T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 };
 
 // CHECK: call {{.*}} @__cxa_atexit
-// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @t to %struct.T*), 
i64 6
+// CHECK: getelementptr inbounds ({{.*}} getelementptr inbounds ([2 x [3 x 
{{.*}}]], [2 x [3 x {{.*}}]]* @t, i32 0, i32 0, i32 0), i64 6)
 // CHECK: call void @_ZN1TD1Ev
 // CHECK: icmp eq {{.*}} @t
 // CHECK: br i1 {{.*}}
@@ -47,9 +47,9 @@ T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.
 static T t2[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 };
 
 // CHECK: call {{.*}} @__cxa_atexit
-// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @_ZL2t2 to 
%struct.T*), i64 6
+// CHECK: getelementptr inbounds ({{.*}} getelementptr inbounds ([2 x [3 x 
{{.*}}]], [2 x [3 x {{.*}}]]* @_ZL2t2, i32 0, i32 0, i32 0), i64 6)
 // CHECK: call void @_ZN1TD1Ev
-// CHECK: icmp eq {{.*}} @_ZL2t
+// CHECK: icmp eq {{.*}} @_ZL2t2
 // CHECK: br i1 {{.*}}
 
 using U = T[2][3];


___
cfe-commits mailing list
cfe-commits@lists.llvm.or

[PATCH] D24488: Simplify Clang's version number configuration in CMake.

2016-09-12 Thread David L. Jones via cfe-commits
dlj created this revision.
dlj added a reviewer: rsmith.
dlj added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Simplify Clang's version number configuration in CMake.

Currently, the Clang version is computed as follows:

 1. LLVM defines major, minor, and patch versions, all statically set. Today,
these are 4, 0, and 0, respectively.
 2. The static version numbers are combined into PACKAGE_VERSION along with a
suffix, so the result today looks like "4.0.0svn".
 3. Clang extracts CLANG_VERSION from PACKAGE_VERSION using a regexp. The regexp
allows the patch level to omitted, and drops any non-digit trailing values.
Today, this result looks like "4.0.0".
 4. CLANG_VERSION is then split further into CLANG_VERSION_MAJOR and
CLANG_VERSION_MINOR. Today, these resolve to 4 and 0, respectively.
 5. If CLANG_VERSION matches a regexp with three version components, then
CLANG_VERSION_PATCHLEVEL is extracted and the CLANG_HAS_VERSION_PATCHLEVEL
variable is set to 1. Today, these values are 0 and 1, respectively.
 6. The CLANG_VERSION_* variables (and CLANG_HAS_VERSION_PATCHLEVEL) are
configured into [llvm/tools/clang/]include/clang/Basic/Version.inc
verbatim by CMake.
 7. In [llvm/tools/clang/]include/clang/Basic/Version.h, macros are defined
conditionally, based on CLANG_HAS_VERSION_PATCHLEVEL, to compute
CLANG_VERSION_STRING as either a two- or three-level version number. Today,
this value is "4.0.0", because despite the patchlevel being 0, it was
matched by regexp and is thus "HAS"ed by the preprocessor. This string is
then used wherever Clang's "version" is needed [*].

[*] Including, notably, by compiler-rt, for computing its installation path.

This change collapses steps 2-5 by defaulting Clang to use LLVM's (non-string)
version components for the Clang version (see [*] for why not PACKAGE_VERSION),
and collapses steps 6 and 7 by simply writing CLANG_VERSION_STRING into
Version.inc. The Clang version today always uses the patchlevel form, so the
collapsed Version.inc does not have logic for a version without a patch level.

Historically speaking, this technique began with the VER file in r82085 (which
survives in the form of the regexp in #3). The major, minor, and patchlevel
versions were introduced by r106863 (which remains in #4-6). The VER file itself
was deleted in favor of the LLVM version number in r106914. On the LLVM side,
the individual LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, and PACKAGE_VERSION
weren't introduced for nearly two more years, until r150405.

https://reviews.llvm.org/D24488

Files:
  CMakeLists.txt
  include/clang/Basic/Version.h
  include/clang/Basic/Version.inc.in
  lib/Frontend/InitPreprocessor.cpp

Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -511,16 +511,12 @@
 #define TOSTR(X) TOSTR2(X)
   Builder.defineMacro("__clang_major__", TOSTR(CLANG_VERSION_MAJOR));
   Builder.defineMacro("__clang_minor__", TOSTR(CLANG_VERSION_MINOR));
-#ifdef CLANG_VERSION_PATCHLEVEL
   Builder.defineMacro("__clang_patchlevel__", TOSTR(CLANG_VERSION_PATCHLEVEL));
-#else
-  Builder.defineMacro("__clang_patchlevel__", "0");
-#endif
+#undef TOSTR
+#undef TOSTR2
   Builder.defineMacro("__clang_version__", 
   "\"" CLANG_VERSION_STRING " "
   + getClangFullRepositoryVersion() + "\"");
-#undef TOSTR
-#undef TOSTR2
   if (!LangOpts.MSVCCompat) {
 // Currently claim to be compatible with GCC 4.2.1-5621, but only if we're
 // not compiling for MSVC compatibility
Index: include/clang/Basic/Version.inc.in
===
--- include/clang/Basic/Version.inc.in
+++ include/clang/Basic/Version.inc.in
@@ -1,6 +1,5 @@
 #define CLANG_VERSION @CLANG_VERSION@
+#define CLANG_VERSION_STRING "@CLANG_VERSION@"
 #define CLANG_VERSION_MAJOR @CLANG_VERSION_MAJOR@
 #define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
-#if @CLANG_HAS_VERSION_PATCHLEVEL@
 #define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
-#endif
Index: include/clang/Basic/Version.h
===
--- include/clang/Basic/Version.h
+++ include/clang/Basic/Version.h
@@ -19,26 +19,6 @@
 #include "clang/Basic/Version.inc"
 #include "llvm/ADT/StringRef.h"
 
-/// \brief Helper macro for CLANG_VERSION_STRING.
-#define CLANG_MAKE_VERSION_STRING2(X) #X
-
-#ifdef CLANG_VERSION_PATCHLEVEL
-/// \brief Helper macro for CLANG_VERSION_STRING.
-#define CLANG_MAKE_VERSION_STRING(X,Y,Z) CLANG_MAKE_VERSION_STRING2(X.Y.Z)
-
-/// \brief A string that describes the Clang version number, e.g., "1.0".
-#define CLANG_VERSION_STRING \
-  CLANG_MAKE_VERSION_STRING(CLANG_VERSION_MAJOR,CLANG_VERSION_MINOR, \
-CLANG_VERSION_PATCHLEVEL)
-#else
-/// \brief Helper macro for CLANG_VERSI

r281666 - Simplify Clang's version number configuration in CMake.

2016-09-15 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Sep 15 17:12:26 2016
New Revision: 281666

URL: http://llvm.org/viewvc/llvm-project?rev=281666&view=rev
Log:
Simplify Clang's version number configuration in CMake.

Currently, the Clang version is computed as follows:

 1. LLVM defines major, minor, and patch versions, all statically set. Today,
these are 4, 0, and 0, respectively.
 2. The static version numbers are combined into PACKAGE_VERSION along with a
suffix, so the result today looks like "4.0.0svn".
 3. Clang extracts CLANG_VERSION from PACKAGE_VERSION using a regexp. The regexp
allows the patch level to omitted, and drops any non-digit trailing values.
Today, this result looks like "4.0.0".
 4. CLANG_VERSION is then split further into CLANG_VERSION_MAJOR and
CLANG_VERSION_MINOR. Today, these resolve to 4 and 0, respectively.
 5. If CLANG_VERSION matches a regexp with three version components, then
CLANG_VERSION_PATCHLEVEL is extracted and the CLANG_HAS_VERSION_PATCHLEVEL
variable is set to 1. Today, these values are 0 and 1, respectively.
 6. The CLANG_VERSION_* variables (and CLANG_HAS_VERSION_PATCHLEVEL) are
configured into [llvm/tools/clang/]include/clang/Basic/Version.inc
verbatim by CMake.
 7. In [llvm/tools/clang/]include/clang/Basic/Version.h, macros are defined
conditionally, based on CLANG_HAS_VERSION_PATCHLEVEL, to compute
CLANG_VERSION_STRING as either a two- or three-level version number. Today,
this value is "4.0.0", because despite the patchlevel being 0, it was
matched by regexp and is thus "HAS"ed by the preprocessor. This string is
then used wherever Clang's "version" is needed [*].

[*] Including, notably, by compiler-rt, for computing its installation path.

This change collapses steps 2-5 by defaulting Clang to use LLVM's (non-string)
version components for the Clang version (see [*] for why not PACKAGE_VERSION),
and collapses steps 6 and 7 by simply writing CLANG_VERSION_STRING into
Version.inc. The Clang version today always uses the patchlevel form, so the
collapsed Version.inc does not have logic for a version without a patch level.

Historically speaking, this technique began with the VER file in r82085 (which
survives in the form of the regexp in #3). The major, minor, and patchlevel
versions were introduced by r106863 (which remains in #4-6). The VER file itself
was deleted in favor of the LLVM version number in r106914. On the LLVM side,
the individual LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, and PACKAGE_VERSION
weren't introduced for nearly two more years, until r150405.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Basic/Version.h
cfe/trunk/include/clang/Basic/Version.inc.in
cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=281666&r1=281665&r2=281666&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Sep 15 17:12:26 2016
@@ -262,22 +262,13 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_
 endif()
 
 # Compute the Clang version from the LLVM version.
-string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
-  ${PACKAGE_VERSION})
+set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
+set(CLANG_VERSION_MINOR ${LLVM_VERSION_MINOR})
+set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH})
+# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX.
+set(CLANG_VERSION 
"${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}")
 message(STATUS "Clang version: ${CLANG_VERSION}")
 
-string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" CLANG_VERSION_MAJOR
-  ${CLANG_VERSION})
-string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" CLANG_VERSION_MINOR
-  ${CLANG_VERSION})
-if (${CLANG_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
-  set(CLANG_HAS_VERSION_PATCHLEVEL 1)
-  string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" 
CLANG_VERSION_PATCHLEVEL
-${CLANG_VERSION})
-else()
-  set(CLANG_HAS_VERSION_PATCHLEVEL 0)
-endif()
-
 # Configure the Version.inc file.
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/include/clang/Basic/Version.inc.in

Modified: cfe/trunk/include/clang/Basic/Version.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Version.h?rev=281666&r1=281665&r2=281666&view=diff
==
--- cfe/trunk/include/clang/Basic/Version.h (original)
+++ cfe/trunk/include/clang/Basic/Version.h Thu Sep 15 17:12:26 2016
@@ -19,26 +19,6 @@
 #include "clang/Basic/Version.inc"
 #include "llvm/ADT/StringRef.h"
 
-/// \brief Helper macro for CLANG_VERSION_STRING.
-#define CLANG_MAKE_VERSION_STRING2(X) #X
-
-#ifdef CLANG_VERSION_PATCHLEVEL
-/// \brief Helper macro for CLANG_VERSION_STRING.
-#define CLANG_MAKE_VERSION_STRING(X,Y,Z) CLANG_MAKE_VERSION_STRING2(X.Y.Z)
-
-/// \brief A string 

r292849 - Add LF_ prefix to LibFunc enums in TargetLibraryInfo.

2017-01-23 Thread David L. Jones via cfe-commits
Author: dlj
Date: Mon Jan 23 17:16:58 2017
New Revision: 292849

URL: http://llvm.org/viewvc/llvm-project?rev=292849&view=rev
Log:
Add LF_ prefix to LibFunc enums in TargetLibraryInfo.

Summary:
The LibFunc::Func enum holds enumerators named for libc functions.
Unfortunately, there are real situations, including libc implementations, where
function names are actually macros (musl uses "#define fopen64 fopen", for
example; any other transitively visible macro would have similar effects).

Strictly speaking, a conforming C++ Standard Library should provide any such
macros as functions instead (via ). However, there are some "library"
functions which are not part of the standard, and thus not subject to this
rule (fopen64, for example). So, in order to be both portable and consistent,
the enum should not use the bare function names.

The old enum naming used a namespace LibFunc and an enum Func, with bare
enumerators. This patch changes LibFunc to be an enum with enumerators prefixed
with "LF_". (Unfortunately, a scoped enum is not sufficient to override macros.)

These changes are for clang. See https://reviews.llvm.org/D28476 for LLVM.

Reviewers: rsmith

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=292849&r1=292848&r2=292849&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jan 23 17:16:58 2017
@@ -262,7 +262,7 @@ static TargetLibraryInfoImpl *createTLII
 TLII->disableAllFunctions();
   else {
 // Disable individual libc/libm calls in TargetLibraryInfo.
-LibFunc::Func F;
+LibFunc F;
 for (auto &FuncName : CodeGenOpts.getNoBuiltinFuncs())
   if (TLII->getLibFunc(FuncName, F))
 TLII->setUnavailable(F);


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


r292868 - Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.

2017-01-23 Thread David L. Jones via cfe-commits
Author: dlj
Date: Mon Jan 23 19:04:30 2017
New Revision: 292868

URL: http://llvm.org/viewvc/llvm-project?rev=292868&view=rev
Log:
Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.

Summary:
This patch changes TableGen-generated code in AttrPCHRead to call functions on
ASTRecordReader, instead of passing separate parameters to ASTReader. This is a
follow-up to r290217.

Reviewers: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=292868&r1=292867&r2=292868&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Jan 23 19:04:30 2017
@@ -2098,8 +2098,7 @@ public:
  unsigned &Idx);
 
   /// \brief Reads attributes from the current stream position.
-  void ReadAttributes(ModuleFile &F, AttrVec &Attrs,
-  const RecordData &Record, unsigned &Idx);
+  void ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs);
 
   /// \brief Reads a statement.
   Stmt *ReadStmt(ModuleFile &F);
@@ -2284,6 +2283,14 @@ public:
   /// \brief Reads a sub-expression operand during statement reading.
   Expr *readSubExpr() { return Reader->ReadSubExpr(); }
 
+  /// \brief Reads a declaration with the given local ID in the given module.
+  ///
+  /// \returns The requested declaration, casted to the given return type.
+  template
+  T *GetLocalDeclAs(uint32_t LocalID) {
+return cast_or_null(Reader->GetLocalDecl(*F, LocalID));
+  }
+
   /// \brief Reads a TemplateArgumentLocInfo appropriate for the
   /// given TemplateArgument kind, advancing Idx.
   TemplateArgumentLocInfo
@@ -2455,7 +2462,7 @@ public:
 
   /// \brief Reads attributes from the current stream position, advancing Idx.
   void readAttributes(AttrVec &Attrs) {
-return Reader->ReadAttributes(*F, Attrs, Record, Idx);
+return Reader->ReadAttributes(*this, Attrs);
   }
 
   /// \brief Reads a token out of a record, advancing Idx.

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=292868&r1=292867&r2=292868&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Jan 23 19:04:30 2017
@@ -1831,7 +1831,7 @@ void ASTDeclReader::VisitImportDecl(Impo
   SourceLocation *StoredLocs = D->getTrailingObjects();
   for (unsigned I = 0, N = Record.back(); I != N; ++I)
 StoredLocs[I] = ReadSourceLocation();
-  (void)Record.readInt(); // The number of stored source locations.
+  Record.skipInts(1); // The number of stored source locations.
 }
 
 void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) {
@@ -2471,12 +2471,11 @@ void ASTDeclReader::VisitOMPCapturedExpr
 
//===--===//
 
 /// \brief Reads attributes from the current stream position.
-void ASTReader::ReadAttributes(ModuleFile &F, AttrVec &Attrs,
-   const RecordData &Record, unsigned &Idx) {
-  for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) {
+void ASTReader::ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs) {
+  for (unsigned i = 0, e = Record.readInt(); i != e; ++i) {
 Attr *New = nullptr;
-attr::Kind Kind = (attr::Kind)Record[Idx++];
-SourceRange Range = ReadSourceRange(F, Record, Idx);
+attr::Kind Kind = (attr::Kind)Record.readInt();
+SourceRange Range = Record.readSourceRange();
 
 #include "clang/Serialization/AttrPCHRead.inc"
 

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=292868&r1=292867&r2=292868&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Jan 23 19:04:30 2017
@@ -90,13 +90,13 @@ GetFlattenedSpellings(const Record &Attr
 
 static std::string ReadPCHRecord(StringRef type) {
   return StringSwitch(type)
-.EndsWith("Decl *", "GetLocalDeclAs<" 
-  + std::string(type, 0, type.size()-1) + ">(F, Record[Idx++])")
-.Case("TypeSourceInfo *", "GetTypeSourceInfo(F, Record, Idx)")
-.Case("Expr *", "ReadExpr(F)")
-.Case("IdentifierInfo *", "GetIdentifierInfo(F, Record, Idx)")
-.Case("StringRef", "ReadString(Record, Idx)")
-.Default("Record[Idx++]");
+.EndsWith("Decl *", "Record

[libcxx] r294683 - Check for musl-libc's max_align_t in addition to other variants.

2017-02-09 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Feb  9 19:27:42 2017
New Revision: 294683

URL: http://llvm.org/viewvc/llvm-project?rev=294683&view=rev
Log:
Check for musl-libc's max_align_t in addition to other variants.

Summary:
Libcxx will define its own max_align_t when it is not available. However, the
availability checks today only check for Clang's definition and GCC's
definition. In particular, it does not check for musl's definition, which is the
same as GCC's but guarded with a different macro.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: chandlerc, cfe-commits

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

Modified:
libcxx/trunk/include/cstddef
libcxx/trunk/include/stddef.h

Modified: libcxx/trunk/include/cstddef
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=294683&r1=294682&r2=294683&view=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Thu Feb  9 19:27:42 2017
@@ -48,7 +48,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 using ::ptrdiff_t;
 using ::size_t;
 
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
+#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
+defined(__DEFINED_max_align_t)
 // Re-use the compiler's  max_align_t where possible.
 using ::max_align_t;
 #else

Modified: libcxx/trunk/include/stddef.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stddef.h?rev=294683&r1=294682&r2=294683&view=diff
==
--- libcxx/trunk/include/stddef.h (original)
+++ libcxx/trunk/include/stddef.h Thu Feb  9 19:27:42 2017
@@ -53,7 +53,8 @@ using std::nullptr_t;
 }
 
 // Re-use the compiler's  max_align_t where possible.
-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T)
+#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
+!defined(__DEFINED_max_align_t)
 typedef long double max_align_t;
 #endif
 


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


[clang-tools-extra] r294689 - Adds the commandline need to run clang-tidy tests.

2017-02-09 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Feb  9 19:48:43 2017
New Revision: 294689

URL: http://llvm.org/viewvc/llvm-project?rev=294689&view=rev
Log:
Adds the commandline need to run clang-tidy tests.

Patch by Jorge Gorbe (lethalantidote)

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=294689&r1=294688&r2=294689&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Thu Feb  9 19:48:43 2017
@@ -537,6 +537,12 @@ YAML format:
 Testing Checks
 --
 
+To run tests for :program:`clang-tidy` use the command:
+
+.. code-block:: console
+
+  $ ninja check-clang-tools
+
 :program:`clang-tidy` checks can be tested using either unit tests or
 `lit`_ tests. Unit tests may be more convenient to test complex replacements
 with strict checks. `Lit`_ tests allow using partial text matching and regular


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


[libcxx] r306755 - [lit/libcxx] Fix a remaining reference to lit.util.capture() in custom libcxx/Darwin code.

2017-06-29 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Jun 29 16:07:27 2017
New Revision: 306755

URL: http://llvm.org/viewvc/llvm-project?rev=306755&view=rev
Log:
[lit/libcxx] Fix a remaining reference to lit.util.capture() in custom 
libcxx/Darwin code.

Summary:
This reference to lit.util.capture is functionally identical to
subprocess.check_output, so this change switches to call the library routine
directly.

Reviewers: mzolotukhin, EricWF

Reviewed By: mzolotukhin

Subscribers: sanjoy, llvm-commits

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

Modified:
libcxx/trunk/utils/libcxx/test/target_info.py

Modified: libcxx/trunk/utils/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/target_info.py?rev=306755&r1=306754&r2=306755&view=diff
==
--- libcxx/trunk/utils/libcxx/test/target_info.py (original)
+++ libcxx/trunk/utils/libcxx/test/target_info.py Thu Jun 29 16:07:27 2017
@@ -8,11 +8,11 @@
 #===--===//
 
 import importlib
-import lit.util  # pylint: disable=import-error,no-name-in-module
 import locale
 import os
 import platform
 import re
+import subprocess
 import sys
 
 class DefaultTargetInfo(object):
@@ -73,12 +73,13 @@ class DarwinLocalTI(DefaultTargetInfo):
 super(DarwinLocalTI, self).__init__(full_config)
 
 def is_host_macosx(self):
-name = lit.util.capture(['sw_vers', '-productName']).strip()
+name = subprocess.check_output(['sw_vers', '-productName']).strip()
 return name == "Mac OS X"
 
 def get_macosx_version(self):
 assert self.is_host_macosx()
-version = lit.util.capture(['sw_vers', '-productVersion']).strip()
+version = subprocess.check_output(
+['sw_vers', '-productVersion']).strip()
 version = re.sub(r'([0-9]+\.[0-9]+)(\..*)?', r'\1', version)
 return version
 
@@ -86,7 +87,7 @@ class DarwinLocalTI(DefaultTargetInfo):
 assert self.is_host_macosx()
 cmd = ['xcrun', '--sdk', name, '--show-sdk-path']
 try:
-out = lit.util.capture(cmd).strip()
+out = subprocess.check_output(cmd).strip()
 except OSError:
 pass
 
@@ -127,7 +128,7 @@ class DarwinLocalTI(DefaultTargetInfo):
 else:
 cmd = ['xcrun', '--show-sdk-path']
 try:
-out = lit.util.capture(cmd).strip()
+out = subprocess.check_output(cmd).strip()
 res = 0
 except OSError:
 res = -1


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


r307320 - Change remaining references to lit.util.capture to use subprocess.check_output.

2017-07-06 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Jul  6 14:46:47 2017
New Revision: 307320

URL: http://llvm.org/viewvc/llvm-project?rev=307320&view=rev
Log:
Change remaining references to lit.util.capture to use subprocess.check_output.

Summary:
The capture() function was removed in r306625. This should fix PGO breakages
reported by Michael Zolotukhin.

Reviewers: mzolotukhin

Subscribers: sanjoy, llvm-commits

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

Modified:
cfe/trunk/test/Unit/lit.cfg
cfe/trunk/test/lit.cfg

Modified: cfe/trunk/test/Unit/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.cfg?rev=307320&r1=307319&r2=307320&view=diff
==
--- cfe/trunk/test/Unit/lit.cfg (original)
+++ cfe/trunk/test/Unit/lit.cfg Thu Jul  6 14:46:47 2017
@@ -4,6 +4,7 @@
 
 import os
 import platform
+import subprocess
 
 import lit.formats
 import lit.util
@@ -65,8 +66,8 @@ if config.test_exec_root is None:
 lit_config.fatal('No site specific configuration available!')
 
 # Get the source and object roots.
-llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
-llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
+llvm_src_root = subprocess.check_output(['llvm-config', 
'--src-root']).strip()
+llvm_obj_root = subprocess.check_output(['llvm-config', 
'--obj-root']).strip()
 clang_src_root = os.path.join(llvm_src_root, "tools", "clang")
 clang_obj_root = os.path.join(llvm_obj_root, "tools", "clang")
 

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=307320&r1=307319&r2=307320&view=diff
==
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Thu Jul  6 14:46:47 2017
@@ -148,8 +148,8 @@ if config.test_exec_root is None:
 lit_config.fatal('No site specific configuration available!')
 
 # Get the source and object roots.
-llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
-llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
+llvm_src_root = subprocess.check_output(['llvm-config', 
'--src-root']).strip()
+llvm_obj_root = subprocess.check_output(['llvm-config', 
'--obj-root']).strip()
 clang_src_root = os.path.join(llvm_src_root, "tools", "clang")
 clang_obj_root = os.path.join(llvm_obj_root, "tools", "clang")
 


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


r288997 - Add more tests for MSVC version handling.

2016-12-07 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Dec  7 17:39:44 2016
New Revision: 288997

URL: http://llvm.org/viewvc/llvm-project?rev=288997&view=rev
Log:
Add more tests for MSVC version handling.

Summary:
This change adds more test cases for the default MSVC compatibility version:
 1. When -fms-extensions is supplied, but -fmsc-version and
-fms-compatibility-version are not.
 2. With the target triple specifies an MSVC environment, but no other
-fms* flags.

Reviewers: rnk, llvm-commits

Subscribers: hans, compnerd, amccarth

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

Modified:
cfe/trunk/test/Driver/msc-version.c
cfe/trunk/test/Driver/msvc-triple.c

Modified: cfe/trunk/test/Driver/msc-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msc-version.c?rev=288997&r1=288996&r2=288997&view=diff
==
--- cfe/trunk/test/Driver/msc-version.c (original)
+++ cfe/trunk/test/Driver/msc-version.c Wed Dec  7 17:39:44 2016
@@ -55,3 +55,12 @@
 // CHECK-MSC-15-NOT: "-fmsc-version=150020706"
 // CHECK-MSC-15: "-fms-compatibility-version=15.0.20706"
 
+//
+// Verify default version with -fms-extensions
+//
+
+// RUN: %clang -target i686-windows -fms-extensions -dM -E - http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msvc-triple.c?rev=288997&r1=288996&r2=288997&view=diff
==
--- cfe/trunk/test/Driver/msvc-triple.c (original)
+++ cfe/trunk/test/Driver/msvc-triple.c Wed Dec  7 17:39:44 2016
@@ -1,7 +1,9 @@
 // RUN: %clang -target i686-pc-windows-msvc19 -S -emit-llvm %s -o - | 
FileCheck %s --check-prefix=TARGET-19
 // RUN: %clang -target i686-pc-windows-msvc   -S -emit-llvm %s -o - 
-fms-compatibility-version=19 | FileCheck %s --check-prefix=OVERRIDE-19
 // RUN: %clang -target i686-pc-windows-msvc-elf -S -emit-llvm %s -o - | 
FileCheck %s --check-prefix=ELF-DEFAULT
+// RUN: %clang -target i686-pc-windows-msvc   -S -emit-llvm %s -o - | 
FileCheck %s --check-prefix=DEFAULT
 
 // TARGET-19:   target triple = "i686-pc-windows-msvc19.0.0"
 // OVERRIDE-19: target triple = "i686-pc-windows-msvc19.0.0"
 // ELF-DEFAULT: target triple = "i686-pc-windows-msvc{{.*}}-elf"
+// DEFAULT: target triple = "i686-pc-windows-msvc{{[^-]+}}"


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


r288998 - Refactor how the MSVC toolchain searches for a compatibility version.

2016-12-07 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Dec  7 17:41:58 2016
New Revision: 288998

URL: http://llvm.org/viewvc/llvm-project?rev=288998&view=rev
Log:
Refactor how the MSVC toolchain searches for a compatibility version.

Summary:
The MSVC toolchain and Clang driver combination currently uses a fairly complex
sequence of steps to determine the MS compatibility version to pass to cc1.
There is some oddness in this sequence currently, with some code which inspects
flags in the toolchain, and some code which inspects the triple and local
environment in the driver code.

This change is an attempt to consolidate most of this logic so that
Win32-specific code lives in MSVCToolChain.cpp. I'm not 100% happy with the
split, so any suggestions are welcome.

There are a few things you might want to watch for for specifically:

 - On all platforms, if MSVC compatibility flags are provided (and valid), use
   those.
 - The fallback sequence should be the same as before, but is now consolidated
   into MSVCToolChain::getMSVCVersion:
   - Otherwise, try to use the Triple.
   - Otherwise, on Windows, check the executable.
   - Otherwise, on Windows or with --fms-extensions, default to 18.
   - Otherwise, we can't determine the version.
 - MSVCToolChain::ComputeEffectiveTriple no longer calls the base
   ToolChain::ComputeEffectiveClangTriple. The only thing it would change for
   Windows the architecture, which we don't care about for the compatibility
   version.
- I'm not sure whether this is philosophically correct (but it should
  be easy to add back to MSVCToolChain::getMSVCVersionFromTriple if not).
- Previously, Tools.cpp just called getTriple() anyhow, so it doesn't look
  like the effective triple was always being used previously anyhow.

Reviewers: hans, compnerd, llvm-commits, rnk

Subscribers: amccarth

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

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/MSVCToolChain.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=288998&r1=288997&r2=288998&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Dec  7 17:41:58 2016
@@ -442,15 +442,15 @@ public:
   virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const;
 
+  /// \brief On Windows, returns the MSVC compatibility version.
+  virtual VersionTuple computeMSVCVersion(const Driver *D,
+  const llvm::opt::ArgList &Args) 
const;
+
   /// \brief Return sanitizers which are available in this toolchain.
   virtual SanitizerMask getSupportedSanitizers() const;
 
   /// \brief Return sanitizers which are enabled by default.
   virtual SanitizerMask getDefaultSanitizers() const { return 0; }
-
-  /// \brief On Windows, returns the version of cl.exe.  On other platforms,
-  /// returns an empty VersionTuple.
-  virtual VersionTuple getMSVCVersionFromExe() const { return VersionTuple(); }
 };
 
 /// Set a ToolChain's effective triple. Reset it when the registration object

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=288998&r1=288997&r2=288998&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Wed Dec  7 17:41:58 2016
@@ -16,6 +16,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -472,6 +473,14 @@ bool MSVCToolChain::getVisualStudioBinar
   return true;
 }
 
+VersionTuple MSVCToolChain::getMSVCVersionFromTriple() const {
+  unsigned Major, Minor, Micro;
+  getTriple().getEnvironmentVersion(Major, Minor, Micro);
+  if (Major || Minor || Micro)
+return VersionTuple(Major, Minor, Micro);
+  return VersionTuple();
+}
+
 VersionTuple MSVCToolChain::getMSVCVersionFromExe() const {
   VersionTuple Version;
 #ifdef USE_WIN32
@@ -668,21 +677,34 @@ void MSVCToolChain::AddClangCXXStdlibInc
   // FIXME: There should probably be logic here to find libc++ on Windows.
 }
 
+VersionTuple MSVCToolChain::computeMSVCVersion(const Driver *D,
+   const ArgList &Args) const {
+  bool IsWindowsMSVC = getTriple().isWindowsMSVCEnvironment();
+  VersionTuple MSVT = ToolChain::computeMSVCVersion(D, Args);
+  if (MSVT.empty()) MSVT = getMS

r289011 - Loosen checks for _MSC_FULL_VER under -fms-extensions.

2016-12-07 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Dec  7 19:11:41 2016
New Revision: 289011

URL: http://llvm.org/viewvc/llvm-project?rev=289011&view=rev
Log:
Loosen checks for _MSC_FULL_VER under -fms-extensions.

Summary:
On actual Windows hosts :-) , this could report something other than the
fallback, with a non-zero minor/build number.

Reviewers: rnk, llvm-commits

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

Modified:
cfe/trunk/test/Driver/msc-version.c

Modified: cfe/trunk/test/Driver/msc-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msc-version.c?rev=289011&r1=289010&r2=289011&view=diff
==
--- cfe/trunk/test/Driver/msc-version.c (original)
+++ cfe/trunk/test/Driver/msc-version.c Wed Dec  7 19:11:41 2016
@@ -62,5 +62,5 @@
 // RUN: %clang -target i686-windows -fms-extensions -dM -E - http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17405: Use Backend_EmitMCNull for null codegen unit tests.

2016-02-18 Thread David L. Jones via cfe-commits
dlj created this revision.
dlj added a subscriber: cfe-commits.

Using Backend_EmitLL attemps to create a file with an empty filename.
This is problematic in certain environments: an empty filename may be
illegal, or the default output path may not be writable (in the case
where an empty filename would otherwise have some non-failing
semantics). This patch switches to use Backend_EmitMCNull, which
allows CodeGen to run, but does not attempt to create or write an
output file.

http://reviews.llvm.org/D17405

Files:
  unittests/Frontend/CodeGenActionTest.cpp

Index: unittests/Frontend/CodeGenActionTest.cpp
===
--- unittests/Frontend/CodeGenActionTest.cpp
+++ unittests/Frontend/CodeGenActionTest.cpp
@@ -26,7 +26,7 @@
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {


Index: unittests/Frontend/CodeGenActionTest.cpp
===
--- unittests/Frontend/CodeGenActionTest.cpp
+++ unittests/Frontend/CodeGenActionTest.cpp
@@ -26,7 +26,7 @@
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17405: Use Backend_EmitMCNull for null codegen unit tests.

2016-02-18 Thread David L. Jones via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261252: Use Backend_EmitMCNull for null codegen unit tests. 
(authored by dlj).

Changed prior to commit:
  http://reviews.llvm.org/D17405?vs=48380&id=48386#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17405

Files:
  cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp

Index: cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
===
--- cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
+++ cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
@@ -26,7 +26,7 @@
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {


Index: cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
===
--- cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
+++ cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
@@ -26,7 +26,7 @@
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261252 - Use Backend_EmitMCNull for null codegen unit tests.

2016-02-18 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Feb 18 14:27:16 2016
New Revision: 261252

URL: http://llvm.org/viewvc/llvm-project?rev=261252&view=rev
Log:
Use Backend_EmitMCNull for null codegen unit tests.

Using Backend_EmitLL attemps to create a file with an empty filename.
This is problematic in certain environments: an empty filename may be
illegal, or the default output path may not be writable (in the case
where an empty filename would otherwise have some non-failing
semantics). This patch switches to use Backend_EmitMCNull, which
allows CodeGen to run, but does not attempt to create or write an
output file.

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

Modified:
cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp

Modified: cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp?rev=261252&r1=261251&r2=261252&view=diff
==
--- cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp (original)
+++ cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp Thu Feb 18 14:27:16 2016
@@ -26,7 +26,7 @@ namespace {
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {


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