[PATCH] D35546: [AArch64] Produce correct defaultlib directives for windows in MSVC style

2017-07-19 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308584: [AArch64] Produce correct defaultlib directives for 
windows in MSVC style (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D35546?vs=107058=107443#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35546

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/pragma-comment.c


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -4860,6 +4860,22 @@
 
   bool doesReturnSlotInterfereWithArgs() const override { return false; }
 };
+
+class WindowsAArch64TargetCodeGenInfo : public AArch64TargetCodeGenInfo {
+public:
+  WindowsAArch64TargetCodeGenInfo(CodeGenTypes , AArch64ABIInfo::ABIKind K)
+  : AArch64TargetCodeGenInfo(CGT, K) {}
+
+  void getDependentLibraryOption(llvm::StringRef Lib,
+ llvm::SmallString<24> ) const override {
+Opt = "/DEFAULTLIB:" + qualifyWindowsLibrary(Lib);
+  }
+
+  void getDetectMismatchOption(llvm::StringRef Name, llvm::StringRef Value,
+   llvm::SmallString<32> ) const override {
+Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
+  }
+};
 }
 
 ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty) const {
@@ -8508,7 +8524,8 @@
 if (getTarget().getABI() == "darwinpcs")
   Kind = AArch64ABIInfo::DarwinPCS;
 else if (Triple.isOSWindows())
-  Kind = AArch64ABIInfo::Win64;
+  return SetCGInfo(
+  new WindowsAArch64TargetCodeGenInfo(Types, AArch64ABIInfo::Win64));
 
 return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
   }
Index: cfe/trunk/test/CodeGen/pragma-comment.c
===
--- cfe/trunk/test/CodeGen/pragma-comment.c
+++ cfe/trunk/test/CodeGen/pragma-comment.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 %s -triple thumbv7-linux-gnueabihf -fms-extensions 
-emit-llvm -o - | FileCheck -check-prefix LINUX %s
 // RUN: %clang_cc1 %s -triple i686-pc-linux -fms-extensions -emit-llvm -o - | 
FileCheck -check-prefix LINUX %s
 // RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -fms-extensions -emit-llvm -o - 
| FileCheck -check-prefix PS4 %s
+// RUN: %clang_cc1 %s -triple aarch64-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
 
 #pragma comment(lib, "msvcrt.lib")
 #pragma comment(lib, "kernel32")


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -4860,6 +4860,22 @@
 
   bool doesReturnSlotInterfereWithArgs() const override { return false; }
 };
+
+class WindowsAArch64TargetCodeGenInfo : public AArch64TargetCodeGenInfo {
+public:
+  WindowsAArch64TargetCodeGenInfo(CodeGenTypes , AArch64ABIInfo::ABIKind K)
+  : AArch64TargetCodeGenInfo(CGT, K) {}
+
+  void getDependentLibraryOption(llvm::StringRef Lib,
+ llvm::SmallString<24> ) const override {
+Opt = "/DEFAULTLIB:" + qualifyWindowsLibrary(Lib);
+  }
+
+  void getDetectMismatchOption(llvm::StringRef Name, llvm::StringRef Value,
+   llvm::SmallString<32> ) const override {
+Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
+  }
+};
 }
 
 ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty) const {
@@ -8508,7 +8524,8 @@
 if (getTarget().getABI() == "darwinpcs")
   Kind = AArch64ABIInfo::DarwinPCS;
 else if (Triple.isOSWindows())
-  Kind = AArch64ABIInfo::Win64;
+  return SetCGInfo(
+  new WindowsAArch64TargetCodeGenInfo(Types, AArch64ABIInfo::Win64));
 
 return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
   }
Index: cfe/trunk/test/CodeGen/pragma-comment.c
===
--- cfe/trunk/test/CodeGen/pragma-comment.c
+++ cfe/trunk/test/CodeGen/pragma-comment.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 %s -triple thumbv7-linux-gnueabihf -fms-extensions -emit-llvm -o - | FileCheck -check-prefix LINUX %s
 // RUN: %clang_cc1 %s -triple i686-pc-linux -fms-extensions -emit-llvm -o - | FileCheck -check-prefix LINUX %s
 // RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -fms-extensions -emit-llvm -o - | FileCheck -check-prefix PS4 %s
+// RUN: %clang_cc1 %s -triple aarch64-windows-msvc -fms-extensions -emit-llvm -o - | FileCheck %s
 
 #pragma comment(lib, "msvcrt.lib")
 #pragma comment(lib, "kernel32")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32047: [Driver] Add support for default UBSan blacklists

2017-07-19 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment.

Should we simply not have `ubsan_blacklist.txt` if it's empty?

Otherwise LGTM


https://reviews.llvm.org/D32047



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-07-19 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: include/clang/Basic/Attr.td:2421
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];

davide wrote:
> rnk wrote:
> > Prazek wrote:
> > > rnk wrote:
> > > > davide wrote:
> > > > > Prazek wrote:
> > > > > > majnemer wrote:
> > > > > > > selectany should work on targets other than "x86", "x86_64", 
> > > > > > > "arm", "thumb", etc. I think it is only necessary to require that 
> > > > > > > it be a COFF or ELF target.
> > > > > > Should we allow other OSes than Win32 and Linux?
> > > > > I guess everything ELF should be allowed.
> > > > Why not use weak_odr / linkonce_odr on MachO? Microsoft builds Office 
> > > > for Mac and I suspect they use `__declspec(selectany)`.
> > > I think this is what would happen right now. The question is - should we 
> > > warn about using declspec on macho? Beause not using comdat looks like 
> > > "not supporting" it, but I am not sure about it.
> > I'm pretty sure weak_odr / linkonce_odr with ld64 on macho are the same as 
> > having a comdat. LLVM didn't always have comdats, but it's supported inline 
> > functions for a very long time. We should support selectany there.
> I agree with @rnk here.
So does it actually mean that we don't have any requirements for 
declscpec(any)? It can run on every OS and target


https://reviews.llvm.org/D33852



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


[PATCH] D28954: [analyzer] Add support for symbolic float expressions

2017-07-19 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

As an aside, I think it'd be good to land https://reviews.llvm.org/D28954 and 
https://reviews.llvm.org/D28955 first, since they affect accuracy and precision 
of various analyzer parts that this depends on.

> Here are some examples that should all be UNKNOWN (right?) but are not in the 
> current patch, assuming a and b hold unconstrained symbols of floating-point 
> type:

Yeah, those should definitely be fixed. In general, I tried to avoid performing 
simplifications on anything not of floating-point type, particularly in 
SimpleSValBuilder, but there are probably cases that I've missed.

In your example `clang_analyzer_eval(a < 4.0 || a >= 4.0)` (and likewise for 
the rest), the following is happening:

1. At ExprEngineC.cpp:VisitLogicalExpr(), we hit this logical expression for 
the first time, the introspection fails, and we generate the SVal `(((double) 
(reg_$0)) >= 4.0E+0) != 0` that is bound to `a < 4.0 || a >= 4.0`.
2. The next time around, the introspection succeeds, and we generate the SVal 
`1 S32b` that is bound to `a < 4.0 || a >= 4.0`.
3. Now, when we hit ExprInspectionChecker.cpp:getArgumentValueString(), we 
retrieve the SVal `1 S32b`, and attempt to assert it.
4. Then, we hit SimpleConstraintManager.cpp:assumeAux(), and fall into the 
`nonloc::ConcreteIntKind` case. When `Assumption` is `true`, we are fine and 
return the original `State`, but then when `Assumption` is `false`, we return 
`nullptr`.
5. Back in ExprInspectionChecker.cpp:getArgumentValueString(), we see `StTrue 
!= nullptr` and `StFalse == nullptr`, and we print `TRUE` instead of `UNKNOWN`.

I'm not familiar with `VisitLogicalExpr()` and why integer constants are being 
bound to the logical expressions. Wouldn't we simply want to assume that the 
logical expression, when expressed as a symbolic constraint, is either 
true/false in each respective child state?




Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:150
 
+def FloatingPointMathChecker : Checker<"FPMath">,
+  HelpText<"Check for domain errors in floating-point math functions">,

dcoughlin wrote:
> It is fine to have this in alpha now. What package to do envision this in 
> after it is ready? Is this something that should always be on, or should be 
> opted into on a per-project basis?
This checker is a bit of a toy, in that (last I checked) Clang doesn't support 
the floating-point environment, which is typically used to install global 
floating-point exception handlers (for e.g. NaN, etc). As a result, there are 
probably going to lots of false-positives on real codebases.

Additionally, it requires the z3 solver, which probably isn't being built by 
default in most Linux distributions (and I doubt we're at the point of asking 
package maintainers to add a dependency for clang on libz3, even for those that 
do build that package).

So I think it should definitely be optional.



Comment at: lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp:80
+DefinedOrUnknownSVal isPInf = SVB.evalEQ(state, V, SPInf);
+if (isPInf.isConstant(1)) {
+  C.addTransition(state->BindExpr(CE, LCtx, isPInf));

dcoughlin wrote:
> Is there a reason you're not using assumeDual() here?
I'm not sure how `assumeDual` helps here?  The explicit checks `isPInf` and 
`isNInf` implement the short-circuit effect of logical or, whereas omitting 
them and binding directly to `isInf` miss the short-circuit effect.



Comment at: lib/StaticAnalyzer/Core/BasicValueFactory.cpp:118
+const llvm::APFloat ::getValue(const llvm::APFloat& X) {
+  llvm::FoldingSetNodeID ID;
+  void *InsertPos;

dcoughlin wrote:
> This logic is nearly identical to that in getValue(const llvm::APSInt& X). 
> Can the logic be factored out in some sort of zero-costish abstraction? 
> (Perhaps templatized over the value type?)
The tricky part is that there are associate class member variables for each 
function (`APSIntSet` and `APFloatSet`). I can factor out `getValue` to a 
template, but then I'd need to introduce a templated helper function with two 
specializations to retrieve the class member variable for the input template 
type. I'm not sure if that'd be zero-cost?



Comment at: lib/StaticAnalyzer/Core/BasicValueFactory.cpp:331
+case BO_Div:
+  // Divide by zero
+  if (V1.isFinite() && V2.isInfinity())

dcoughlin wrote:
> Is this comment correct? Is this really a divide by zero?
> 
> I'm also a bit surprised APFloat::divide() doesn't handle this case.
I don't recall why I wrote this...



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:1092
 
+  assert(!V.isFloat());
+

dcoughlin wrote:
> I'm wondering whether we should rename this method to "getKnownIntValue()" 
> and then just return nullptr here. What are the merits of trapping vs. 
> returning nullptr here? 
The trapping should be for 

r308574 - [NFC] Update local variable names to upper-case as per LLVM Coding Standards.

2017-07-19 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Wed Jul 19 18:10:56 2017
New Revision: 308574

URL: http://llvm.org/viewvc/llvm-project?rev=308574=rev
Log:
[NFC] Update local variable names to upper-case as per LLVM Coding Standards.

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

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=308574=308573=308574=diff
==
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Wed Jul 19 18:10:56 2017
@@ -178,28 +178,28 @@ void TokenLexer::ExpandFunctionArguments
   // we install the newly expanded sequence as the new 'Tokens' list.
   bool MadeChange = false;
 
-  for (unsigned i = 0, e = NumTokens; i != e; ++i) {
+  for (unsigned I = 0, E = NumTokens; I != E; ++I) {
 // If we found the stringify operator, get the argument stringified.  The
 // preprocessor already verified that the following token is a macro name
 // when the #define was parsed.
-const Token  = Tokens[i];
+const Token  = Tokens[I];
 // We don't want a space for the next token after a paste
 // operator.  In valid code, the token will get smooshed onto the
 // preceding one anyway. In assembler-with-cpp mode, invalid
 // pastes are allowed through: in this case, we do not want the
 // extra whitespace to be added.  For example, we want ". ## foo"
 // -> ".foo" not ". foo".
-if (i != 0 && !Tokens[i-1].is(tok::hashhash) && CurTok.hasLeadingSpace())
+if (I != 0 && !Tokens[I-1].is(tok::hashhash) && CurTok.hasLeadingSpace())
   NextTokGetsSpace = true;
 
 if (CurTok.isOneOf(tok::hash, tok::hashat)) {
-  int ArgNo = Macro->getParameterNum(Tokens[i+1].getIdentifierInfo());
+  int ArgNo = Macro->getParameterNum(Tokens[I+1].getIdentifierInfo());
   assert(ArgNo != -1 && "Token following # is not an argument?");
 
   SourceLocation ExpansionLocStart =
   getExpansionLocForMacroDefLoc(CurTok.getLocation());
   SourceLocation ExpansionLocEnd =
-  getExpansionLocForMacroDefLoc(Tokens[i+1].getLocation());
+  getExpansionLocForMacroDefLoc(Tokens[I+1].getLocation());
 
   Token Res;
   if (CurTok.is(tok::hash))  // Stringify
@@ -222,7 +222,7 @@ void TokenLexer::ExpandFunctionArguments
 
   ResultToks.push_back(Res);
   MadeChange = true;
-  ++i;  // Skip arg name.
+  ++I;  // Skip arg name.
   NextTokGetsSpace = false;
   continue;
 }
@@ -230,8 +230,8 @@ void TokenLexer::ExpandFunctionArguments
 // Find out if there is a paste (##) operator before or after the token.
 bool NonEmptyPasteBefore =
   !ResultToks.empty() && ResultToks.back().is(tok::hashhash);
-bool PasteBefore = i != 0 && Tokens[i-1].is(tok::hashhash);
-bool PasteAfter = i+1 != e && Tokens[i+1].is(tok::hashhash);
+bool PasteBefore = I != 0 && Tokens[I-1].is(tok::hashhash);
+bool PasteAfter = I+1 != E && Tokens[I+1].is(tok::hashhash);
 assert(!NonEmptyPasteBefore || PasteBefore);
 
 // Otherwise, if this is not an argument token, just add the token to the
@@ -374,7 +374,7 @@ void TokenLexer::ExpandFunctionArguments
 if (PasteAfter) {
   // Discard the argument token and skip (don't copy to the expansion
   // buffer) the paste operator after it.
-  ++i;
+  ++I;
   continue;
 }
 


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


[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo

2017-07-19 Thread MinSeong Kim via Phabricator via cfe-commits
minseong.kim added a comment.

Thanks @jordan_rose @modocache  @hintonda for your time and efforts. 
This patch does regenerate the version control info correctly (SVNVersion.inc) 
every time I re-make clang. Probably I am missing something here.
Could you please be more specific and share your idea about "adding all of 
these as dependencies" to force reconfigure revision info whenever new commits 
added. 
I will gladly change this patch accordingly.


https://reviews.llvm.org/D35533



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


r308561 - [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-19 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Wed Jul 19 17:05:25 2017
New Revision: 308561

URL: http://llvm.org/viewvc/llvm-project?rev=308561=rev
Log:
[StaticAnalyzer] Completely unrolling specific loops with known bound option 

Missing files added to rL308558.


Added:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
cfe/trunk/test/Analysis/loop-unrolling.cpp

Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h?rev=308561=auto
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
(added)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
Wed Jul 19 17:05:25 2017
@@ -0,0 +1,33 @@
+//===--- LoopUnrolling.h - Unroll loops -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// This header contains the declarations of functions which are used to decide
+/// which loops should be completely unrolled and mark their corresponding
+/// CFGBlocks.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H
+
+#include "clang/Analysis/CFG.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
+
+namespace clang {
+namespace ento {
+ProgramStateRef markLoopAsUnrolled(const Stmt *Term, ProgramStateRef State,
+   CFGStmtMap *StmtToBlockMap);
+bool isUnrolledLoopBlock(const CFGBlock *Block, ExplodedNode *Prev);
+bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext );
+
+} // end namespace ento
+} // end namespace clang
+
+#endif

Added: cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp?rev=308561=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp Wed Jul 19 17:05:25 2017
@@ -0,0 +1,203 @@
+//===--- LoopUnrolling.cpp - Unroll loops ---*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// This file contains functions which are used to decide if a loop worth to be
+/// unrolled. Moreover contains function which mark the CFGBlocks which belongs
+/// to the unrolled loop and store them in ProgramState.
+///
+//===--===//
+
+#include "clang/Analysis/CFGStmtMap.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/AST/ParentMap.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h"
+#include "llvm/ADT/Statistic.h"
+
+using namespace clang;
+using namespace ento;
+using namespace clang::ast_matchers;
+
+#define DEBUG_TYPE "LoopUnrolling"
+
+STATISTIC(NumTimesLoopUnrolled,
+  "The # of times a loop has got completely unrolled");
+
+REGISTER_MAP_WITH_PROGRAMSTATE(UnrolledLoops, const Stmt *, const CFGStmtMap *)
+
+namespace clang {
+namespace ento {
+
+static bool isLoopStmt(const Stmt *S) {
+  return S && (isa(S) || isa(S) || isa(S));
+}
+
+static internal::Matcher simpleCondition(StringRef BindName) {
+  return binaryOperator(
+  anyOf(hasOperatorName("<"), hasOperatorName(">"), hasOperatorName("<="),
+hasOperatorName(">="), hasOperatorName("!=")),
+  hasEitherOperand(ignoringParenImpCasts(
+  declRefExpr(to(varDecl(hasType(isInteger())).bind(BindName),
+  hasEitherOperand(ignoringParenImpCasts(integerLiteral(;
+}
+
+static internal::Matcher changeIntBoundNode(StringRef NodeName) {
+  return anyOf(hasDescendant(unaryOperator(
+   anyOf(hasOperatorName("--"), hasOperatorName("++")),
+   hasUnaryOperand(ignoringParenImpCasts(
+   declRefExpr(to(varDecl(equalsBoundNode(NodeName,
+   hasDescendant(binaryOperator(
+ 

r308558 - This feature allows the analyzer to consider loops to completely unroll. New

2017-07-19 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Wed Jul 19 16:50:00 2017
New Revision: 308558

URL: http://llvm.org/viewvc/llvm-project?rev=308558=rev
Log:
This feature allows the analyzer to consider loops to completely unroll. New
requirements/rules (for unrolling) can be added easily via ASTMatchers.

The current implementation is hidden behind a flag.

Right now the blocks which belong to an unrolled loop are marked by the 
LoopVisitor which adds them to the ProgramState. Then whenever we encounter a
CFGBlock in the processCFGBlockEntrance which is marked then we skip its
investigating. That means, it won't be considered to be visited more than the
maximal bound for visiting since it won't be checked.

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


Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=308558=308557=308558=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Wed Jul 19 
16:50:00 2017
@@ -275,6 +275,9 @@ private:
   /// \sa shouldWidenLoops
   Optional WidenLoops;
 
+  /// \sa shouldUnrollLoops
+  Optional UnrollLoops;
+
   /// \sa shouldDisplayNotesAsEvents
   Optional DisplayNotesAsEvents;
 
@@ -560,7 +563,11 @@ public:
   /// This is controlled by the 'widen-loops' config option.
   bool shouldWidenLoops();
 
-  /// Returns true if the bug reporter should transparently treat extra note
+  /// Returns true if the analysis should try to unroll loops with known 
bounds.
+  /// This is controlled by the 'unroll-loops' config option.
+  bool shouldUnrollLoops();
+
+/// Returns true if the bug reporter should transparently treat extra note
   /// diagnostic pieces as event diagnostic pieces. Useful when the diagnostic
   /// consumer doesn't support the extra note pieces.
   ///

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp?rev=308558=308557=308558=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp Wed Jul 19 
16:50:00 2017
@@ -272,6 +272,7 @@ void ExprInspectionChecker::checkEndAnal
 
 reportBug(llvm::to_string(NumTimesReached), BR, N);
   }
+  ReachedStats.clear();
 }
 
 void ExprInspectionChecker::analyzerCrash(const CallExpr *CE,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=308558=308557=308558=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Wed Jul 19 16:50:00 
2017
@@ -375,6 +375,12 @@ bool AnalyzerOptions::shouldWidenLoops()
   return WidenLoops.getValue();
 }
 
+bool AnalyzerOptions::shouldUnrollLoops() {
+  if (!UnrollLoops.hasValue())
+UnrollLoops = getBooleanOption("unroll-loops", /*Default=*/false);
+  return UnrollLoops.getValue();
+}
+
 bool AnalyzerOptions::shouldDisplayNotesAsEvents() {
   if (!DisplayNotesAsEvents.hasValue())
 DisplayNotesAsEvents =

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt?rev=308558=308557=308558=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt Wed Jul 19 16:50:00 2017
@@ -35,6 +35,7 @@ add_clang_library(clangStaticAnalyzerCor
   ExprEngineObjC.cpp
   FunctionSummary.cpp
   HTMLDiagnostics.cpp
+  LoopUnrolling.cpp
   LoopWidening.cpp
   MemRegion.cpp
   PathDiagnostic.cpp
@@ -54,6 +55,7 @@ add_clang_library(clangStaticAnalyzerCor
 
   LINK_LIBS
   clangAST
+  clangASTMatchers
   clangAnalysis
   clangBasic
   clangLex

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=308558=308557=308558=diff
==
--- 

[PATCH] D35652: [clang] Fix handling of "%zd" format specifier in scanf

2017-07-19 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: test/Sema/format-strings-fixit-ssize_t.c:4
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c99 -fsyntax-only 
-pedantic -Wall -Werror %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c99 -E -o - %t | 
FileCheck %s
 

c99 is necessary for "zd"



Comment at: test/Sema/format-strings-scanf.c:1
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s
 

c11 is necessary for _Generic below.
I have not found a more reliable way to define ssize_t
which doesn't require a large number of #ifdef ...


Repository:
  rL LLVM

https://reviews.llvm.org/D35652



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


[PATCH] D35652: [clang] Fix handling of "%zd" format specifier in scanf

2017-07-19 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.

This is a follow-up for https://reviews.llvm.org/D35427
ScanfFormatString.cpp has the same issue (incorrect handling of
the specifiers for ssize_t) and this diff fixes it and adds tests.

Test plan: make check-all


Repository:
  rL LLVM

https://reviews.llvm.org/D35652

Files:
  lib/Analysis/ScanfFormatString.cpp
  test/Sema/format-strings-fixit-ssize_t.c
  test/Sema/format-strings-scanf.c

Index: test/Sema/format-strings-scanf.c
===
--- test/Sema/format-strings-scanf.c
+++ test/Sema/format-strings-scanf.c
@@ -1,10 +1,18 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s
 
 // Test that -Wformat=0 works:
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wformat=0 %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 %s
 
 #include 
-typedef __typeof(sizeof(int)) size_t;
+typedef __SIZE_TYPE__ size_t;
+#define __SSIZE_TYPE__ \
+  __typeof__(_Generic((__SIZE_TYPE__)0,\
+  unsigned long long int : (long long int)0,   \
+  unsigned long int : (long int)0, \
+  unsigned int : (int)0,   \
+  unsigned short : (short)0,   \
+  unsigned char : (signed char)0))
+typedef __SSIZE_TYPE__ ssize_t; 
 typedef struct _FILE FILE;
 typedef __WCHAR_TYPE__ wchar_t;
 
@@ -172,6 +180,23 @@
   scanf("%d", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}}
 }
 
+void test_size_types() {
+  size_t s = 0;
+  scanf("%zu", ); // No warning.
+
+  double d1 = 0.;
+  scanf("%zu", ); // expected-warning-re{{format specifies type 'size_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+
+  ssize_t ss = 0;
+  scanf("%zd", ); // No warning.
+
+  double d2 = 0.;
+  scanf("%zd", ); // expected-warning-re{{format specifies type 'ssize_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+
+  double d3 = 0.;
+  scanf("%zn", ); // expected-warning-re{{format specifies type 'ssize_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+}
+
 void check_conditional_literal(char *s, int *i) {
   scanf(0 ? "%s" : "%d", i); // no warning
   scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char *'}}
Index: test/Sema/format-strings-fixit-ssize_t.c
===
--- test/Sema/format-strings-fixit-ssize_t.c
+++ test/Sema/format-strings-fixit-ssize_t.c
@@ -1,18 +1,22 @@
 // RUN: cp %s %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -pedantic -Wall -fixit %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -Wall -Werror %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -E -o - %t | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c99 -pedantic -Wall -fixit %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c99 -fsyntax-only -pedantic -Wall -Werror %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c99 -E -o - %t | FileCheck %s
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
warnings will be fixed by -fixit, and the resulting file should
compile cleanly with -Werror -pedantic. */
 
 int printf(char const *, ...);
+int scanf(const char *, ...);
 
 void test() {
   typedef signed long int ssize_t;
   printf("%f", (ssize_t) 42);
+  ssize_t s;
+  scanf("%f",  );
 }
 
 // CHECK: printf("%zd", (ssize_t) 42);
+// CHECK: scanf("%zd", )
Index: lib/Analysis/ScanfFormatString.cpp
===
--- lib/Analysis/ScanfFormatString.cpp
+++ lib/Analysis/ScanfFormatString.cpp
@@ -251,8 +251,7 @@
 case LengthModifier::AsIntMax:
   return ArgType::PtrTo(ArgType(Ctx.getIntMaxType(), "intmax_t"));
 case LengthModifier::AsSizeT:
-  // FIXME: ssize_t.
-  return ArgType();
+  return ArgType::PtrTo(ArgType(Ctx.getSignedSizeType(), "ssize_t"));
 case LengthModifier::AsPtrDiff:
   return ArgType::PtrTo(ArgType(Ctx.getPointerDiffType(), "ptrdiff_t"));
 case LengthModifier::AsLongDouble:
@@ -386,7 +385,7 @@
 case LengthModifier::AsIntMax:
   return ArgType::PtrTo(ArgType(Ctx.getIntMaxType(), "intmax_t"));
 case LengthModifier::AsSizeT:
-  return ArgType(); // FIXME: ssize_t
+  return ArgType::PtrTo(ArgType(Ctx.getSignedSizeType(), "ssize_t"));
 case LengthModifier::AsPtrDiff:
   return ArgType::PtrTo(ArgType(Ctx.getPointerDiffType(), "ptrdiff_t"));
 case 

r308546 - [X86] Put avx512vpopcntdq in the right spot in the validateCpuSupports string switch.

2017-07-19 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jul 19 15:58:58 2017
New Revision: 308546

URL: http://llvm.org/viewvc/llvm-project?rev=308546=rev
Log:
[X86] Put avx512vpopcntdq in the right spot in the validateCpuSupports string 
switch.

The validateCpuSupports switch is in the order of the enum defined in 
CGBuiltin.cpp and libgcc/compiler-rt.

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

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=308546=308545=308546=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul 19 15:58:58 2017
@@ -4414,11 +4414,11 @@ bool X86TargetInfo::validateCpuSupports(
   .Case("avx512bw", true)
   .Case("avx512dq", true)
   .Case("avx512cd", true)
-  .Case("avx512vpopcntdq", true)
   .Case("avx512er", true)
   .Case("avx512pf", true)
   .Case("avx512vbmi", true)
   .Case("avx512ifma", true)
+  .Case("avx512vpopcntdq", true)
   .Default(false);
 }
 


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


[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-19 Thread Sumanth Gundapaneni via Phabricator via cfe-commits
sgundapa added a comment.

> Moreover, why can't this determining factor be built into the compiler so the 
> user doesn't even have to bother. That would be a more ideal user experience.

Here is a use case : For the code that stays in TCM, the customer doesn't want 
the data that the code refers to be outside of TCM. As kparzysz mentioned, the 
loads cause a huge latency and is not intended. Disabling table generation is 
the right thing to do here. For code that stays in regular memory,  generating 
tables is far more efficient than a bunch of if-elses.

> As an alternative solution, why not just disable the transformation in 
> SimplifyCFG when -fno-jump-tables is used? The underlying issue seems to be 
> the same (i.e., you want to avoid generating more relocations) and AFAICT 
> that's what -fno-jump-tables is all about.. (Admittedly, I don't know the 
> full history of -fno-jump-tables, so others might disagree with this 
> suggestion.)

Jump tables are not supported by all targets but lookup tables are. Jump tables 
need indirect addressing mode where as a lookup table is just an array of 
values.

This is from "man gcc"
-fno-jump-tables

  Do not use jump tables for switch statements even where it would be more 
efficient than other code generation strategies.  This option is of use in 
conjunction with -fpic or -fPIC for building code that forms part of a
  dynamic linker and cannot reference the address of a jump table.  On some 
targets, jump tables do not require a GOT and this option is not needed.

This will throw some background on why this option was introduced.


https://reviews.llvm.org/D35578



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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:2356
+  X86_32TargetCodeGenInfo::setTargetAttributes(D, GV, CGM, IsForDefinition);
 
   addStackProbeSizeTargetAttribute(D, GV, CGM);

No, sorry, I must not have been clear.  We still need a check here, but we 
should do it after the first call.

The idea is that we want to give the generic x86-32 target an opportunity to 
add target attributes, whether this is a declaration or a definition.  , Having 
done that, we come back to this function to add any Windows-specific target 
attributes.  Since all the Windows-specific attributes are definition-only, we 
can just exit if it's only for a declaration.



Comment at: lib/CodeGen/TargetInfo.cpp:5534
+ForDefinition_t IsForDefinition) const {
+  ARMTargetCodeGenInfo::setTargetAttributes(D, GV, CGM, IsForDefinition);
   addStackProbeSizeTargetAttribute(D, GV, CGM);

Same thing here: please add a check, but only after you've given the generic 
ARM target an opportunity to set attributes in all cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479



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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:1336
+if code compiled using ``-mlong-calls`` switch, it forces compiler to use
+the ``jal`` instruction to call the function.
+  }];

sdardis wrote:
> rjmccall wrote:
> > sdardis wrote:
> > > rjmccall wrote:
> > > > I suggest the following wording:
> > > > 
> > > > Clang supports the ``__attribute__((long_call))``, 
> > > > ``__attribute__((far))``, and
> > > > ``__attribute__((near))`` attributes on MIPS targets.  These attributes 
> > > > may only be
> > > > added to function declarations and change the code generated by the 
> > > > compiler when
> > > > directly calling the function.  The ``near`` attribute allows calls to 
> > > > the function to
> > > > be made using the ``jal`` instruction, which requires the function to 
> > > > be defined in the
> > > > same 256MB segment as the caller.  The ``long_call`` and ``far`` 
> > > > attributes are
> > > > synonyms and require the use of a different call sequence that works 
> > > > regardless of
> > > > the distance between the functions.
> > > > 
> > > > These attributes take priority over command line switches such as 
> > > > ``-mlong-calls``.
> > > > requires the function to be defined
> > > 
> > > I'd change the "defined" to be "located".
> > > 
> > > > in the same 256MB segment as the caller.
> > > 
> > > I'd change this to: "in the same naturally aligned 256MB segment as the 
> > > caller."
> > > 
> > > This also needs a note saying that it has no effect for code compiled 
> > > with -fpic.
> > Oh, yes, if these statements are true then it's absolutely important to 
> > include them.  I was going off of the raw ISA specification, since jal just 
> > takes a relative offset, but if the toolchain has more specific 
> > requirements then those are what should be documented.
> > 
> > This whole feature is strange to me; do MIPS linkers just never introduce 
> > things like branch islands and lazy-binding functions?
> > since jal just takes a relative offset,
> 
> jal doesn't take an offset, the instruction takes an 26-bit immediate  
> (called the instruction index) shifts it left 2 bits and combines it with the 
> remaining upper bits of the address of the instruction in the delay slot of 
> jal to form the new $pc--so it's possible to jump from the bottom of a 256MB 
> segment to the top.
> 
> (My apologies for the long answer here, jal is one of the odder control 
> transfer instruction for MIPS.)
> 
> > This whole feature is strange to me; do MIPS linkers just never introduce 
> > things like branch islands and lazy-binding functions?
> 
> This feature is orthogonal to lazy-binding functions. The usage of 
> 'long-call' and 'near' is to support bare-metal / static relocation model 
> environments where the caller and callee might be in different memory 
> segments (e.g. KSEG0 and KSEG1) or have a custom memory layout for their 
> program's sections.
> 
> To the best of my knowledge, the GNU linker for MIPS only inserts stub 
> functions / branch islands when compiling static code that calls PIC code. 
Well, that's what I get for skimming the first search hit instead of taking the 
time to read the real documentation.  Thank you for the correction.

Oh, and of course that's why you can't really use JAL in PIC: the linker could 
statically resolve instruction indexes within the current image, but only if 
the image gets loaded at a base address that's a multiple of 256MB!  That's 
obviously too coarse-grained to be workable.

What an unfortunate instruction design.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479



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


[PATCH] D35546: [AArch64] Produce correct defaultlib directives for windows in MSVC style

2017-07-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D35546



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


[PATCH] D35573: Improve SEMA for attribute-target

2017-07-19 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308539: Improve SEMA for attribute-target (authored by 
erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D35573?vs=107134=107398#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35573

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/attr-target.c

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -3271,7 +3271,7 @@
   unsigned ArgNum, StringRef ,
   SourceLocation *ArgLocation = nullptr);
   bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
-  void checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
+  bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
   bool checkMSInheritanceAttrOnDefinition(
   CXXRecordDecl *RD, SourceRange Range, bool BestCase,
   MSInheritanceAttr::Spelling SemanticSpelling);
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2387,8 +2387,9 @@
 def err_attribute_requires_opencl_version : Error<
   "%0 attribute requires OpenCL version %1%select{| or above}2">;
 def warn_unsupported_target_attribute
-: Warning<"Ignoring unsupported '%0' in the target attribute string">,
-InGroup;
+: Warning<"ignoring %select{unsupported|duplicate}0"
+  "%select{| architecture}1 '%2' in the target attribute string">,
+  InGroup;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported for this target">;
 // The err_*_attribute_argument_not_int are separate because they're used by
Index: cfe/trunk/test/Sema/attr-target.c
===
--- cfe/trunk/test/Sema/attr-target.c
+++ cfe/trunk/test/Sema/attr-target.c
@@ -2,7 +2,13 @@
 
 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("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 target attribute string}}
+
 
 
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -2993,22 +2993,43 @@
 D->addAttr(NewAttr);
 }
 
-// Check for things we'd like to warn about, no errors or validation for now.
-// TODO: Validation should use a backend target library that specifies
-// the allowable subtarget features and cpus. We could use something like a
-// TargetCodeGenInfo hook here to do validation.
-void Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
+// Check for things we'd like to warn about. Multiversioning issues are
+// handled later in the process, once we know how many exist.
+bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
+  enum FirstParam { Unsupported, Duplicate };
+  enum SecondParam { None, Architecture };
   for (auto Str : {"tune=", "fpmath="})
 if (AttrStr.find(Str) != StringRef::npos)
-  Diag(LiteralLoc, diag::warn_unsupported_target_attribute) << Str;
+  return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+ << Unsupported << None << Str;
+
+  

r308539 - Improve SEMA for attribute-target

2017-07-19 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jul 19 15:06:33 2017
New Revision: 308539

URL: http://llvm.org/viewvc/llvm-project?rev=308539=rev
Log:
Improve SEMA for attribute-target

Add more diagnosis for the non-multiversioning case.

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


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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=308539=308538=308539=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 19 15:06:33 
2017
@@ -2387,8 +2387,9 @@ 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 unsupported '%0' in the target attribute string">,
-InGroup;
+: Warning<"ignoring %select{unsupported|duplicate}0"
+  "%select{| architecture}1 '%2' in the target attribute string">,
+  InGroup;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported for this target">;
 // The err_*_attribute_argument_not_int are separate because they're used by

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=308539=308538=308539=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jul 19 15:06:33 2017
@@ -3271,7 +3271,7 @@ public:
   unsigned ArgNum, StringRef ,
   SourceLocation *ArgLocation = nullptr);
   bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
-  void checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
+  bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
   bool checkMSInheritanceAttrOnDefinition(
   CXXRecordDecl *RD, SourceRange Range, bool BestCase,
   MSInheritanceAttr::Spelling SemanticSpelling);

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=308539=308538=308539=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jul 19 15:06:33 2017
@@ -2993,22 +2993,43 @@ static void handleSectionAttr(Sema , D
 D->addAttr(NewAttr);
 }
 
-// Check for things we'd like to warn about, no errors or validation for now.
-// TODO: Validation should use a backend target library that specifies
-// the allowable subtarget features and cpus. We could use something like a
-// TargetCodeGenInfo hook here to do validation.
-void Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
+// Check for things we'd like to warn about. Multiversioning issues are
+// handled later in the process, once we know how many exist.
+bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
+  enum FirstParam { Unsupported, Duplicate };
+  enum SecondParam { None, Architecture };
   for (auto Str : {"tune=", "fpmath="})
 if (AttrStr.find(Str) != StringRef::npos)
-  Diag(LiteralLoc, diag::warn_unsupported_target_attribute) << Str;
+  return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+ << Unsupported << None << Str;
+
+  TargetAttr::ParsedTargetAttr ParsedAttrs = TargetAttr::parse(AttrStr);
+
+  if (!ParsedAttrs.Architecture.empty() &&
+  !Context.getTargetInfo().isValidCPUName(ParsedAttrs.Architecture))
+return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+   << Unsupported << Architecture << ParsedAttrs.Architecture;
+
+  if (ParsedAttrs.DuplicateArchitecture)
+return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+   << Duplicate << None << "arch=";
+
+  for (const auto  : ParsedAttrs.Features) {
+auto CurFeature = StringRef(Feature).drop_front(); // remove + or -.
+if (!Context.getTargetInfo().isValidFeatureName(CurFeature))
+  return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+ << Unsupported << None << CurFeature;
+  }
+
+  return true;
 }
 
 static void handleTargetAttr(Sema , Decl *D, const AttributeList ) {
   StringRef Str;
   SourceLocation LiteralLoc;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, ))
+  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, ) ||
+  !S.checkTargetAttr(LiteralLoc, Str))
 return;
-  S.checkTargetAttr(LiteralLoc, Str);
   unsigned Index = 

[libcxx] r308534 - [libcxx] [test] Fix Clang -Wunused-local-typedef warnings.

2017-07-19 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Jul 19 15:02:29 2017
New Revision: 308534

URL: http://llvm.org/viewvc/llvm-project?rev=308534=rev
Log:
[libcxx] [test] Fix Clang -Wunused-local-typedef warnings.

Fix D34536.

Modified:

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp

Modified: 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp?rev=308534=308533=308534=diff
==
--- 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp
 Wed Jul 19 15:02:29 2017
@@ -34,7 +34,6 @@ test()
 
 void test_edges()
 {
-typedef std::complex C;
 const double pi = std::atan2(+0., -0.);
 const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
 for (unsigned i = 0; i < N; ++i)

Modified: 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp?rev=308534=308533=308534=diff
==
--- 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
 Wed Jul 19 15:02:29 2017
@@ -34,7 +34,6 @@ test()
 
 void test_edges()
 {
-typedef std::complex C;
 const double pi = std::atan2(+0., -0.);
 const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
 for (unsigned i = 0; i < N; ++i)

Modified: 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp?rev=308534=308533=308534=diff
==
--- 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp
 Wed Jul 19 15:02:29 2017
@@ -34,7 +34,6 @@ test()
 
 void test_edges()
 {
-typedef std::complex C;
 const double pi = std::atan2(+0., -0.);
 const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
 for (unsigned i = 0; i < N; ++i)

Modified: 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp?rev=308534=308533=308534=diff
==
--- 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
 Wed Jul 19 15:02:29 2017
@@ -34,7 +34,6 @@ test()
 
 void test_edges()
 {
-typedef std::complex C;
 const double pi = std::atan2(+0., -0.);
 const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
 for (unsigned i = 0; i < N; ++i)

Modified: 
libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
URL: 

[libcxx] r308535 - [libcxx] [test] Update msvc_stdlib_force_include.hpp.

2017-07-19 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Jul 19 15:02:33 2017
New Revision: 308535

URL: http://llvm.org/viewvc/llvm-project?rev=308535=rev
Log:
[libcxx] [test] Update msvc_stdlib_force_include.hpp.

MSVC's STL is replacing _HAS_FUNCTION_ASSIGN with 
_HAS_FUNCTION_ALLOCATOR_SUPPORT,
and is adding _HAS_UNEXPECTED.

Modified:
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp

Modified: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=308535=308534=308535=diff
==
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (original)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Wed Jul 19 15:02:33 
2017
@@ -70,9 +70,10 @@ const AssertionDialogAvoider assertion_d
 #define _ENABLE_ATOMIC_ALIGNMENT_FIX
 
 // Enable features that /std:c++latest removes by default.
-#define _HAS_AUTO_PTR_ETC  1
-#define _HAS_FUNCTION_ASSIGN   1
-#define _HAS_OLD_IOSTREAMS_MEMBERS 1
+#define _HAS_AUTO_PTR_ETC   1
+#define _HAS_FUNCTION_ALLOCATOR_SUPPORT 1
+#define _HAS_OLD_IOSTREAMS_MEMBERS  1
+#define _HAS_UNEXPECTED 1
 
 // Silence warnings about raw pointers and other unchecked iterators.
 #define _SCL_SECURE_NO_WARNINGS


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


[libcxx] r308533 - [libcxx] [test] Fix MSVC warning C4067 "unexpected tokens following preprocessor directive - expected a newline".

2017-07-19 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Jul 19 15:02:25 2017
New Revision: 308533

URL: http://llvm.org/viewvc/llvm-project?rev=308533=rev
Log:
[libcxx] [test] Fix MSVC warning C4067 "unexpected tokens following 
preprocessor directive - expected a newline".

Also fixes Clang/LLVM 4.0 (for Windows) error "function-like macro 
'TEST_GLIBC_PREREQ' is not defined".

Fixes D34535.

Modified:

libcxx/trunk/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp?rev=308533=308532=308533=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
 Wed Jul 19 15:02:25 2017
@@ -117,7 +117,13 @@ int main()
 // GLIBC <= 2.23 uses currency_symbol=""
 // GLIBC >= 2.24 uses currency_symbol=""
 // See also: 
http://www.fileformat.info/info/unicode/char/20bd/index.htm
-#if defined(TEST_GLIBC_PREREQ) && TEST_GLIBC_PREREQ(2, 24)
+#if defined(TEST_GLIBC_PREREQ)
+#if TEST_GLIBC_PREREQ(2, 24)
+#define TEST_GLIBC_2_24_CURRENCY_SYMBOL
+#endif
+#endif
+
+#if defined(TEST_GLIBC_2_24_CURRENCY_SYMBOL)
 assert(f.curr_symbol() == " \u20BD");
 #else
 assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
@@ -129,7 +135,7 @@ int main()
 }
 {
 Fwf f(LOCALE_ru_RU_UTF_8, 1);
-#if defined(TEST_GLIBC_PREREQ) && TEST_GLIBC_PREREQ(2, 24)
+#if defined(TEST_GLIBC_2_24_CURRENCY_SYMBOL)
 assert(f.curr_symbol() == L" \u20BD");
 #else
 assert(f.curr_symbol() == L" \x440\x443\x431");


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


[libcxx] r308532 - [libcxx] [test] Fix MSVC warning C4242 "conversion from 'int' to 'const char', possible loss of data".

2017-07-19 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Jul 19 15:02:22 2017
New Revision: 308532

URL: http://llvm.org/viewvc/llvm-project?rev=308532=rev
Log:
[libcxx] [test] Fix MSVC warning C4242 "conversion from 'int' to 'const char', 
possible loss of data".

Fixes D34534.

Modified:

libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp?rev=308532=308531=308532=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp 
Wed Jul 19 15:02:22 2017
@@ -40,7 +40,7 @@ protected:
 if (__c != base::traits_type::eof())
 {
 int n = str_.size();
-str_.push_back(__c);
+str_.push_back(static_cast(__c));
 str_.resize(str_.capacity());
 base::setp(const_cast(str_.data()),
const_cast(str_.data() + str_.size()));

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp?rev=308532=308531=308532=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
 Wed Jul 19 15:02:22 2017
@@ -46,7 +46,7 @@ protected:
 if (__c != base::traits_type::eof())
 {
 int n = str_.size();
-str_.push_back(__c);
+str_.push_back(static_cast(__c));
 str_.resize(str_.capacity());
 base::setp(const_cast(str_.data()),
const_cast(str_.data() + str_.size()));


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


[PATCH] D35338: Add the -fdestroy-globals flag

2017-07-19 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a subscriber: bruno.
vsk added a comment.

That seems like a nice win and I like the convenience of this approach. That 
said I've just remembered that there's a thread on cfe-dev about this:
[RFC] Suppress C++ static destructor registration

I don't think a consensus was reached. From what I gather, some people think 
that the convenience of this flag makes it worth adding to clang, while others 
think that adding a non-standard compiler-specific flag is asking for trouble.

I suspect that we'll need more consensus to get this in tree. See Richard's 
comment:
"If someone's prepared to write up a paper for the C++ committee exploring what 
it would mean to standardize this behaviour and actually fix the problem for 
everyone, it would seem extremely reasonable for clang trunk to carry a flag to 
enable that behaviour (and it certainly doesn't have to wait for the committee 
to respond)."


https://reviews.llvm.org/D35338



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


[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane closed this revision.
erichkeane added a comment.

Forgot the svn commit message part, but closed by the related revision. r308530


https://reviews.llvm.org/D35572



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


r308530 - Add isValidCPUName and isValidFeature to TargetInfo

2017-07-19 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jul 19 14:50:08 2017
New Revision: 308530

URL: http://llvm.org/viewvc/llvm-project?rev=308530=rev
Log:
Add isValidCPUName and isValidFeature to TargetInfo

These two functions are really useful for implementations of attributes 
(including attribute-target), so add the functionality.

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

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=308530=308529=308530=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Jul 19 14:50:08 2017
@@ -869,6 +869,11 @@ public:
 return false;
   }
 
+  /// brief Determine whether this TargetInfo supports the given CPU name.
+  virtual bool isValidCPUName(StringRef Name) const {
+return false;
+  }
+
   /// \brief Use the specified ABI.
   ///
   /// \return False on error (invalid ABI name).
@@ -891,6 +896,11 @@ public:
 Features[Name] = Enabled;
   }
 
+  /// \brief Determine whether this TargetInfo supports the given feature.
+  virtual bool isValidFeatureName(StringRef Feature) const {
+return false;
+  }
+
   /// \brief Perform initialization based on the user configured
   /// set of features (e.g., +sse4).
   ///

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=308530=308529=308530=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul 19 14:50:08 2017
@@ -963,8 +963,8 @@ public:
   //  401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
   //  821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,
   //  titan, rs64.
-  bool setCPU(const std::string ) override {
-bool CPUKnown = llvm::StringSwitch(Name)
+  bool isValidCPUName(StringRef Name) const override {
+return llvm::StringSwitch(Name)
   .Case("generic", true)
   .Case("440", true)
   .Case("450", true)
@@ -1014,10 +1014,12 @@ public:
   .Case("powerpc64le", true)
   .Case("ppc64le", true)
   .Default(false);
+  }
 
+  bool setCPU(const std::string ) override {
+bool CPUKnown = isValidCPUName(Name);
 if (CPUKnown)
   CPU = Name;
-
 return CPUKnown;
   }
 
@@ -2006,6 +2008,9 @@ public:
 // FIXME: implement
 return TargetInfo::CharPtrBuiltinVaList;
   }
+  bool isValidCPUName(StringRef Name) const override {
+return StringToCudaArch(Name) != CudaArch::UNKNOWN;
+  }
   bool setCPU(const std::string ) override {
 GPU = StringToCudaArch(Name);
 return GPU != CudaArch::UNKNOWN;
@@ -2367,6 +2372,13 @@ public:
   .Default(GK_NONE);
   }
 
+  bool isValidCPUName(StringRef Name) const override {
+if (getTriple().getArch() == llvm::Triple::amdgcn)
+  return GK_NONE !=  parseAMDGCNName(Name);
+else
+  return GK_NONE !=  parseR600Name(Name);
+  }
+
   bool setCPU(const std::string ) override {
 if (getTriple().getArch() == llvm::Triple::amdgcn)
   GPU = parseAMDGCNName(Name);
@@ -2873,6 +2885,87 @@ class X86TargetInfo : public TargetInfo
 //@}
   } 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_Pentium3M:
+case CK_PentiumM:
+case CK_Yonah:
+case CK_C3_2:
+case CK_Pentium4:
+case CK_Pentium4M:
+case CK_Lakemont:
+case CK_Prescott:
+case CK_K6:
+case CK_K6_2:
+case CK_K6_3:
+case CK_Athlon:
+case CK_AthlonThunderbird:
+case CK_Athlon4:
+case CK_AthlonXP:
+case CK_AthlonMP:
+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_Athlon64:
+case CK_Athlon64SSE3:
+case CK_AthlonFX:

[PATCH] D34294: Rework libcxx strerror_r handling.

2017-07-19 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308528: Rework libcxx strerror_r handling. (authored by 
jyknight).

Repository:
  rL LLVM

https://reviews.llvm.org/D34294

Files:
  libcxx/trunk/src/system_error.cpp


Index: libcxx/trunk/src/system_error.cpp
===
--- libcxx/trunk/src/system_error.cpp
+++ libcxx/trunk/src/system_error.cpp
@@ -73,39 +73,59 @@
   std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
   return string(buffer);
 }
-#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && 
\
-(!defined(__ANDROID__) || __ANDROID_API__ >= 23)
-// GNU Extended version
-string do_strerror_r(int ev) {
-char buffer[strerror_buff_size];
-char* ret = ::strerror_r(ev, buffer, strerror_buff_size);
-return string(ret);
-}
 #else
-// POSIX version
+
+// Only one of the two following functions will be used, depending on
+// the return type of strerror_r:
+
+// For the GNU variant, a char* return value:
+__attribute__((unused)) const char *
+handle_strerror_r_return(char *strerror_return, char *buffer) {
+  // GNU always returns a string pointer in its return value. The
+  // string might point to either the input buffer, or a static
+  // buffer, but we don't care which.
+  return strerror_return;
+}
+
+// For the POSIX variant: an int return value.
+__attribute__((unused)) const char *
+handle_strerror_r_return(int strerror_return, char *buffer) {
+  // The POSIX variant either:
+  // - fills in the provided buffer and returns 0
+  // - returns a positive error value, or
+  // - returns -1 and fills in errno with an error value.
+  if (strerror_return == 0)
+return buffer;
+
+  // Only handle EINVAL. Other errors abort.
+  int new_errno = strerror_return == -1 ? errno : strerror_return;
+  if (new_errno == EINVAL)
+return "";
+
+  _LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from ::strerror_r");
+  // FIXME maybe? 'strerror_buff_size' is likely to exceed the
+  // maximum error size so ERANGE shouldn't be returned.
+  std::abort();
+}
+
+// This function handles both GNU and POSIX variants, dispatching to
+// one of the two above functions.
 string do_strerror_r(int ev) {
 char buffer[strerror_buff_size];
+// Preserve errno around the call. (The C++ standard requires that
+// system_error functions not modify errno).
 const int old_errno = errno;
-int ret;
-if ((ret = ::strerror_r(ev, buffer, strerror_buff_size)) != 0) {
-// If `ret == -1` then the error is specified using `errno`, otherwise
-// `ret` represents the error.
-const int new_errno = ret == -1 ? errno : ret;
-errno = old_errno;
-if (new_errno == EINVAL) {
-std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
-return string(buffer);
-} else {
-_LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from 
::strerr_r");
-// FIXME maybe? 'strerror_buff_size' is likely to exceed the
-// maximum error size so ERANGE shouldn't be returned.
-std::abort();
-}
+const char *error_message = handle_strerror_r_return(
+::strerror_r(ev, buffer, strerror_buff_size), buffer);
+// If we didn't get any message, print one now.
+if (!error_message[0]) {
+  std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
+  error_message = buffer;
 }
-return string(buffer);
+errno = old_errno;
+return string(error_message);
 }
 #endif
-
 } // end namespace
 #endif
 


Index: libcxx/trunk/src/system_error.cpp
===
--- libcxx/trunk/src/system_error.cpp
+++ libcxx/trunk/src/system_error.cpp
@@ -73,39 +73,59 @@
   std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
   return string(buffer);
 }
-#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && \
-(!defined(__ANDROID__) || __ANDROID_API__ >= 23)
-// GNU Extended version
-string do_strerror_r(int ev) {
-char buffer[strerror_buff_size];
-char* ret = ::strerror_r(ev, buffer, strerror_buff_size);
-return string(ret);
-}
 #else
-// POSIX version
+
+// Only one of the two following functions will be used, depending on
+// the return type of strerror_r:
+
+// For the GNU variant, a char* return value:
+__attribute__((unused)) const char *
+handle_strerror_r_return(char *strerror_return, char *buffer) {
+  // GNU always returns a string pointer in its return value. The
+  // string might point to either the input buffer, or a static
+  // buffer, but we don't care which.
+  return strerror_return;
+}
+
+// For the POSIX variant: an int return value.
+__attribute__((unused)) const char *
+handle_strerror_r_return(int strerror_return, char *buffer) {
+  // The POSIX variant either:
+  // - fills in the provided buffer and returns 0

[libcxx] r308528 - Rework libcxx strerror_r handling.

2017-07-19 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Wed Jul 19 14:48:49 2017
New Revision: 308528

URL: http://llvm.org/viewvc/llvm-project?rev=308528=rev
Log:
Rework libcxx strerror_r handling.

The set of #ifdefs used to handle the two incompatible variants of
strerror_r were not complete (they didn't handle newlib appropriately).

Rather than attempting to make the ifdefs more complex, make them
unnecessary by choosing which behavior to use dependent upon the
return type.

Reviewers: waltl

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

Modified:
libcxx/trunk/src/system_error.cpp

Modified: libcxx/trunk/src/system_error.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/system_error.cpp?rev=308528=308527=308528=diff
==
--- libcxx/trunk/src/system_error.cpp (original)
+++ libcxx/trunk/src/system_error.cpp Wed Jul 19 14:48:49 2017
@@ -73,39 +73,59 @@ string do_strerror_r(int ev) {
   std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
   return string(buffer);
 }
-#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && 
\
-(!defined(__ANDROID__) || __ANDROID_API__ >= 23)
-// GNU Extended version
-string do_strerror_r(int ev) {
-char buffer[strerror_buff_size];
-char* ret = ::strerror_r(ev, buffer, strerror_buff_size);
-return string(ret);
-}
 #else
-// POSIX version
+
+// Only one of the two following functions will be used, depending on
+// the return type of strerror_r:
+
+// For the GNU variant, a char* return value:
+__attribute__((unused)) const char *
+handle_strerror_r_return(char *strerror_return, char *buffer) {
+  // GNU always returns a string pointer in its return value. The
+  // string might point to either the input buffer, or a static
+  // buffer, but we don't care which.
+  return strerror_return;
+}
+
+// For the POSIX variant: an int return value.
+__attribute__((unused)) const char *
+handle_strerror_r_return(int strerror_return, char *buffer) {
+  // The POSIX variant either:
+  // - fills in the provided buffer and returns 0
+  // - returns a positive error value, or
+  // - returns -1 and fills in errno with an error value.
+  if (strerror_return == 0)
+return buffer;
+
+  // Only handle EINVAL. Other errors abort.
+  int new_errno = strerror_return == -1 ? errno : strerror_return;
+  if (new_errno == EINVAL)
+return "";
+
+  _LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from ::strerror_r");
+  // FIXME maybe? 'strerror_buff_size' is likely to exceed the
+  // maximum error size so ERANGE shouldn't be returned.
+  std::abort();
+}
+
+// This function handles both GNU and POSIX variants, dispatching to
+// one of the two above functions.
 string do_strerror_r(int ev) {
 char buffer[strerror_buff_size];
+// Preserve errno around the call. (The C++ standard requires that
+// system_error functions not modify errno).
 const int old_errno = errno;
-int ret;
-if ((ret = ::strerror_r(ev, buffer, strerror_buff_size)) != 0) {
-// If `ret == -1` then the error is specified using `errno`, otherwise
-// `ret` represents the error.
-const int new_errno = ret == -1 ? errno : ret;
-errno = old_errno;
-if (new_errno == EINVAL) {
-std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
-return string(buffer);
-} else {
-_LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from 
::strerr_r");
-// FIXME maybe? 'strerror_buff_size' is likely to exceed the
-// maximum error size so ERANGE shouldn't be returned.
-std::abort();
-}
+const char *error_message = handle_strerror_r_return(
+::strerror_r(ev, buffer, strerror_buff_size), buffer);
+// If we didn't get any message, print one now.
+if (!error_message[0]) {
+  std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
+  error_message = buffer;
 }
-return string(buffer);
+errno = old_errno;
+return string(error_message);
 }
 #endif
-
 } // end namespace
 #endif
 


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


[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-19 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.



LGTM.

-eric


https://reviews.llvm.org/D35572



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


[PATCH] D34873: Fix miscompiled 32bit binaries by mingw

2017-07-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk requested changes to this revision.
rnk added a comment.
This revision now requires changes to proceed.

This doesn't seem like an acceptable workaround, surely this regresses 
functionality for arrays with more than UINT_MAX elements.


https://reviews.llvm.org/D34873



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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-19 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:1336
+if code compiled using ``-mlong-calls`` switch, it forces compiler to use
+the ``jal`` instruction to call the function.
+  }];

rjmccall wrote:
> sdardis wrote:
> > rjmccall wrote:
> > > I suggest the following wording:
> > > 
> > > Clang supports the ``__attribute__((long_call))``, 
> > > ``__attribute__((far))``, and
> > > ``__attribute__((near))`` attributes on MIPS targets.  These attributes 
> > > may only be
> > > added to function declarations and change the code generated by the 
> > > compiler when
> > > directly calling the function.  The ``near`` attribute allows calls to 
> > > the function to
> > > be made using the ``jal`` instruction, which requires the function to be 
> > > defined in the
> > > same 256MB segment as the caller.  The ``long_call`` and ``far`` 
> > > attributes are
> > > synonyms and require the use of a different call sequence that works 
> > > regardless of
> > > the distance between the functions.
> > > 
> > > These attributes take priority over command line switches such as 
> > > ``-mlong-calls``.
> > > requires the function to be defined
> > 
> > I'd change the "defined" to be "located".
> > 
> > > in the same 256MB segment as the caller.
> > 
> > I'd change this to: "in the same naturally aligned 256MB segment as the 
> > caller."
> > 
> > This also needs a note saying that it has no effect for code compiled with 
> > -fpic.
> Oh, yes, if these statements are true then it's absolutely important to 
> include them.  I was going off of the raw ISA specification, since jal just 
> takes a relative offset, but if the toolchain has more specific requirements 
> then those are what should be documented.
> 
> This whole feature is strange to me; do MIPS linkers just never introduce 
> things like branch islands and lazy-binding functions?
> since jal just takes a relative offset,

jal doesn't take an offset, the instruction takes an 26-bit immediate  (called 
the instruction index) shifts it left 2 bits and combines it with the remaining 
upper bits of the address of the instruction in the delay slot of jal to form 
the new $pc--so it's possible to jump from the bottom of a 256MB segment to the 
top.

(My apologies for the long answer here, jal is one of the odder control 
transfer instruction for MIPS.)

> This whole feature is strange to me; do MIPS linkers just never introduce 
> things like branch islands and lazy-binding functions?

This feature is orthogonal to lazy-binding functions. The usage of 'long-call' 
and 'near' is to support bare-metal / static relocation model environments 
where the caller and callee might be in different memory segments (e.g. KSEG0 
and KSEG1) or have a custom memory layout for their program's sections.

To the best of my knowledge, the GNU linker for MIPS only inserts stub 
functions / branch islands when compiling static code that calls PIC code. 


Repository:
  rL LLVM

https://reviews.llvm.org/D35479



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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-19 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 107381.
atanasyan added a comment.

- New wording of attributes documentation and comments.
- Remove redundant `if-return` statements.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/long-call-attr.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-long-call.c

Index: test/Sema/attr-long-call.c
===
--- /dev/null
+++ test/Sema/attr-long-call.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+
+__attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' attribute takes no arguments}}
+__attribute__((far(0))) void foo2();  // expected-error {{'far' attribute takes no arguments}}
+__attribute__((near(0))) void foo3();  // expected-error {{'near' attribute takes no arguments}}
+
+__attribute((long_call)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((far)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((near)) int a; // expected-warning {{attribute only applies to functions}}
+
+__attribute((long_call)) void foo4();
+__attribute((far)) void foo5();
+__attribute((near)) void foo6();
+
+__attribute((long_call, far)) void foo7();
+
+__attribute((far, near)) void foo8(); // expected-error {{'far' and 'near' attributes are not compatible}} \
+  // expected-note {{conflicting attribute is here}}
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 62 attributes:
+// CHECK: #pragma clang attribute supports 64 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -31,6 +31,8 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
+// CHECK-NEXT: MipsLongCall (SubjectMatchRule_function)
+// CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
Index: test/CodeGen/long-call-attr.c
===
--- /dev/null
+++ test/CodeGen/long-call-attr.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+
+void __attribute__((long_call)) foo1 (void);
+
+void __attribute__((far)) foo2 (void) {}
+
+// CHECK: define void @foo2() [[FAR:#[0-9]+]]
+
+void __attribute__((near)) foo3 (void) { foo1(); }
+
+// CHECK: define void @foo3() [[NEAR:#[0-9]+]]
+
+// CHECK: declare void @foo1() [[LONGDECL:#[0-9]+]]
+
+// CHECK: attributes [[FAR]] = { {{.*}} "long-call" {{.*}} }
+// CHECK: attributes [[NEAR]] = { {{.*}} "short-call" {{.*}} }
+// CHECK: attributes [[LONGDECL]] = { {{.*}} "long-call" {{.*}} }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5965,6 +5965,14 @@
   case AttributeList::AT_NoMicroMips:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_MipsLongCall:
+handleSimpleAttributeWithExclusions(
+S, D, Attr);
+break;
+  case AttributeList::AT_MipsShortCall:
+handleSimpleAttributeWithExclusions(
+S, D, Attr);
+break;
   case AttributeList::AT_AMDGPUFlatWorkGroupSize:
 handleAMDGPUFlatWorkGroupSizeAttr(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 #define LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 
+#include "CodeGenModule.h"
 #include "CGValue.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
@@ -34,7 +35,6 @@
 namespace CodeGen {
 class ABIInfo;
 class CallArgList;
-class CodeGenModule;
 class CodeGenFunction;
 class CGFunctionInfo;
 
@@ -55,7 +55,8 @@
   /// setTargetAttributes - 

[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-19 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D35572#813520, @erichkeane wrote:

> In https://reviews.llvm.org/D35572#813369, @echristo wrote:
>
> > Can you update the code in CGBuiltin to use this as part of this patch? :)
> >
> > Thanks!
>
>
> I'm not sure which you're referring to?  I don't see a bit in CGBuiltin that 
> checks for a subset of the "Features", however it is a much smaller list 
> (since it is only things that the compiler-rt can check).  Is it perhaps more 
> closely related to that one?


It's currently checking for a subset, but that's just because it was the subset 
that the compiler-rt support supported. After Craig's patch I think we can just 
support them all unless I'm misreading something.


https://reviews.llvm.org/D35572



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-07-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 6 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11846
   // an address space.
   if (T.getAddressSpace() != 0) {
 // OpenCL allows function arguments declared to be an array of a type

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Could we use `LangAS::Default` here too?
> > done
> Sorry, I wasn't clear. I think we could have:
> 
>   if (T.getAddressSpace() != LangAS::Default && T.getAddressSpace() != 
> LangAS::opencl_private)
> 
> and then original condition. It is a bit clearer I think.
No. For OpenCL, the condition is on line 11847 and 11848. An array type in 
other address spaces is allowed.



Comment at: lib/Sema/SemaType.cpp:6969
 
+  if (state.getSema().getLangOpts().OpenCL &&
+  !hasOpenCLAddressSpace && type.getAddressSpace() == 0 &&

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Would it be nicer to not append any address space at all neither here nor 
> > > down at the end of this function and keep it default instead until the 
> > > Codegen? If it's doable I would very much prefer that. It seems like it 
> > > would make the implementation potentially a bit cleaner to understand and 
> > > easier to improve semantical analysis. See one example of improving 
> > > original type printing in my comment to the test below.
> > > 
> > > Also there are at least these 3 related bugs open currently:
> > > https://bugs.llvm.org//show_bug.cgi?id=33418
> > > https://bugs.llvm.org//show_bug.cgi?id=33419
> > > https://bugs.llvm.org//show_bug.cgi?id=33420
> > > 
> > > Does your change address any of those?
> > On the contrary, I think using default address space for automatic variable 
> > and function parameter will cause ambiguity and inconsistency in AST, 
> > making it more difficult to understand and process, and making some bug 
> > (e.g. https://bugs.llvm.org//show_bug.cgi?id=33419) unfixable. For example, 
> > `private int f(void)` and `int f(void)` will be identical in AST, therefore 
> > we cannot diagnose `private int f(void)`.
> > 
> > With current representation I am able to fix the 3 bugs. I will update the 
> > diff.
> I don't see why?
> 
> `private int f(void)` -> will have an address space attribute in AST as it is 
> provided explicitly.
> 
> `int f(void) ` -> will have no address space attribute because it's not 
> provided explicitly and not attached implicitly either.
> 
> All I was asking is  not to deduce the address space here if it's not 
> specified explicitly until later step when we need to put it in the IR.
Clang already deduce global and generic address spaces and use them in the 
diagnostic messages. I don't see why we can use deduced global and generic 
address space in diagnostics whereas cannot use deduced private address space 
in diagnostics. Why users can accept deduced global and generic address spaces 
but cannot accept deduced private address space?

Automatic variables and function parameters have private address space. This is 
the reality and as true as a global variable has global or constant address 
spaces. Not using private address space in diagnostics gives user illusion that 
automatic variables and function parameters do not have address space, which is 
not true.

Besides, allowing default address space to represent private address space in 
AST causes ambiguity in AST. Instead of just check if a type has private 
address space, now we need to check if a type has private or default address 
spaces. Also if an expression has default address space, it is not clear if it 
is an l-value or r-value. This will complicate semantic checking unnecessarily. 
Also I am not sure if it is acceptable to modify AST between Sema and CodeGen 
since it seems to change the paradigm of how clang does Sema/CodeGen now.


https://reviews.llvm.org/D35082



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


New buildbot admin

2017-07-19 Thread Galina Kistanova via cfe-commits
Hello everyone,

I'm going on vacation starting from the next week. I will be traveling, so
likely will be slow with my e-mails.

Please feel free to contact Victor Leschuk ()
with the questions or request related to the LLVM Lab and the buildbot
infrastructure.

Thanks

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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:1336
+if code compiled using ``-mlong-calls`` switch, it forces compiler to use
+the ``jal`` instruction to call the function.
+  }];

sdardis wrote:
> rjmccall wrote:
> > I suggest the following wording:
> > 
> > Clang supports the ``__attribute__((long_call))``, 
> > ``__attribute__((far))``, and
> > ``__attribute__((near))`` attributes on MIPS targets.  These attributes may 
> > only be
> > added to function declarations and change the code generated by the 
> > compiler when
> > directly calling the function.  The ``near`` attribute allows calls to the 
> > function to
> > be made using the ``jal`` instruction, which requires the function to be 
> > defined in the
> > same 256MB segment as the caller.  The ``long_call`` and ``far`` attributes 
> > are
> > synonyms and require the use of a different call sequence that works 
> > regardless of
> > the distance between the functions.
> > 
> > These attributes take priority over command line switches such as 
> > ``-mlong-calls``.
> > requires the function to be defined
> 
> I'd change the "defined" to be "located".
> 
> > in the same 256MB segment as the caller.
> 
> I'd change this to: "in the same naturally aligned 256MB segment as the 
> caller."
> 
> This also needs a note saying that it has no effect for code compiled with 
> -fpic.
Oh, yes, if these statements are true then it's absolutely important to include 
them.  I was going off of the raw ISA specification, since jal just takes a 
relative offset, but if the toolchain has more specific requirements then those 
are what should be documented.

This whole feature is strange to me; do MIPS linkers just never introduce 
things like branch islands and lazy-binding functions?


Repository:
  rL LLVM

https://reviews.llvm.org/D35479



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


[PATCH] D35259: Complex Long Double classification In RegCall calling convention

2017-07-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:3516
+  // calling convention is used.
   if (IsRegCall && FI.getReturnType()->getTypePtr()->isRecordType() &&
   !FI.getReturnType()->getTypePtr()->isUnionType()) {

This is incorrect. We should consult the CXXABI first, and then only do these 
regcall-specific things if it returns false. Consider adding this test case to 
find the bug:
```
struct NonTrivial {
  int x, y;
  ~NonTrivial();
};
NonTrivial __regcall f() { return NonTrivial(); }
```

This should not return in registers, but it does today.



Comment at: lib/CodeGen/TargetInfo.cpp:3526
 }
+  } else if (IsRegCall && FI.getReturnType()->getAs()) {
+const ComplexType *CT = FI.getReturnType()->getAs();

This isn't necessarily a bug, but please always do C++ ABI classifications 
first so it's easy to spot the bug above.


https://reviews.llvm.org/D35259



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


[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-19 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 updated this revision to Diff 107347.
malhar1995 added a comment.

Addressed all comments except the one where I had to remove the test to see if 
the return type was null while emitting diagnostics.


Repository:
  rL LLVM

https://reviews.llvm.org/D35613

Files:
  include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/retain-release-inline.m
  test/Analysis/retain-release.m

Index: test/Analysis/retain-release.m
===
--- test/Analysis/retain-release.m
+++ test/Analysis/retain-release.m
@@ -325,6 +325,9 @@
 
 extern
 void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
+typedef struct {
+  int ref;
+} isl_basic_map;
 
 //===--===//
 // Test cases.
@@ -574,6 +577,14 @@
   }
 }
 
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
+
+// Test custom diagnostics for generalized objects.
+void f18(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
+  // After this call, 'bmap' has a +1 reference count.
+  bmap = isl_basic_map_cow(bmap); // expected-warning {{Potential leak of an object}}
+}
+
 // Test basic tracking of ivars associated with 'self'.  For the retain/release
 // checker we currently do not want to flag leaks associated with stores
 // of tracked objects to ivars.
Index: test/Analysis/retain-release-inline.m
===
--- test/Analysis/retain-release-inline.m
+++ test/Analysis/retain-release-inline.m
@@ -299,15 +299,15 @@
   bar(s);
 }
 
-__attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_cow(__attribute__((cf_consumed)) isl_basic_map *bmap);
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
 void free(void *);
 
 // As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
 // implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
 // a leak warning is raised by RetainCountChecker as the analyzer is unable to detect a decrement in the reference
 // count of 'bmap' along the path in 'isl_basic_map_free' assuming the predicate of the second 'if' branch to be
 // true or assuming both the predicates in the function to be false.
-__attribute__((annotate("rc_ownership_trusted_implementation"))) isl_basic_map *isl_basic_map_free(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+__attribute__((annotate("rc_ownership_trusted_implementation"))) isl_basic_map *isl_basic_map_free(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   if (!bmap)
 return NULL;
 
@@ -322,15 +322,15 @@
 // implementation and doesn't analyze its body. If that annotation is removed, a 'use-after-release' warning might
 // be raised by RetainCountChecker as the pointer which is passed as an argument to this function and the pointer
 // which is returned from the function point to the same memory location.
-__attribute__((annotate("rc_ownership_trusted_implementation"))) __attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap) {
+__attribute__((annotate("rc_ownership_trusted_implementation"))) __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap) {
   if (!bmap)
 return NULL;
 
   bmap->ref++;
   return bmap;
 }
 
-void test_use_after_release_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+void test_use_after_release_with_trusted_implementation_annotate_attribute(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   // After this call, 'bmap' has a +1 reference count.
   bmap = isl_basic_map_cow(bmap);
   // After the call to 'isl_basic_map_copy', 'bmap' has a +1 reference count.
@@ -341,7 +341,7 @@
   isl_basic_map_free(temp);
 }
 
-void test_leak_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+void test_leak_with_trusted_implementation_annotate_attribute(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   // After this call, 'bmap' has a +1 reference count.
   bmap = isl_basic_map_cow(bmap); // no-warning
   // After this call, 'bmap' has a +0 reference count.
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -1340,6 +1340,8 @@
 
   if (D->hasAttr())
 return 

[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-19 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

In https://reviews.llvm.org/D35578#814919, @mcrosier wrote:

> It sounds like to me you have some cases when you do want lookup tables and 
> other cases that you don't.  What exactly is the determining factor here?


The determining factor is whether the customers want it or not.  Each case has 
its own specifics, which we do not want to hardcode into the compiler.  At one 
point, the customers have reported to us that memory loads coming from switch 
expansion is an undesirable outcome.  We want to provide them with an option to 
prevent that from happening.


https://reviews.llvm.org/D35578



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


[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-19 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier added a comment.

In https://reviews.llvm.org/D35578#814817, @sgundapa wrote:

> > Wouldn't the fix be to make the backend deal with this, then? Either by 
> > putting the table with the function text, or or opting out of lookup 
> > tables? It seems that might be a better experience for the user.
>
> That is perfectly reasonable and in fact  i have committed a hexagon change 
> recently to that effect . The llvm flag hexagon-emi-lookup-tables controls 
> the generation of lookup table for hexagon.
>  The problem is, I don't want the users of the compiler to use a combination 
> of front end and back end flags to get the desired result.


First, command-line flags (i.e., those predicated with -mllvm) were never 
designed to be customer facing.  They have no guarantee that they will persist 
and are generally undocumented.  They're designed to be used by those working 
on LLVM to simplify tuning/testing.  Any other use is likely a misuse.

> "-fno-jump-tables -mllvm -hexagon-emit-lookup-tables=false". This could be 
> much neater with a "-fno-jump-tables -fno-lookup-tables" or better just 
> "-fno-switch-tables"

I'm still very far from convinced adding new flags and proposing that users 
switch from using the long-standing -fno-jump-tables flag to the 
-fno-switch-tables flag is the right approach.  Are you going to convince the 
GCC community to do the same?

It sounds like to me you have some cases when you do want lookup tables and 
other cases that you don't.  What exactly is the determining factor here?  
Moreover, why can't this determining factor be built into the compiler so the 
user doesn't even have to bother.  That would be a more ideal user experience.

As an alternative solution, why not just disable the transformation in 
SimplifyCFG when -fno-jump-tables is used?  The underlying issue seems to be 
the same (i.e., you want to avoid generating more relocations) and AFAICT 
that's what -fno-jump-tables is all about..  (Admittedly, I don't know the full 
history of -fno-jump-tables, so others might disagree with this suggestion.)


https://reviews.llvm.org/D35578



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


[PATCH] D35259: Complex Long Double classification In RegCall calling convention

2017-07-19 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 107343.
eandrews added a comment.

As per revision comments, I moved the condition for extended precision floating 
type to isX86VectorTypeForVectorCall. This update will now alter behavior for 
complex long double type under vectorcall calling convention as well. 
Returns/parameters will be passed in memory.


https://reviews.llvm.org/D35259

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenCXX/regcall.cpp


Index: test/CodeGenCXX/regcall.cpp
===
--- test/CodeGenCXX/regcall.cpp
+++ test/CodeGenCXX/regcall.cpp
@@ -95,3 +95,11 @@
   freeTempFunc(1);
   t3.do_thing();
 }
+
+long double _Complex __regcall foo(long double _Complex f) {
+  return f;
+}
+// CHECK-LIN64-DAG: define x86_regcallcc void @_Z15__regcall3__fooCe({ 
x86_fp80, x86_fp80 }* noalias sret %agg.result, { x86_fp80, x86_fp80 }* byval 
align 16 %f)
+// CHECK-LIN32-DAG: define x86_regcallcc void @_Z15__regcall3__fooCe({ 
x86_fp80, x86_fp80 }* inreg noalias sret %agg.result, { x86_fp80, x86_fp80 }* 
byval align 4 %f)
+// CHECK-WIN64-DAG: define x86_regcallcc { double, double } 
@"\01?foo@@YwU?$_Complex@O@__clang@@U12@@Z"(double %f.0, double %f.1)
+// CHECK-WIN32-DAG: define x86_regcallcc { double, double } 
@"\01?foo@@YwU?$_Complex@O@__clang@@U12@@Z"(double %f.0, double %f.1)
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -882,8 +882,14 @@
 /// X86_VectorCall calling convention. Shared between x86_32 and x86_64.
 static bool isX86VectorTypeForVectorCall(ASTContext , QualType Ty) {
   if (const BuiltinType *BT = Ty->getAs()) {
-if (BT->isFloatingPoint() && BT->getKind() != BuiltinType::Half)
+if (BT->isFloatingPoint() && BT->getKind() != BuiltinType::Half) {
+  if (BT->getKind() == BuiltinType::LongDouble) {
+if (().getLongDoubleFormat() ==
+::APFloat::x87DoubleExtended())
+  return false;
+  }
   return true;
+}
   } else if (const VectorType *VT = Ty->getAs()) {
 // vectorcall can pass XMM, YMM, and ZMM vectors. We don't pass SSE1 MMX
 // registers specially.
@@ -3505,6 +3511,8 @@
   unsigned FreeSSERegs = IsRegCall ? 16 : 8;
   unsigned NeededInt, NeededSSE;
 
+  // Complex Long Double Type is passed in Memory when Regcall
+  // calling convention is used.
   if (IsRegCall && FI.getReturnType()->getTypePtr()->isRecordType() &&
   !FI.getReturnType()->getTypePtr()->isUnionType()) {
 FI.getReturnInfo() =
@@ -3515,6 +3523,11 @@
 } else {
   FI.getReturnInfo() = getIndirectReturnResult(FI.getReturnType());
 }
+  } else if (IsRegCall && FI.getReturnType()->getAs()) {
+const ComplexType *CT = FI.getReturnType()->getAs();
+if (getContext().getCanonicalType(CT->getElementType()) ==
+getContext().LongDoubleTy)
+  FI.getReturnInfo() = getIndirectReturnResult(FI.getReturnType());
   } else if (!getCXXABI().classifyReturnType(FI))
 FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
 


Index: test/CodeGenCXX/regcall.cpp
===
--- test/CodeGenCXX/regcall.cpp
+++ test/CodeGenCXX/regcall.cpp
@@ -95,3 +95,11 @@
   freeTempFunc(1);
   t3.do_thing();
 }
+
+long double _Complex __regcall foo(long double _Complex f) {
+  return f;
+}
+// CHECK-LIN64-DAG: define x86_regcallcc void @_Z15__regcall3__fooCe({ x86_fp80, x86_fp80 }* noalias sret %agg.result, { x86_fp80, x86_fp80 }* byval align 16 %f)
+// CHECK-LIN32-DAG: define x86_regcallcc void @_Z15__regcall3__fooCe({ x86_fp80, x86_fp80 }* inreg noalias sret %agg.result, { x86_fp80, x86_fp80 }* byval align 4 %f)
+// CHECK-WIN64-DAG: define x86_regcallcc { double, double } @"\01?foo@@YwU?$_Complex@O@__clang@@U12@@Z"(double %f.0, double %f.1)
+// CHECK-WIN32-DAG: define x86_regcallcc { double, double } @"\01?foo@@YwU?$_Complex@O@__clang@@U12@@Z"(double %f.0, double %f.1)
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -882,8 +882,14 @@
 /// X86_VectorCall calling convention. Shared between x86_32 and x86_64.
 static bool isX86VectorTypeForVectorCall(ASTContext , QualType Ty) {
   if (const BuiltinType *BT = Ty->getAs()) {
-if (BT->isFloatingPoint() && BT->getKind() != BuiltinType::Half)
+if (BT->isFloatingPoint() && BT->getKind() != BuiltinType::Half) {
+  if (BT->getKind() == BuiltinType::LongDouble) {
+if (().getLongDoubleFormat() ==
+::APFloat::x87DoubleExtended())
+  return false;
+  }
   return true;
+}
   } else if (const VectorType *VT = Ty->getAs()) {
 // vectorcall can pass XMM, YMM, and ZMM vectors. We don't pass SSE1 MMX
 // registers specially.
@@ -3505,6 +3511,8 @@
   unsigned FreeSSERegs = IsRegCall ? 16 : 8;
   unsigned NeededInt, 

r308498 - Add AlignedAllocation.h.

2017-07-19 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed Jul 19 10:26:42 2017
New Revision: 308498

URL: http://llvm.org/viewvc/llvm-project?rev=308498=rev
Log:
Add AlignedAllocation.h.

I forgot to "git add" it in r308496.

Added:
cfe/trunk/include/clang/Basic/AlignedAllocation.h

Added: cfe/trunk/include/clang/Basic/AlignedAllocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AlignedAllocation.h?rev=308498=auto
==
--- cfe/trunk/include/clang/Basic/AlignedAllocation.h (added)
+++ cfe/trunk/include/clang/Basic/AlignedAllocation.h Wed Jul 19 10:26:42 2017
@@ -0,0 +1,44 @@
+//===--- AlignedAllocation.h - Aligned Allocation ---*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief Defines a function that returns the minimum OS versions supporting
+/// C++17's aligned allocation functions.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ALIGNED_ALLOCATION_H
+#define LLVM_CLANG_BASIC_ALIGNED_ALLOCATION_H
+
+#include "clang/Basic/VersionTuple.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/ErrorHandling.h"
+
+namespace clang {
+
+inline VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) {
+  switch (OS) {
+  default:
+break;
+  case llvm::Triple::Darwin:
+  case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
+return VersionTuple(10U, 13U);
+  case llvm::Triple::IOS:
+  case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
+return VersionTuple(11U);
+  case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0.
+return VersionTuple(4U);
+  }
+
+  llvm_unreachable("Unexpected OS");
+}
+
+} // end namespace clang
+
+#endif // LLVM_CLANG_BASIC_ALIGNED_ALLOCATION_H


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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-19 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Some comments on the documentation.




Comment at: include/clang/Basic/AttrDocs.td:1336
+if code compiled using ``-mlong-calls`` switch, it forces compiler to use
+the ``jal`` instruction to call the function.
+  }];

rjmccall wrote:
> I suggest the following wording:
> 
> Clang supports the ``__attribute__((long_call))``, ``__attribute__((far))``, 
> and
> ``__attribute__((near))`` attributes on MIPS targets.  These attributes may 
> only be
> added to function declarations and change the code generated by the compiler 
> when
> directly calling the function.  The ``near`` attribute allows calls to the 
> function to
> be made using the ``jal`` instruction, which requires the function to be 
> defined in the
> same 256MB segment as the caller.  The ``long_call`` and ``far`` attributes 
> are
> synonyms and require the use of a different call sequence that works 
> regardless of
> the distance between the functions.
> 
> These attributes take priority over command line switches such as 
> ``-mlong-calls``.
> requires the function to be defined

I'd change the "defined" to be "located".

> in the same 256MB segment as the caller.

I'd change this to: "in the same naturally aligned 256MB segment as the caller."

This also needs a note saying that it has no effect for code compiled with 
-fpic.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479



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


[PATCH] D35520: [Sema] Improve diagnostic message for unavailable c++17 aligned allocation functions

2017-07-19 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308496: [Sema] Improve diagnostic message for unavailable 
C++17 aligned (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D35520?vs=107140=107336#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35520

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6420,8 +6420,8 @@
   "guarantees %2 bytes">,
   InGroup, DefaultIgnore;
 def warn_aligned_allocation_unavailable :Warning<
-  "aligned %select{allocation|deallocation}0 function of type '%1' possibly "
-  "unavailable on %2">, InGroup, DefaultError;
+  "aligned %select{allocation|deallocation}0 function of type '%1' is only "
+  "available on %2 %3 or newer">, InGroup, DefaultError;
 def note_silence_unligned_allocation_unavailable : Note<
   "if you supply your own aligned allocation functions, use "
   "-Wno-aligned-allocation-unavailable to silence this diagnostic">;
Index: cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,6 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
+// RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DWATCHOS %s
+// RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 
 namespace std {
   typedef decltype(sizeof(0)) size_t;
@@ -56,44 +62,68 @@
 #ifdef NO_ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' possibly unavailable on}}
+// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
 // expected-note@-17 {{if you supply your own aligned allocation functions}}
-// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-19 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' possibly unavailable on}}
+// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
 // expected-note@-21 {{if you supply your own aligned allocation functions}}
-// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-23 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-25 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' possibly unavailable on}}
+// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
 // expected-note@-27 {{if you supply your own aligned allocation functions}}
-// expected-error@-28 {{aligned deallocation function of type 'void (void *, 

[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

A few more minor tweaks.




Comment at: lib/CodeGen/TargetInfo.cpp:2357
+return;
+  X86_32TargetCodeGenInfo::setTargetAttributes(D, GV, CGM, IsForDefinition);
 

That function has its own early exit, so do the early exit after calling it, 
please.



Comment at: lib/CodeGen/TargetInfo.cpp:5538
+return;
+  ARMTargetCodeGenInfo::setTargetAttributes(D, GV, CGM, IsForDefinition);
   addStackProbeSizeTargetAttribute(D, GV, CGM);

Same thing here.



Comment at: lib/CodeGen/TargetInfo.cpp:6643
+
+// Other attributes do not have a sense for declarations.
+if (!IsForDefinition)

"meaning" is a better word here.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479



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


r308496 - [Sema] Improve diagnostic message for unavailable C++17 aligned

2017-07-19 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed Jul 19 10:17:50 2017
New Revision: 308496

URL: http://llvm.org/viewvc/llvm-project?rev=308496=rev
Log:
[Sema] Improve diagnostic message for unavailable C++17 aligned
allocation functions.

This changes the error message Sema prints when an unavailable C++17
aligned allocation function is selected.

Original message: "... possibly unavailable on x86_64-apple-macos10.12"
New message: "... only available on macOS 10.13 or newer"

This is a follow-up to r306722.

rdar://problem/32664169

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=308496=308495=308496=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 19 10:17:50 
2017
@@ -6420,8 +6420,8 @@ def warn_overaligned_type : Warning<
   "guarantees %2 bytes">,
   InGroup, DefaultIgnore;
 def warn_aligned_allocation_unavailable :Warning<
-  "aligned %select{allocation|deallocation}0 function of type '%1' possibly "
-  "unavailable on %2">, InGroup, DefaultError;
+  "aligned %select{allocation|deallocation}0 function of type '%1' is only "
+  "available on %2 %3 or newer">, InGroup, 
DefaultError;
 def note_silence_unligned_allocation_unavailable : Note<
   "if you supply your own aligned allocation functions, use "
   "-Wno-aligned-allocation-unavailable to silence this diagnostic">;

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=308496=308495=308496=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Wed Jul 19 10:17:50 2017
@@ -10,6 +10,7 @@
 #include "Darwin.h"
 #include "Arch/ARM.h"
 #include "CommonArgs.h"
+#include "clang/Basic/AlignedAllocation.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Driver/Compilation.h"
@@ -1743,19 +1744,27 @@ void MachO::AddLinkRuntimeLibArgs(const
 }
 
 bool Darwin::isAlignedAllocationUnavailable() const {
+  llvm::Triple::OSType OS;
+
   switch (TargetPlatform) {
   case MacOS: // Earlier than 10.13.
-return TargetVersion < VersionTuple(10U, 13U, 0U);
+OS = llvm::Triple::MacOSX;
+break;
   case IPhoneOS:
   case IPhoneOSSimulator:
+OS = llvm::Triple::IOS;
+break;
   case TvOS:
   case TvOSSimulator: // Earlier than 11.0.
-return TargetVersion < VersionTuple(11U, 0U, 0U);
+OS = llvm::Triple::TvOS;
+break;
   case WatchOS:
   case WatchOSSimulator: // Earlier than 4.0.
-return TargetVersion < VersionTuple(4U, 0U, 0U);
+OS = llvm::Triple::WatchOS;
+break;
   }
-  llvm_unreachable("Unsupported platform");
+
+  return TargetVersion < alignedAllocMinVersion(OS);
 }
 
 void Darwin::addClangTargetOptions(const llvm::opt::ArgList ,

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=308496=308495=308496=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 19 10:17:50 2017
@@ -24,6 +24,7 @@
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/Basic/AlignedAllocation.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1660,9 +1661,13 @@ static void diagnoseUnavailableAlignedAl
 
   bool IsAligned = false;
   if (FD.isReplaceableGlobalAllocationFunction() && IsAligned) {
+const llvm::Triple  = S.getASTContext().getTargetInfo().getTriple();
+StringRef OSName = AvailabilityAttr::getPlatformNameSourceSpelling(
+S.getASTContext().getTargetInfo().getPlatformName());
+
 S.Diag(Loc, diag::warn_aligned_allocation_unavailable)
- << IsDelete << FD.getType().getAsString()
- << S.getASTContext().getTargetInfo().getTriple().str();
+ << IsDelete << FD.getType().getAsString() << OSName
+ << alignedAllocMinVersion(T.getOS()).getAsString();
 S.Diag(Loc, diag::note_silence_unligned_allocation_unavailable);
   }
 }

Modified: cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp?rev=308496=308495=308496=diff

[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-19 Thread Sumanth Gundapaneni via Phabricator via cfe-commits
sgundapa added a comment.

> Wouldn't the fix be to make the backend deal with this, then? Either by 
> putting the table with the function text, or or opting out of lookup tables? 
> It seems that might be a better experience for the user.

That is perfectly reasonable and in fact  i have committed a hexagon change 
recently to that effect . The llvm flag hexagon-emi-lookup-tables controls the 
generation of lookup table for hexagon.
The problem is, I don't want the users of the compiler to use a combination of 
front end and back end flags to get the desired result.
"-fno-jump-tables -mllvm -hexagon-emit-lookup-tables=false". This could be much 
neater with a "-fno-jump-tables -fno-lookup-tables" or better just 
"-fno-switch-tables"


https://reviews.llvm.org/D35578



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


LLVM buildmaster will be updated and restarted tonight

2017-07-19 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 7 PM Pacific time
today.

Thanks

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


[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D35578#814590, @sgundapa wrote:

> I will try to address the concerns here:
>
> > What exactly is the motivation? I'm trying to narrow down the justification 
> > for adding yet more flags.
>
> (I just typed this message in https://reviews.llvm.org/D35579)
>  For backends with "tightly coupled memory", in scenarios where the data is 
> far away from text pays a good amount of penalty in terms of latency.
>  Hexagon is one such backend. The tables (both lookup and jump) which are 
> being generated are treated as globals with internal linkage and by default
>  will be placed in read only data.


Wouldn't the fix be to make the backend deal with this, then? Either by putting 
the table with the function text, or or opting out of lookup tables? It seems 
that might be a better experience for the user.


https://reviews.llvm.org/D35578



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


[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo

2017-07-19 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a subscriber: modocache.
jordan_rose added a comment.

> The addition of "${path}/.git/HEAD" at line 37 is used only once when repo is 
> initially synced "for the first time". This is because ${git_path}/logs/HEAD 
> file at line 34 for Git or Git submodule does not exist with initial repo 
> sync[.]

Hm, interesting. Unfortunately, adding more commits won't automatically force a 
reconfigure. Maybe we should consider adding //all// of these as dependencies? 
cc @modocache, who just changed some of this.


https://reviews.llvm.org/D35533



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


[PATCH] D35577: Add -flookup-tables and -fno-lookup-tables flags

2017-07-19 Thread Sumanth Gundapaneni via Phabricator via cfe-commits
sgundapa updated this revision to Diff 107317.
sgundapa added a comment.

Made the changes asked by reviewers


https://reviews.llvm.org/D35577

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/nouselookuptable.c


Index: test/CodeGen/nouselookuptable.c
===
--- /dev/null
+++ test/CodeGen/nouselookuptable.c
@@ -0,0 +1,14 @@
+// RUN: %clang -S -fno-lookup-tables %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefix=NOLOOKUP %s
+// NOLOOKUP: @foo
+// NOLOOKUP: attributes #0 = {{.*}}"no-lookup-tables"="true"{{.*}}
+
+// RUN: %clang -S %s -emit-llvm -o - | FileCheck --check-prefix=LOOKUP %s
+// RUN: %clang -S -flookup-tables %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefix=LOOKUP %s
+// LOOKUP: @foo
+// LOOKUP: attributes #0 = {{.*}}"no-lookup-tables"="false"{{.*}}
+
+void foo() {
+  return;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -652,6 +652,8 @@
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
+  Opts.NoUseLookupTables = Args.hasArg(OPT_fno_lookup_tables);
+
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.EmitSummaryIndex = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2266,6 +2266,10 @@
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (!Args.hasFlag(options::OPT_flookup_tables, 
options::OPT_fno_lookup_tables,
+true))
+CmdArgs.push_back("-fno-lookup-tables");
+
   if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
 options::OPT_fno_preserve_as_comments, true))
 CmdArgs.push_back("-fno-preserve-as-comments");
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -806,6 +806,10 @@
   Fn->addFnAttr("no-jump-tables",
 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add no-lookup-tables value.
+  Fn->addFnAttr("no-lookup-tables",
+llvm::toStringRef(CGM.getCodeGenOpts().NoUseLookupTables));
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -177,6 +177,7 @@
 CODEGENOPT(UnrollLoops   , 1, 0) ///< Control whether loops are unrolled.
 CODEGENOPT(RerollLoops   , 1, 0) ///< Control whether loops are rerolled.
 CODEGENOPT(NoUseJumpTables   , 1, 0) ///< Set when -fno-jump-tables is enabled.
+CODEGENOPT(NoUseLookupTables , 1, 0) ///< Set when -fno-lookup-tables is 
enabled.
 CODEGENOPT(UnsafeFPMath  , 1, 0) ///< Allow unsafe floating point optzns.
 CODEGENOPT(UnwindTables  , 1, 0) ///< Emit unwind tables.
 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -792,6 +792,9 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def flookup_tables : Flag<["-"], "flookup-tables">, Group;
+def fno_lookup_tables : Flag<["-"], "fno-lookup-tables">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Do not use lookup tables for lowering switches">;
 
 // Begin sanitizer flags. These should all be core options exposed in all 
driver
 // modes.


Index: test/CodeGen/nouselookuptable.c
===
--- /dev/null
+++ test/CodeGen/nouselookuptable.c
@@ -0,0 +1,14 @@
+// RUN: %clang -S -fno-lookup-tables %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefix=NOLOOKUP %s
+// NOLOOKUP: @foo
+// NOLOOKUP: attributes #0 = {{.*}}"no-lookup-tables"="true"{{.*}}
+
+// RUN: %clang -S %s -emit-llvm -o - | FileCheck --check-prefix=LOOKUP %s
+// RUN: %clang -S -flookup-tables %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefix=LOOKUP %s
+// LOOKUP: @foo
+// LOOKUP: attributes #0 = {{.*}}"no-lookup-tables"="false"{{.*}}
+
+void foo() {
+  return;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp

[PATCH] D35485: [clang-format] Fix comment levels between '}' and PPDirective

2017-07-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 107314.
krasimir added a comment.

- Adapt the fix from comment suggestion


https://reviews.llvm.org/D35485

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestComments.cpp

Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -836,6 +836,25 @@
"  int j;\n"
"}"));
 
+  EXPECT_EQ("int f(int i) {\n"
+"  if (true) {\n"
+"++i;\n"
+"  }\n"
+"  // comment\n"
+"#ifdef A\n"
+"  int j;\n"
+"#endif\n"
+"}",
+format("int f(int i) {\n"
+   "  if (true) {\n"
+   "++i;\n"
+   "  }\n"
+   "  // comment\n"
+   "#ifdef A\n"
+   "int j;\n"
+   "#endif\n"
+   "}"));
+
   // Keep the current level if there is an empty line between the comment and
   // the preprocessor directive.
   EXPECT_EQ("void f() {\n"
@@ -853,6 +872,46 @@
"  int j;\n"
"}"));
 
+  EXPECT_EQ("void f() {\n"
+"  int i;\n"
+"  return i;\n"
+"}\n"
+"// comment\n"
+"\n"
+"#ifdef A\n"
+"int i;\n"
+"#endif // A",
+format("void f() {\n"
+   "   int i;\n"
+   "  return i;\n"
+   "}\n"
+   "// comment\n"
+   "\n"
+   "#ifdef A\n"
+   "int i;\n"
+   "#endif // A"));
+
+  EXPECT_EQ("int f(int i) {\n"
+"  if (true) {\n"
+"++i;\n"
+"  }\n"
+"  // comment\n"
+"\n"
+"#ifdef A\n"
+"  int j;\n"
+"#endif\n"
+"}",
+format("int f(int i) {\n"
+   "   if (true) {\n"
+   "++i;\n"
+   "  }\n"
+   "  // comment\n"
+   "\n"
+   "#ifdef A\n"
+   "  int j;\n"
+   "#endif\n"
+   "}"));
+
   // Align with the preprocessor directive if the comment was originally aligned
   // with the preprocessor directive.
   EXPECT_EQ("void f() {\n"
@@ -867,6 +926,25 @@
"#ifdef A\n"
"  int j;\n"
"}"));
+
+  EXPECT_EQ("int f(int i) {\n"
+"  if (true) {\n"
+"++i;\n"
+"  }\n"
+"// comment\n"
+"#ifdef A\n"
+"  int j;\n"
+"#endif\n"
+"}",
+format("int f(int i) {\n"
+   "   if (true) {\n"
+   "++i;\n"
+   "  }\n"
+   "// comment\n"
+   "#ifdef A\n"
+   "  int j;\n"
+   "#endif\n"
+   "}"));
 }
 
 TEST_F(FormatTestComments, SplitsLongLinesInComments) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -486,14 +486,15 @@
 return;
   }
 
+  flushComments(isOnNewLine(*FormatTok));
+  Line->Level = InitialLevel;
   nextToken(); // Munch the closing brace.
 
   if (MacroBlock && FormatTok->is(tok::l_paren))
 parseParens();
 
   if (MunchSemi && FormatTok->Tok.is(tok::semi))
 nextToken();
-  Line->Level = InitialLevel;
   Line->MatchingOpeningBlockLineIndex = OpeningLineIndex;
   if (OpeningLineIndex != UnwrappedLine::kInvalidIndex) {
 // Update the opening line to add the forward reference as well
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35485: [clang-format] Fix comment levels between '}' and PPDirective

2017-07-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:489
 
-  nextToken(); // Munch the closing brace.
+  nextToken(InitialLevel); // Munch the closing brace.
 

djasper wrote:
> krasimir wrote:
> > djasper wrote:
> > > krasimir wrote:
> > > > djasper wrote:
> > > > > What happens if you instead change the Line->Level = InitialLevel; 
> > > > > statement from below to before this line? That seems like the more 
> > > > > intuitively correct fix.
> > > > This doesn't work since comments before the right brace haven't been 
> > > > emitted yet and would get the wrong level.
> > > So that means this seems to be the interesting case:
> > > 
> > >   void f() {
> > > DoSomething();
> > > // This was a fun function.
> > >   }
> > >   // Cool macro:
> > >   #define A a
> > > 
> > > Now, both comments are basically read when we are reading the "}", but 
> > > they should have different indentation levels. I have another suggestion, 
> > > see below.
> > Here is another breaking test in case we change `Line->Level = 
> > InitialLevel` to above this line:
> > ```
> > switch (x) {
> > default: {
> >   // Do nothing.
> > }
> > }
> > ```
> > gets reformatted as:
> > ```
> > switch (x) {
> > default: {
> > // Do nothing.
> > }
> > }
> > ```
> I think we can fix all of these cases by doing:
> 
>   flushComments(isOnNewLine(*FormatTok));
>   Line->Level = InitialLevel;
>   nextToken(); // Munch the closing brace.
> 
> (so add the first two lines here, remove Line->Level = InitialLevel; below.
Cool! Thanks!


https://reviews.llvm.org/D35485



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


[PATCH] D35617: [clangd] Allow specifying -resource-dir

2017-07-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308486: [clangd] Allow specifying -resource-dir (authored by 
krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D35617

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
@@ -216,9 +216,10 @@
   R"(,"result":[)" + Locations + R"(]})");
 }
 
-ClangdLSPServer::ClangdLSPServer(JSONOutput , bool RunSynchronously)
+ClangdLSPServer::ClangdLSPServer(JSONOutput , bool RunSynchronously,
+ llvm::Optional ResourceDir)
 : Out(Out), DiagConsumer(*this),
-  Server(CDB, DiagConsumer, FSProvider, RunSynchronously) {}
+  Server(CDB, DiagConsumer, FSProvider, RunSynchronously, ResourceDir) {}
 
 void ClangdLSPServer::run(std::istream ) {
   assert(!IsDone && "Run was called before");
Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -25,6 +25,11 @@
  llvm::cl::desc("parse on main thread"),
  llvm::cl::init(false), llvm::cl::Hidden);
 
+static llvm::cl::opt
+ResourceDir("resource-dir",
+llvm::cl::desc("directory for system clang headers"),
+llvm::cl::init(""), llvm::cl::Hidden);
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "clangd");
 
@@ -35,6 +40,9 @@
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
 
-  ClangdLSPServer LSPServer(Out, RunSynchronously);
+  llvm::Optional ResourceDirRef = None;
+  if (!ResourceDir.empty())
+ResourceDirRef = ResourceDir;
+  ClangdLSPServer LSPServer(Out, RunSynchronously, ResourceDirRef);
   LSPServer.run(std::cin);
 }
Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h
@@ -15,6 +15,7 @@
 #include "Path.h"
 #include "Protocol.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/Optional.h"
 
 namespace clang {
 namespace clangd {
@@ -25,7 +26,8 @@
 /// dispatch and ClangdServer together.
 class ClangdLSPServer {
 public:
-  ClangdLSPServer(JSONOutput , bool RunSynchronously);
+ ClangdLSPServer(JSONOutput , bool RunSynchronously,
+ llvm::Optional ResourceDir);
 
   /// Run LSP server loop, receiving input for it from \p In. \p In must be
   /// opened in binary mode. Output will be written using Out variable passed 
to


Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
@@ -216,9 +216,10 @@
   R"(,"result":[)" + Locations + R"(]})");
 }
 
-ClangdLSPServer::ClangdLSPServer(JSONOutput , bool RunSynchronously)
+ClangdLSPServer::ClangdLSPServer(JSONOutput , bool RunSynchronously,
+ llvm::Optional ResourceDir)
 : Out(Out), DiagConsumer(*this),
-  Server(CDB, DiagConsumer, FSProvider, RunSynchronously) {}
+  Server(CDB, DiagConsumer, FSProvider, RunSynchronously, ResourceDir) {}
 
 void ClangdLSPServer::run(std::istream ) {
   assert(!IsDone && "Run was called before");
Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -25,6 +25,11 @@
  llvm::cl::desc("parse on main thread"),
  llvm::cl::init(false), llvm::cl::Hidden);
 
+static llvm::cl::opt
+ResourceDir("resource-dir",
+llvm::cl::desc("directory for system clang headers"),
+llvm::cl::init(""), llvm::cl::Hidden);
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "clangd");
 
@@ -35,6 +40,9 @@
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
 
-  ClangdLSPServer LSPServer(Out, RunSynchronously);
+  llvm::Optional ResourceDirRef = None;
+  if (!ResourceDir.empty())
+ResourceDirRef = ResourceDir;
+  ClangdLSPServer LSPServer(Out, RunSynchronously, ResourceDirRef);
   LSPServer.run(std::cin);
 }
Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
===
--- 

[clang-tools-extra] r308486 - [clangd] Allow specifying -resource-dir

2017-07-19 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed Jul 19 08:43:35 2017
New Revision: 308486

URL: http://llvm.org/viewvc/llvm-project?rev=308486=rev
Log:
[clangd] Allow specifying -resource-dir

Summary: This patch allows clangd to specify its -resource-dir.

Reviewers: bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=308486=308485=308486=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Jul 19 08:43:35 2017
@@ -216,9 +216,10 @@ void ClangdLSPServer::LSPProtocolCallbac
   R"(,"result":[)" + Locations + R"(]})");
 }
 
-ClangdLSPServer::ClangdLSPServer(JSONOutput , bool RunSynchronously)
+ClangdLSPServer::ClangdLSPServer(JSONOutput , bool RunSynchronously,
+ llvm::Optional ResourceDir)
 : Out(Out), DiagConsumer(*this),
-  Server(CDB, DiagConsumer, FSProvider, RunSynchronously) {}
+  Server(CDB, DiagConsumer, FSProvider, RunSynchronously, ResourceDir) {}
 
 void ClangdLSPServer::run(std::istream ) {
   assert(!IsDone && "Run was called before");

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=308486=308485=308486=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Wed Jul 19 08:43:35 2017
@@ -15,6 +15,7 @@
 #include "Path.h"
 #include "Protocol.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/Optional.h"
 
 namespace clang {
 namespace clangd {
@@ -25,7 +26,8 @@ class JSONOutput;
 /// dispatch and ClangdServer together.
 class ClangdLSPServer {
 public:
-  ClangdLSPServer(JSONOutput , bool RunSynchronously);
+ ClangdLSPServer(JSONOutput , bool RunSynchronously,
+ llvm::Optional ResourceDir);
 
   /// Run LSP server loop, receiving input for it from \p In. \p In must be
   /// opened in binary mode. Output will be written using Out variable passed 
to

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=308486=308485=308486=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Jul 19 08:43:35 2017
@@ -25,6 +25,11 @@ static llvm::cl::opt
  llvm::cl::desc("parse on main thread"),
  llvm::cl::init(false), llvm::cl::Hidden);
 
+static llvm::cl::opt
+ResourceDir("resource-dir",
+llvm::cl::desc("directory for system clang headers"),
+llvm::cl::init(""), llvm::cl::Hidden);
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "clangd");
 
@@ -35,6 +40,9 @@ int main(int argc, char *argv[]) {
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
 
-  ClangdLSPServer LSPServer(Out, RunSynchronously);
+  llvm::Optional ResourceDirRef = None;
+  if (!ResourceDir.empty())
+ResourceDirRef = ResourceDir;
+  ClangdLSPServer LSPServer(Out, RunSynchronously, ResourceDirRef);
   LSPServer.run(std::cin);
 }


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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-07-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11846
   // an address space.
   if (T.getAddressSpace() != 0) {
 // OpenCL allows function arguments declared to be an array of a type

yaxunl wrote:
> Anastasia wrote:
> > Could we use `LangAS::Default` here too?
> done
Sorry, I wasn't clear. I think we could have:

  if (T.getAddressSpace() != LangAS::Default && T.getAddressSpace() != 
LangAS::opencl_private)

and then original condition. It is a bit clearer I think.



Comment at: lib/Sema/SemaType.cpp:6969
 
+  if (state.getSema().getLangOpts().OpenCL &&
+  !hasOpenCLAddressSpace && type.getAddressSpace() == 0 &&

yaxunl wrote:
> Anastasia wrote:
> > Would it be nicer to not append any address space at all neither here nor 
> > down at the end of this function and keep it default instead until the 
> > Codegen? If it's doable I would very much prefer that. It seems like it 
> > would make the implementation potentially a bit cleaner to understand and 
> > easier to improve semantical analysis. See one example of improving 
> > original type printing in my comment to the test below.
> > 
> > Also there are at least these 3 related bugs open currently:
> > https://bugs.llvm.org//show_bug.cgi?id=33418
> > https://bugs.llvm.org//show_bug.cgi?id=33419
> > https://bugs.llvm.org//show_bug.cgi?id=33420
> > 
> > Does your change address any of those?
> On the contrary, I think using default address space for automatic variable 
> and function parameter will cause ambiguity and inconsistency in AST, making 
> it more difficult to understand and process, and making some bug (e.g. 
> https://bugs.llvm.org//show_bug.cgi?id=33419) unfixable. For example, 
> `private int f(void)` and `int f(void)` will be identical in AST, therefore 
> we cannot diagnose `private int f(void)`.
> 
> With current representation I am able to fix the 3 bugs. I will update the 
> diff.
I don't see why?

`private int f(void)` -> will have an address space attribute in AST as it is 
provided explicitly.

`int f(void) ` -> will have no address space attribute because it's not 
provided explicitly and not attached implicitly either.

All I was asking is  not to deduce the address space here if it's not specified 
explicitly until later step when we need to put it in the IR.



Comment at: test/SemaOpenCL/access-qualifier.cl:23
 #else
-void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 
'read_write' can not be used for '__read_write image1d_t' prior to OpenCL 
version 2.0}}
+void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 
'read_write' can not be used for '__private __read_write image1d_t' prior to 
OpenCL version 2.0}}
 #endif

yaxunl wrote:
> Anastasia wrote:
> > Ok, I think that here it would be less confusing not to add any address 
> > space since it's missing in the original source.
> Although it looks strange at first sight, `__private __read_write image1d_t` 
> is the true type of the argument. The function argument is allocated from 
> stack and is an l-value. If we take its address, we get a private pointer.
Yes, it is a true type in the Clang internal representation indeed, but not in 
the original source though. Here we are giving the feedback about the source 
code so it's nicer to keep it as close to the original as possible. But we are 
doing similar "magic" for blocks, images and other places, so it's not that 
critical at the end. Just if it can be avoided it would be better.


https://reviews.llvm.org/D35082



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


[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 107310.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Changed fallthrough for Craig


https://reviews.llvm.org/D35572

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -963,8 +963,8 @@
   //  401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
   //  821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,
   //  titan, rs64.
-  bool setCPU(const std::string ) override {
-bool CPUKnown = llvm::StringSwitch(Name)
+  bool isValidCPUName(StringRef Name) const override {
+return llvm::StringSwitch(Name)
   .Case("generic", true)
   .Case("440", true)
   .Case("450", true)
@@ -1014,10 +1014,12 @@
   .Case("powerpc64le", true)
   .Case("ppc64le", true)
   .Default(false);
+  }
 
+  bool setCPU(const std::string ) override {
+bool CPUKnown = isValidCPUName(Name);
 if (CPUKnown)
   CPU = Name;
-
 return CPUKnown;
   }
 
@@ -2006,6 +2008,9 @@
 // FIXME: implement
 return TargetInfo::CharPtrBuiltinVaList;
   }
+  bool isValidCPUName(StringRef Name) const override {
+return StringToCudaArch(Name) != CudaArch::UNKNOWN;
+  }
   bool setCPU(const std::string ) override {
 GPU = StringToCudaArch(Name);
 return GPU != CudaArch::UNKNOWN;
@@ -2367,6 +2372,13 @@
   .Default(GK_NONE);
   }
 
+  bool isValidCPUName(StringRef Name) const override {
+if (getTriple().getArch() == llvm::Triple::amdgcn)
+  return GK_NONE !=  parseAMDGCNName(Name);
+else
+  return GK_NONE !=  parseR600Name(Name);
+  }
+
   bool setCPU(const std::string ) override {
 if (getTriple().getArch() == llvm::Triple::amdgcn)
   GPU = parseAMDGCNName(Name);
@@ -2873,6 +2885,87 @@
 //@}
   } 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_Pentium3M:
+case CK_PentiumM:
+case CK_Yonah:
+case CK_C3_2:
+case CK_Pentium4:
+case CK_Pentium4M:
+case CK_Lakemont:
+case CK_Prescott:
+case CK_K6:
+case CK_K6_2:
+case CK_K6_3:
+case CK_Athlon:
+case CK_AthlonThunderbird:
+case CK_Athlon4:
+case CK_AthlonXP:
+case CK_AthlonMP:
+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_Athlon64:
+case CK_Athlon64SSE3:
+case CK_AthlonFX:
+case CK_K8:
+case CK_K8SSE3:
+case CK_Opteron:
+case CK_OpteronSSE3:
+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");
+  }
+
   CPUKind getCPUKind(StringRef CPU) const {
 return llvm::StringSwitch(CPU)
 .Case("i386", CK_i386)
@@ -3053,6 +3146,7 @@
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,
  const std::vector ) const override;
+  bool isValidFeatureName(StringRef Name) const override;
   bool hasFeature(StringRef Feature) const override;
   bool handleTargetFeatures(std::vector ,
 DiagnosticsEngine ) override;
@@ -3066,87 +3160,13 @@
   return "no-mmx";
 return "";
   }
-  bool setCPU(const std::string ) override {
-CPU = getCPUKind(Name);
 
-// 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 (CPU) {
-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:
-

[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-19 Thread Sumanth Gundapaneni via Phabricator via cfe-commits
sgundapa added a comment.

I will try to address the concerns here:

> What exactly is the motivation? I'm trying to narrow down the justification 
> for adding yet more flags.

(I just typed this message in https://reviews.llvm.org/D35579)
For backends with "tightly coupled memory", in scenarios where the data is far 
away from text pays a good amount of penalty in terms of latency.
Hexagon is one such backend. The tables (both lookup and jump) which are being 
generated are treated as globals with internal linkage and by default
will be placed in read only data.

Interestingly when programmers specify the command line flag 
"-fno-jump-tables", they assume there is no data that goes in to other sections.
In case of llvm, the attribute "no-jump-tables" has no effect on simplifyCFG 
which generates the lookup table. This leads me to introduce "no-lookup-tables"

> Either way, it sounds like "-fno-switch-tables" is just a synonym for the 
> (soon-to-be-)existing options "-fno-jump-tables -fno-lookup-tables" and 
> therefore doesn't need to exist as a separate option

Ideally I want to rename fno-jump-tables to fno-switch-tables.

> LLVM backends can opt out of these kinds of tables if they're not suitable 
> for the target, but why would a Clang user want to do it?

Often TCM memory is small enough and this needs support for both cases(generate 
tables and do not generate tables)


https://reviews.llvm.org/D35578



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


Re: [PATCH v3] [PPC64]: Add support for Swift calling convention

2017-07-19 Thread Adrian Prantl via cfe-commits

> On Jun 21, 2017, at 11:32 PM, Andrew Jeffery  wrote:
> 
> For the tests I've extracted the int5 and int8 cases to cater for
> different alignments for different platform ABIs. For Linux on POWER the
> 5 and 8 element vectors must be naturally aligned with respect to the
> total "soft" vector size, despite being represented as an aggregate.
> Specifically, the patch caters for the following differences in
> supporting powerpc64le-unknown-linux:
> 
>   $ diff -u test/CodeGen/64bit-swiftcall.c test/CodeGen/ppc64-swiftcall.c
>   --- test/CodeGen/64bit-swiftcall.c  2017-04-20 17:14:59.797963820 +0930
>   +++ test/CodeGen/ppc64-swiftcall.c  2017-04-20 17:15:11.621965118 +0930
>   @@ -1,7 +1,6 @@
>   -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 
> -emit-llvm -o - %s | FileCheck %s
>   -// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm 
> -o - %s | FileCheck %s
>   +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux -emit-llvm -o - %s | 
> FileCheck %s
> 
>   -// REQUIRES: aarch64-registered-target,x86-registered-target
>   +// REQUIRES: powerpc-registered-target
> 
>#define SWIFTCALL __attribute__((swiftcall))
>#define OUT __attribute__((swift_indirect_result))
>   @@ -370,8 +369,8 @@
> 
>TEST(int8)
>// CHECK-LABEL: define {{.*}} @return_int8()
>   -// CHECK:   [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 16
>   +// CHECK:   [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 32
>// CHECK:   [[VAR:%.*]] = alloca [[REC]], align
>// CHECK:   store
>// CHECK:   load
>// CHECK:   store
>   @@ -414,8 +413,8 @@
> 
>TEST(int5)
>// CHECK-LABEL: define {{.*}} @return_int5()
>   -// CHECK:   [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 16
>   +// CHECK:   [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 32
>// CHECK:   [[VAR:%.*]] = alloca [[REC]], align
>// CHECK:   store
>// CHECK:   load
>// CHECK:   store
> 
> Despite some duplication, the advantage of this approach over using
> pattern matching for alignment in 64bit-swiftcall.c is that we ensure
> each platform is using the expected alignment but without duplicating
> the entirety of 64bit-swiftcall.c.

You could also write all in one file and use invoke FileCheck with 
--check-prefix=CHECK-PPC64 to have a second set of CHECK-lines in the same 
input file.

-- adrian
> 
> Signed-off-by: Andrew Jeffery 
> ---
> 
> Hello,
> 
> The only change in v3 is rebasing it on top upstream HEAD, fixing a conflict 
> in
> one of the lit REQUIRES lines.
> 
> Ulrich, Hal, Bill: I've Cc'ed you as you were fingered by the blame output. As
> some background I sent the patch several months ago but it hasn't got much
> traction aside from a LGTM from Adrian (thanks!). I'm hoping it gets a bit 
> more
> attention as without it we get build failures for Swift on POWER, which is
> in-turn blocking some CI efforts. 
> 
> Cheers,
> 
> Andrew
> 
> lib/Basic/Targets.cpp |  11 ++
> lib/CodeGen/TargetInfo.cpp|  14 ++-
> test/CodeGen/64bit-swiftcall-extvec-agg-align16.c | 117 ++
> test/CodeGen/64bit-swiftcall-extvec-agg-align32.c | 116 +
> test/CodeGen/64bit-swiftcall.c|  93 +
> 5 files changed, 258 insertions(+), 93 deletions(-)
> create mode 100644 test/CodeGen/64bit-swiftcall-extvec-agg-align16.c
> create mode 100644 test/CodeGen/64bit-swiftcall-extvec-agg-align32.c
> 
> diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
> index e23a93e..54b5911 100644
> --- a/lib/Basic/Targets.cpp
> +++ b/lib/Basic/Targets.cpp
> @@ -1753,6 +1753,17 @@ public:
> }
> return false;
>   }
> +
> +  CallingConvCheckResult checkCallingConvention(CallingConv CC) const 
> override {
> +switch (CC) {
> +case CC_C:
> +case CC_Swift:
> +return CCCR_OK;
> +default:
> +break;
> +}
> +return CCCR_Warning;
> +  }
> };
> 
> class DarwinPPC32TargetInfo : public DarwinTargetInfo {
> diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
> index 8d00e05..a82cd24 100644
> --- a/lib/CodeGen/TargetInfo.cpp
> +++ b/lib/CodeGen/TargetInfo.cpp
> @@ -4179,7 +4179,7 @@ 
> PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction ,
> 
> namespace {
> /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
> -class PPC64_SVR4_ABIInfo : public ABIInfo {
> +class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
> public:
>   enum ABIKind {
> ELFv1 = 0,
> @@ -4223,7 +4223,7 @@ private:
> public:
>   PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes , ABIKind Kind, bool HasQPX,
>  bool SoftFloatABI)
> -  : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
> +  : SwiftABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
> IsSoftFloatABI(SoftFloatABI) {}
> 
>   bool isPromotableTypeForABI(QualType Ty) const;
> @@ -4266,6 +4266,16 @@ public:
> 
>   Address EmitVAArg(CodeGenFunction 

[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2012
+  } else if (CurrV.getObjKind() == RetEffect::GenericC) {
+if (Sym->getType().isNull()) {
+  os << " returns an object with a ";

I don't think this can happen. Symbols always have a type, see 
`isValidTypeForSymbol()`. These branches can be removed from the surrounding 
code as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D35613



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


[PATCH] D35617: [clangd] Allow specifying -resource-dir

2017-07-19 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D35617



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


[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-07-19 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

In https://reviews.llvm.org/D35538#814008, @compnerd wrote:

> Can you please add a test that shows that the AEABI functions are not given 
> the wrong CC?  Also, can you show that if someone also passes `-meabi=gnu` 
> with a VFP target, that we still annotate the functions with the differing CC 
> (since that should prefer the GNU functions over the AEABI functions).


Thanks for the comment. Can I just check my understanding before I proceed? In 
particular I think I need a bit more information about what -meabi=gnu is 
supposed to do. 
I think tests to make sure the the floating point helper functions always use 
AAPCS is a good idea and I'll start working on that. At the moment I'm trying 
to work out the best way of doing this as this is all done in the ARM backend 
in llvm. My current favorite options are to compile and check the assembly in 
the clang test suite, or just check that the calls to the floating point helper 
functions are not emitted by clang and add a test to llvm to make sure that 
they have the correct calling convention. I'm currently tending towards the 
second option.

With respect to -meabi=gnu, this was added in clang under r252463 and llvm 
r252462. From tracing through the flag through ARMTargetMachine.cpp and 
ARMISelLowering.cpp it seems like all this flag does in llvm is to use memcpy, 
memmove and memset instead of __aeabi_memcpy, __aeabi_memmove and 
__aeabi_memset respectively. These functions always use AAPCS calling 
convention, but as they do not take any floating point parameters it doesn't 
matter either way. As it stands the option won't have any effect on the use of 
other library functions for example doing a double precision divide with 
-meabi=gnu results in a call to __aeabi_ddiv. Does this match your expectation 
of what -meabi=gnu is supposed to do? If it doesn't can you point me at a 
description?  All that I could find externally was the -meabi option in the GNU 
assembler (there is no equivalent gcc option), the value of -meabi=gnu maps to 
EF_ARM_ABI_UNKNOWN which is intended for generation of pre ARM ABI objects.

I'll be on vacation for the next 3 days, I'll pick this back up next week.


https://reviews.llvm.org/D35538



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


[PATCH] D35485: [clang-format] Fix comment levels between '}' and PPDirective

2017-07-19 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:489
 
-  nextToken(); // Munch the closing brace.
+  nextToken(InitialLevel); // Munch the closing brace.
 

krasimir wrote:
> djasper wrote:
> > krasimir wrote:
> > > djasper wrote:
> > > > What happens if you instead change the Line->Level = InitialLevel; 
> > > > statement from below to before this line? That seems like the more 
> > > > intuitively correct fix.
> > > This doesn't work since comments before the right brace haven't been 
> > > emitted yet and would get the wrong level.
> > So that means this seems to be the interesting case:
> > 
> >   void f() {
> > DoSomething();
> > // This was a fun function.
> >   }
> >   // Cool macro:
> >   #define A a
> > 
> > Now, both comments are basically read when we are reading the "}", but they 
> > should have different indentation levels. I have another suggestion, see 
> > below.
> Here is another breaking test in case we change `Line->Level = InitialLevel` 
> to above this line:
> ```
> switch (x) {
> default: {
>   // Do nothing.
> }
> }
> ```
> gets reformatted as:
> ```
> switch (x) {
> default: {
> // Do nothing.
> }
> }
> ```
I think we can fix all of these cases by doing:

  flushComments(isOnNewLine(*FormatTok));
  Line->Level = InitialLevel;
  nextToken(); // Munch the closing brace.

(so add the first two lines here, remove Line->Level = InitialLevel; below.


https://reviews.llvm.org/D35485



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


[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-19 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

This looks pretty good. There are some minor comments in line.

One thing that is missing: tests for the new diagnostic text. Can you add new 
tests that specifically test for the new diagnostic text with // 
expected-warning {{ ... }}}. These should probably go in retain-release.m.




Comment at: include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h:150
+/// Indicates that the tracked object is a generic C object.
+GenericC
   };

I would suggest calling this just "Generalized" to avoid confusion with 
generics and because it might not be C (it could, for example, be C++).



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:1343
 return RetEffect::MakeOwned(RetEffect::CF);
+  else if (hasRCAnnotation(D, "give"))
+return RetEffect::MakeOwned(RetEffect::GenericC);

I would suggest having the annotation be "rc_ownership_returns_retained". This 
is consistent  with the CF and NS attribute names. I wouldn't be too concerned 
about this being verbose since users of the annotation in ISL will still use 
"__give".



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:1368
   Template->addArg(AF, parm_idx, DecRefMsg);
-else if (pd->hasAttr())
+else if (pd->hasAttr() || hasRCAnnotation(pd, "take"))
   Template->addArg(AF, parm_idx, DecRef);

I would suggest having the annotation be "rc_ownership_consumed".


Repository:
  rL LLVM

https://reviews.llvm.org/D35613



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


[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo

2017-07-19 Thread MinSeong Kim via Phabricator via cfe-commits
minseong.kim added a comment.

Thanks for the reviewing this patch. Please correct if I am wrong.

The addition of "${path}/.git/HEAD" at line 37 is used only once when repo is 
initially synced "for the first time". This is because ${git_path}/logs/HEAD 
file at line 34 for Git or Git submodule does not exist with initial repo sync 
and therefore no generation of SVNVersion.inc  which is referenced by --version 
option, resulting null for the revision values of clang and llvm. After the 
second repo sync, the first file  "${git_path}/logs/HEAD" will be created and 
can be used to generate "SVNVersion.inc". This enables correct version 
information to be displayed even if new changes are merged.




Comment at: lib/Basic/CMakeLists.txt:17
 
 macro(find_first_existing_vc_file out_var path)
   set(git_path "${path}/.git")

hintonda wrote:
> LLVM already has a version of find_first_existing_vc_file in 
> llvm/include/llvm/Support/CMakelists.txt.
> 
> Would it make sense move it to an llvm module and reuse it in clang?
Thanks for the suggestion. 
My understanding is that "llvm/include/llvm/Support/CMakeLists.txt" is used to 
generate VCSRevision.h which is used by llvm-specific modules such as opt, not 
clang. Furthermore find_first_existing_vc_file function in 
llvm/include/llvm/Support/CMakeLists.txt does not handle the version info 
either.


https://reviews.llvm.org/D35533



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


[clang-tools-extra] r308479 - Clear release notes for 6.0.0

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 07:15:27 2017
New Revision: 308479

URL: http://llvm.org/viewvc/llvm-project?rev=308479=rev
Log:
Clear release notes for 6.0.0

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=308479=308478=308479=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Jul 19 07:15:27 2017
@@ -1,5 +1,5 @@
 ===
-Extra Clang Tools 5.0.0 (In-Progress) Release Notes
+Extra Clang Tools 6.0.0 (In-Progress) Release Notes
 ===
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 5.0.0. Here we describe the status of the Extra Clang Tools in
+Clang release 6.0.0. Here we describe the status of the Extra Clang Tools in
 some detail, including major improvements from the previous release and new
 feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
@@ -32,7 +32,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Extra Clang Tools 5.0.0?
+What's New in Extra Clang Tools 6.0.0?
 ==
 
 Some of the major new features and improvements to Extra Clang Tools are listed
@@ -57,126 +57,7 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- New `android-cloexec-creat
-  `_ 
check
-
-  Detect usage of ``creat()``.
-
-- New `android-cloexec-open
-  `_ 
check
-
-  Checks if the required file flag ``O_CLOEXEC`` exists in ``open()``,
-  ``open64()`` and ``openat()``.
-
-- New `android-cloexec-fopen
-  `_ 
check
-
-  Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
-
-- New `android-cloexec-socket
-  
`_ 
check
-
-  Checks if the required file flag ``SOCK_CLOEXEC`` is present in the argument 
of
-  ``socket()``.
-
-- New `bugprone-suspicious-memset-usage
-  
`_
 check
-
-  Finds ``memset()`` calls with potential mistakes in their arguments.
-  Replaces and extends the ``google-runtime-memset`` check.
-
-- New `bugprone-undefined-memory-manipulation
-  
`_
 check
-
-  Finds calls of memory manipulation functions ``memset()``, ``memcpy()`` and
-  ``memmove()`` on not TriviallyCopyable objects resulting in undefined 
behavior.
-
-- New `cert-dcl21-cpp
-  `_ check
-
-  Checks if the overloaded postfix ``operator++/--`` returns a constant object.
-
-- New `cert-dcl58-cpp
-  `_ check
-
-  Finds modification of the ``std`` or ``posix`` namespace.
-
-- Improved `cppcoreguidelines-no-malloc
-  
`_
 check
-
-  Allow custom memory management functions to be considered as well.
-
-- New `misc-forwarding-reference-overload
-  
`_
 check
-
-  Finds perfect forwarding constructors that can unintentionally hide copy or 
move constructors.
-
-- New `misc-lambda-function-name 
`_
 check
-
-  Finds uses of ``__func__`` or ``__FUNCTION__`` inside lambdas.
-
-- New `modernize-replace-random-shuffle
-  
`_
 check
-
-  Finds and fixes usage of ``std::random_shuffle`` as the function has been 
removed from C++17.
-
-- New `modernize-return-braced-init-list
-  
`_
 check
-
-  Finds and replaces 

r308478 - Clear release notes for 6.0.0

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 07:14:07 2017
New Revision: 308478

URL: http://llvm.org/viewvc/llvm-project?rev=308478=rev
Log:
Clear release notes for 6.0.0

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=308478=308477=308478=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jul 19 07:14:07 2017
@@ -1,5 +1,5 @@
 ===
-Clang 5.0.0 (In-Progress) Release Notes
+Clang 6.0.0 (In-Progress) Release Notes
 ===
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Clang C/C++/Objective-C
-frontend, part of the LLVM Compiler Infrastructure, release 5.0.0. Here we
+frontend, part of the LLVM Compiler Infrastructure, release 6.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
 general LLVM release notes, see `the LLVM
@@ -36,7 +36,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Clang 5.0.0?
+What's New in Clang 6.0.0?
 ==
 
 Some of the major new features and improvements to Clang are listed
@@ -52,11 +52,7 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
--  -Wcast-qual was implemented for C++. C-style casts are now properly
-   diagnosed.
-
--  -Wunused-lambda-capture warns when a variable explicitly captured
-   by a lambda is not used in the body of the lambda.
+-  ...
 
 New Compiler Flags
 --
@@ -69,9 +65,7 @@ Deprecated Compiler Flags
 The following options are deprecated and ignored. They will be removed in
 future versions of Clang.
 
-- -fslp-vectorize-aggressive used to enable the BB vectorizing pass. They have 
been superseeded
-  by the normal SLP vectorizer.
-- -fno-slp-vectorize-aggressive used to be the default behavior of clang.
+- ...
 
 New Pragmas in Clang
 ---
@@ -82,9 +76,7 @@ Clang now supports the ...
 Attribute Changes in Clang
 --
 
--  The ``overloadable`` attribute now allows at most one function with a given
-   name to lack the ``overloadable`` attribute. This unmarked function will not
-   have its name mangled.
+- ...
 
 Windows Support
 ---
@@ -147,49 +139,7 @@ AST Matchers
 clang-format
 
 
-* Option **BreakBeforeInheritanceComma** added to break before ``:`` and ``,`` 
 in case of
-  multiple inheritance in a class declaration. Enabled by default in the 
Mozilla coding style.
-
-  +-++
-  | true| false  |
-  +=++
-  | .. code-block:: c++ | .. code-block:: c++|
-  | ||
-  |   class MyClass |   class MyClass : public X, public Y { |
-  |   : public X|   };   |
-  |   , public Y {  ||
-  |   };||
-  +-++
-
-* Align block comment decorations.
-
-  +--+-+
-  | Before   | After   |
-  +==+=+
-  |  .. code-block:: c++ | .. code-block:: c++ |
-  |  | |
-  |/* line 1 |   /* line 1 |
-  |  * line 2|* line 2 |
-  | */   |*/   |
-  +--+-+
-
-* The :doc:`ClangFormatStyleOptions` documentation provides detailed examples 
for most options.
-
-* Namespace end comments are now added or updated automatically.
-
-  +-+-+
-  | Before  | After   |
-  +=+=+
-  | .. code-block:: c++ | .. code-block:: c++ |
-  | | |
-  |   namespace A { |   namespace A { |
-  |   int i;|   int i;|
-  |   int j;|   int j;|
-  |   } | 

[libunwind] r308472 - Drop 'svn' suffix from version number.

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 07:04:52 2017
New Revision: 308472

URL: http://llvm.org/viewvc/llvm-project?rev=308472=rev
Log:
Drop 'svn' suffix from version number.

Modified:
libunwind/branches/release_50/CMakeLists.txt

Modified: libunwind/branches/release_50/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_50/CMakeLists.txt?rev=308472=308471=308472=diff
==
--- libunwind/branches/release_50/CMakeLists.txt (original)
+++ libunwind/branches/release_50/CMakeLists.txt Wed Jul 19 07:04:52 2017
@@ -79,7 +79,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 5.0.0svn)
+  set(PACKAGE_VERSION 5.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libcxx] r308471 - Drop 'svn' suffix from version number.

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 07:04:38 2017
New Revision: 308471

URL: http://llvm.org/viewvc/llvm-project?rev=308471=rev
Log:
Drop 'svn' suffix from version number.

Modified:
libcxx/branches/release_50/CMakeLists.txt

Modified: libcxx/branches/release_50/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/CMakeLists.txt?rev=308471=308470=308471=diff
==
--- libcxx/branches/release_50/CMakeLists.txt (original)
+++ libcxx/branches/release_50/CMakeLists.txt Wed Jul 19 07:04:38 2017
@@ -23,7 +23,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION 5.0.0svn)
+  set(PACKAGE_VERSION 5.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libcxxabi] r308470 - Drop 'svn' suffix from version number.

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 07:04:19 2017
New Revision: 308470

URL: http://llvm.org/viewvc/llvm-project?rev=308470=rev
Log:
Drop 'svn' suffix from version number.

Modified:
libcxxabi/branches/release_50/CMakeLists.txt

Modified: libcxxabi/branches/release_50/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_50/CMakeLists.txt?rev=308470=308469=308470=diff
==
--- libcxxabi/branches/release_50/CMakeLists.txt (original)
+++ libcxxabi/branches/release_50/CMakeLists.txt Wed Jul 19 07:04:19 2017
@@ -21,7 +21,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxxabi CXX C)
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 5.0.0svn)
+  set(PACKAGE_VERSION 5.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


Re: [libcxx] r308468 - Update _LIBCPP_VERSION and the version in CMakeLists to 6.0

2017-07-19 Thread Hans Wennborg via cfe-commits
Eric or Marshall, can you double check that I got this right?

Thanks,
Hans

On Wed, Jul 19, 2017 at 3:57 PM, Hans Wennborg via cfe-commits
 wrote:
> Author: hans
> Date: Wed Jul 19 06:57:10 2017
> New Revision: 308468
>
> URL: http://llvm.org/viewvc/llvm-project?rev=308468=rev
> Log:
> Update _LIBCPP_VERSION and the version in CMakeLists to 6.0
>
> Modified:
> libcxx/trunk/CMakeLists.txt
> libcxx/trunk/include/__config
> libcxx/trunk/include/__libcpp_version
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=308468=308467=308468=diff
> ==
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Wed Jul 19 06:57:10 2017
> @@ -23,7 +23,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
>project(libcxx CXX C)
>
>set(PACKAGE_NAME libcxx)
> -  set(PACKAGE_VERSION 5.0.0svn)
> +  set(PACKAGE_VERSION 6.0.0svn)
>set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
>set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
>
>
> Modified: libcxx/trunk/include/__config
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=308468=308467=308468=diff
> ==
> --- libcxx/trunk/include/__config (original)
> +++ libcxx/trunk/include/__config Wed Jul 19 06:57:10 2017
> @@ -33,7 +33,7 @@
>  #define _GNUC_VER_NEW 0
>  #endif
>
> -#define _LIBCPP_VERSION 5000
> +#define _LIBCPP_VERSION 6000
>
>  #ifndef _LIBCPP_ABI_VERSION
>  #define _LIBCPP_ABI_VERSION 1
>
> Modified: libcxx/trunk/include/__libcpp_version
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__libcpp_version?rev=308468=308467=308468=diff
> ==
> --- libcxx/trunk/include/__libcpp_version (original)
> +++ libcxx/trunk/include/__libcpp_version Wed Jul 19 06:57:10 2017
> @@ -1 +1 @@
> -5000
> +6000
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r308468 - Update _LIBCPP_VERSION and the version in CMakeLists to 6.0

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 06:57:10 2017
New Revision: 308468

URL: http://llvm.org/viewvc/llvm-project?rev=308468=rev
Log:
Update _LIBCPP_VERSION and the version in CMakeLists to 6.0

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/include/__config
libcxx/trunk/include/__libcpp_version

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=308468=308467=308468=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Wed Jul 19 06:57:10 2017
@@ -23,7 +23,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION 5.0.0svn)
+  set(PACKAGE_VERSION 6.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=308468=308467=308468=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Jul 19 06:57:10 2017
@@ -33,7 +33,7 @@
 #define _GNUC_VER_NEW 0
 #endif
 
-#define _LIBCPP_VERSION 5000
+#define _LIBCPP_VERSION 6000
 
 #ifndef _LIBCPP_ABI_VERSION
 #define _LIBCPP_ABI_VERSION 1

Modified: libcxx/trunk/include/__libcpp_version
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__libcpp_version?rev=308468=308467=308468=diff
==
--- libcxx/trunk/include/__libcpp_version (original)
+++ libcxx/trunk/include/__libcpp_version Wed Jul 19 06:57:10 2017
@@ -1 +1 @@
-5000
+6000


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


[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-19 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier added a comment.

In https://reviews.llvm.org/D35578#813629, @Quuxplusone wrote:

> If the goal is fine-grained control over the heuristics for compiling switch 
> statements, perhaps one should enumerate all the possible ways to lower 
> switch statements --- jump-tables, lookup-tables, if-trees, if-chains, 
> (more?) --- and add a separate flag for each of them.


In general, I would argue against such an approach without good justification.  
More is not always better as exposing such fine grain control is going to place 
a maintenance burden on the compiler developers with minimal improvement from 
the users perspective.


https://reviews.llvm.org/D35578



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


[clang-tools-extra] r308467 - Bump docs version to 6.0

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 06:51:07 2017
New Revision: 308467

URL: http://llvm.org/viewvc/llvm-project?rev=308467=rev
Log:
Bump docs version to 6.0

Modified:
clang-tools-extra/trunk/docs/conf.py

Modified: clang-tools-extra/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/conf.py?rev=308467=308466=308467=diff
==
--- clang-tools-extra/trunk/docs/conf.py (original)
+++ clang-tools-extra/trunk/docs/conf.py Wed Jul 19 06:51:07 2017
@@ -49,9 +49,9 @@ copyright = u'2007-%d, The Clang Team' %
 # built documents.
 #
 # The short version.
-version = '5'
+version = '6'
 # The full version, including alpha/beta/rc tags.
-release = '5'
+release = '6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


r308466 - Bump docs version to 6.0

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 06:50:27 2017
New Revision: 308466

URL: http://llvm.org/viewvc/llvm-project?rev=308466=rev
Log:
Bump docs version to 6.0

Modified:
cfe/trunk/docs/analyzer/conf.py
cfe/trunk/docs/conf.py

Modified: cfe/trunk/docs/analyzer/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/conf.py?rev=308466=308465=308466=diff
==
--- cfe/trunk/docs/analyzer/conf.py (original)
+++ cfe/trunk/docs/analyzer/conf.py Wed Jul 19 06:50:27 2017
@@ -49,9 +49,9 @@ copyright = u'2013-%d, Analyzer Team' %
 # built documents.
 #
 # The short version.
-version = '5'
+version = '6'
 # The full version, including alpha/beta/rc tags.
-release = '5'
+release = '6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

Modified: cfe/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/conf.py?rev=308466=308465=308466=diff
==
--- cfe/trunk/docs/conf.py (original)
+++ cfe/trunk/docs/conf.py Wed Jul 19 06:50:27 2017
@@ -49,9 +49,9 @@ copyright = u'2007-%d, The Clang Team' %
 # built documents.
 #
 # The short version.
-version = '5'
+version = '6'
 # The full version, including alpha/beta/rc tags.
-release = '5'
+release = '6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


[libunwind] r308465 - Bump docs version to 6.0

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 06:49:39 2017
New Revision: 308465

URL: http://llvm.org/viewvc/llvm-project?rev=308465=rev
Log:
Bump docs version to 6.0

Modified:
libunwind/trunk/docs/conf.py

Modified: libunwind/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/docs/conf.py?rev=308465=308464=308465=diff
==
--- libunwind/trunk/docs/conf.py (original)
+++ libunwind/trunk/docs/conf.py Wed Jul 19 06:49:39 2017
@@ -47,9 +47,9 @@ copyright = u'2011-2017, LLVM Project'
 # built documents.
 #
 # The short X.Y version.
-version = '5.0'
+version = '6.0'
 # The full version, including alpha/beta/rc tags.
-release = '5.0'
+release = '6.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


[libcxx] r308462 - Bump docs version to 6.0

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 06:46:11 2017
New Revision: 308462

URL: http://llvm.org/viewvc/llvm-project?rev=308462=rev
Log:
Bump docs version to 6.0

Modified:
libcxx/trunk/docs/conf.py

Modified: libcxx/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/conf.py?rev=308462=308461=308462=diff
==
--- libcxx/trunk/docs/conf.py (original)
+++ libcxx/trunk/docs/conf.py Wed Jul 19 06:46:11 2017
@@ -47,9 +47,9 @@ copyright = u'2011-2017, LLVM Project'
 # built documents.
 #
 # The short X.Y version.
-version = '5.0'
+version = '6.0'
 # The full version, including alpha/beta/rc tags.
-release = '5.0'
+release = '6.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


[libcxxabi] r308461 - Update version to 6.0.0svn

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 06:42:18 2017
New Revision: 308461

URL: http://llvm.org/viewvc/llvm-project?rev=308461=rev
Log:
Update version to 6.0.0svn

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=308461=308460=308461=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed Jul 19 06:42:18 2017
@@ -21,7 +21,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxxabi CXX C)
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 5.0.0svn)
+  set(PACKAGE_VERSION 6.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


r308459 - Revert "Reland "[mips] Teach the driver to accept -m(no-)gpopt.""

2017-07-19 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Wed Jul 19 06:34:08 2017
New Revision: 308459

URL: http://llvm.org/viewvc/llvm-project?rev=308459=rev
Log:
Revert "Reland "[mips] Teach the driver to accept -m(no-)gpopt.""

This reverts r308458. Investigating further buildbot breakage.

Removed:
cfe/trunk/test/Driver/mips-gpopt-warning.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=308459=308458=308459=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Jul 19 06:34:08 
2017
@@ -279,10 +279,6 @@ def warn_target_unsupported_nanlegacy :
 def warn_target_unsupported_compact_branches : Warning<
   "ignoring '-mcompact-branches=' option because the '%0' architecture does 
not"
   " support it">, InGroup;
-def warn_drv_unsupported_gpopt : Warning<
-  "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
-  " usage of}0-mabicalls">,
-  InGroup;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=308459=308458=308459=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jul 19 06:34:08 2017
@@ -61,7 +61,6 @@ def DoublePromotion : DiagGroup<"double-
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
-def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">;
 def NullConversion : DiagGroup<"null-conversion">;
 def ImplicitConversionFloatingPointToBool :

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=308459=308458=308459=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 19 06:34:08 2017
@@ -2035,12 +2035,6 @@ def mfp64 : Flag<["-"], "mfp64">, Group<
   HelpText<"Use 64-bit floating point registers (MIPS only)">;
 def mfp32 : Flag<["-"], "mfp32">, Group,
   HelpText<"Use 32-bit floating point registers (MIPS only)">;
-def mgpopt : Flag<["-"], "mgpopt">, Group,
-  HelpText<"Use GP relative accesses for symbols known to be in a small"
-   " data section (MIPS)">;
-def mno_gpopt : Flag<["-"], "mno-gpopt">, Group,
-  HelpText<"Do not use GP relative accesses for symbols known to be in a small"
-   " data section (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=308459=308458=308459=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Jul 19 06:34:08 2017
@@ -1462,33 +1462,6 @@ void Clang::AddMIPSTargetArgs(const ArgL
 A->claim();
   }
 
-  Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt);
-  Arg *ABICalls =
-  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
-
-  // -mabicalls is the default for many MIPS environments, even with -fno-pic.
-  // -mgpopt is the default for static, -fno-pic environments but these two
-  // options conflict. We want to be certain that -mno-abicalls -mgpopt is
-  // the only case where -mllvm -mgpopt is passed.
-  // NOTE: We need a warning here or in the backend to warn when -mgpopt is
-  //   passed explicitly when compiling something with -mabicalls
-  //   (implictly) in affect. Currently the warning is in the backend.
-  bool NoABICalls =
-  ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
-  bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
-  if (NoABICalls && (!GPOpt || WantGPOpt)) {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-mgpopt=1");
-  } else {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-mgpopt=0");
-  if 

[PATCH] D35406: [clangd] Replace ASTUnit with manual AST management.

2017-07-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clangd/ClangdUnit.cpp:167
+std::move(VFS));
+  CI->getFrontendOpts().DisableFree = false;
+  return CI;

Why `DisableFree`?



Comment at: clangd/ClangdUnit.cpp:251
+CompilerInstance::createDiagnostics(new DiagnosticOptions,
+, false);
+CI = createCompilerInvocation(ArgStrs, CommandLineDiagsEngine, VFS);

What's the purpose of this local scope here?
Wouldn't  point to garbage after the end of this local 
scope?



Comment at: clangd/ClangdUnit.cpp:262
+  ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
+  if (!Preamble || !Preamble->Preamble.CanReuse(*CI, ContentsBuffer.get(),
+Bounds, VFS.get())) {

We can not compute `Bounds`, `if (Preamble)`.



Comment at: clangd/ClangdUnit.cpp:268
+CompilerInstance::createDiagnostics(
+>getDiagnosticOpts(), , false);
+ClangdUnitPreambleCallbacks SerializedDeclsCollector;

Here `PreambleDiagsEngine` holds a pointer to the local variable 
`PreambleDiagnosticsConsumer`.
Next, `BuiltPreamble` holds a reference to `PreambleDiagsEngine`.
Next, `Preamble` is created by moving `BuiltPreamble`.
Doesn't then `Preamble` hold a transitive reference to junk after this local 
scope?



Comment at: clangd/ClangdUnit.cpp:404
+CI = createCompilerInvocation(ArgStrs, CommandLineDiagsEngine, VFS);
+  }
+  assert(CI && "Couldn't create CompilerInvocation");

what's the purpose of this local scope?



Comment at: clangd/ClangdUnit.cpp:691
+
+void ClangdUnit::ParsedAST::ensurePreambleDeclsDeserialized() {
+  if (PendingTopLevelDecls.empty())

Why do we need to ensure that Decls are deserialized?



Comment at: clangd/ClangdUnit.h:77
+  /// Stores and provides access to parsed AST.
+  class ParsedAST {
+  public:

Why is this a separate class and not just part of `ClangdUnit`?


https://reviews.llvm.org/D35406



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


r308458 - Reland "[mips] Teach the driver to accept -m(no-)gpopt."

2017-07-19 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Wed Jul 19 06:12:37 2017
New Revision: 308458

URL: http://llvm.org/viewvc/llvm-project?rev=308458=rev
Log:
Reland "[mips] Teach the driver to accept -m(no-)gpopt."

This patch teaches the driver to pass -mgpopt by default to the backend when it
is supported, i.e. we are using -mno-abicalls.

Reviewers: atanasyan, slthakur

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

This version fixes a logic error that generated warnings incorrectly.

Added:
cfe/trunk/test/Driver/mips-gpopt-warning.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=308458=308457=308458=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Jul 19 06:12:37 
2017
@@ -279,6 +279,10 @@ def warn_target_unsupported_nanlegacy :
 def warn_target_unsupported_compact_branches : Warning<
   "ignoring '-mcompact-branches=' option because the '%0' architecture does 
not"
   " support it">, InGroup;
+def warn_drv_unsupported_gpopt : Warning<
+  "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
+  " usage of}0-mabicalls">,
+  InGroup;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=308458=308457=308458=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jul 19 06:12:37 2017
@@ -61,6 +61,7 @@ def DoublePromotion : DiagGroup<"double-
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
+def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">;
 def NullConversion : DiagGroup<"null-conversion">;
 def ImplicitConversionFloatingPointToBool :

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=308458=308457=308458=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 19 06:12:37 2017
@@ -2035,6 +2035,12 @@ def mfp64 : Flag<["-"], "mfp64">, Group<
   HelpText<"Use 64-bit floating point registers (MIPS only)">;
 def mfp32 : Flag<["-"], "mfp32">, Group,
   HelpText<"Use 32-bit floating point registers (MIPS only)">;
+def mgpopt : Flag<["-"], "mgpopt">, Group,
+  HelpText<"Use GP relative accesses for symbols known to be in a small"
+   " data section (MIPS)">;
+def mno_gpopt : Flag<["-"], "mno-gpopt">, Group,
+  HelpText<"Do not use GP relative accesses for symbols known to be in a small"
+   " data section (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=308458=308457=308458=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Jul 19 06:12:37 2017
@@ -1462,6 +1462,33 @@ void Clang::AddMIPSTargetArgs(const ArgL
 A->claim();
   }
 
+  Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt);
+  Arg *ABICalls =
+  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+
+  // -mabicalls is the default for many MIPS environments, even with -fno-pic.
+  // -mgpopt is the default for static, -fno-pic environments but these two
+  // options conflict. We want to be certain that -mno-abicalls -mgpopt is
+  // the only case where -mllvm -mgpopt is passed.
+  // NOTE: We need a warning here or in the backend to warn when -mgpopt is
+  //   passed explicitly when compiling something with -mabicalls
+  //   (implictly) in affect. Currently the warning is in the backend.
+  bool NoABICalls =
+  ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+  bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
+  if 

[PATCH] D35484: Add a warning for missing '#pragma pack (pop)' and suspicious '#pragma pack' uses when including files

2017-07-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

This triggered a warning in LLVM itself, in CoverageMapping.h :

  error: non-default #pragma pack value might change the alignment of
  struct or union members in the included file [-Werror,-Wpragma-pack]
  #include "llvm/ProfileData/InstrProfData.inc"
   ^
  
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h:513:1:
  note: previous '#pragma pack' directive that modifies alignment is
  here
  LLVM_PACKED_START
  ^
  
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/Compiler.h:349:28:
  note: expanded from macro 'LLVM_PACKED_START'
  # define LLVM_PACKED_START _Pragma("pack(push, 1)")
 ^
  :14:2: note: expanded from here
   pack(push, 1)

I think I might tweak this diagnostic to avoid warning in that case. It might 
be better to just avoid warning about "non-default #pragma pack value might 
change the alignment of
struct or union members in the included file" until a first record declaration 
is encountered in the included file. This will avoid the warning in LLVM as the 
packed class is declared in the file that includes the header.


Repository:
  rL LLVM

https://reviews.llvm.org/D35484



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


[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.

2017-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D35216#814124, @dcoughlin wrote:

> In this case, I would be fine with some sort of AbstractStorageMemoryRegion 
> that meant "here is a memory region and somewhere reachable from here exists 
> another region of type T". Or even multiple regions with different 
> identifiers. This wouldn't specify how the memory is reachable, but it would 
> allow for transfer functions to get at those regions and it would allow for 
> invalidation.


Yeah, this is what we can easily implement now as a 
symbolic-region-based-on-a-metadata-symbol (though we can make a new region 
class for that if we eg. want it typed). The problem is that the relation 
between such storage region and its parent object region is essentially 
immaterial, similarly to the relation between SymbolRegionValue and its parent 
region. Region contents are mutable: today the abstract storage is reachable 
from its parent object, tomorrow it's not, and maybe something else becomes 
reachable, something that isn't even abstract. So the parent region for the 
abstract storage is most of the time at best a "nice to know" thing - we cannot 
rely on it to do any actual work. We'd anyway need to rely on the checker to do 
the job.

> For std::initializer_list this reachable region would the region for the 
> backing array and the transfer functions for begin() and end() yield the 
> beginning and end element regions for it.

So maybe in fact for std::initializer_list it may work fine because you cannot 
change the data after the object is constructed - so this region's contents are 
essentially immutable. For the future, i feel as if it is a dead end.

I'd like to consider another funny example. Suppose we're trying to model 
std::unique_ptr. Consider:

  void bar(const std::unique_ptr );
  
  void foo(std::unique_ptr ) {
int *a = x.get();   // (a, 0, direct): 
*a = 1; // (AbstractStorageRegion, 0, direct): 1 S32b
int *b = new int;
*b = 2; // (SymRegion{conj_$0}, 0 ,direct): 2 S32b
x.reset(b); // Checker map: x -> SymRegion{conj_$0}
bar(x); // 'a' doesn't escape (the pointer was unique), 'b' 
does.
clang_analyzer_eval(*a == 1); // Making this true is up to the checker.
clang_analyzer_eval(*b == 2); // Making this unknown is up to the checker.
  }

The checker doesn't totally need to ensure that `*a == 1` passes - even though 
the pointer was unique, it could theoretically have `.get()`-ed above and the 
code could of course break the uniqueness invariant (though we'd probably want 
it). The checker can say that "even if `*a` did escape, it was not because it 
was stuffed directly into `bar()`".

The checker's direct responsibility, however, is to solve the `*b == 2` thing 
(which is in fact the problem we're dealing with in this patch - escaping the 
storage region of the object).

So we're talking about one more operation over the program state (scanning 
reachable symbols and regions) that cannot work without checker support.

We can probably add a new callback "checkReachableSymbols" to solve this. This 
is in fact also related to the dead symbols problem (we're scanning for live 
symbols in the store and in the checkers separately, but we need to do so 
simultaneously with a single worklist). Hmm, in fact this sounds like a good 
idea; we can replace checkLiveSymbols with checkReachableSymbols.

Or we could just have ghost member variables, and no checker support required 
at all. For ghost member variables, the relation with their parent region 
(which would be their superregion) is actually useful, the mutability of their 
contents is expressed naturally, and the store automagically sees reachable 
symbols, live symbols, escapes, invalidations, whatever.

> In my view this differs from ghost variables in that (1) this storage does 
> actually exist (it is just a library implementation detail where that storage 
> lives) and (2) it is perfectly valid for a pointer into that storage to be 
> returned and for another part of the program to read or write from that 
> storage. (Well, in this case just read since it is allowed to be read-only 
> memory).
> 
> What I'm not OK with is modeling abstract analysis state (for example, the 
> count of a NSMutableArray or the typestate of a file handle) as a value 
> stored in some ginned up region in the store.This takes an easy problem that 
> the analyzer does well at (modeling typestate) and turns it into a hard one 
> that the analyzer is bad at (reasoning about the contents of the heap).

Yeah, i tend to agree on that. For simple typestates, this is probably an 
overkill, so let's definitely put aside the idea of "ghost symbolic regions" 
that i had earlier.

But, to summarize a bit, in our current case, however, the typestate we're 
looking for //**is**// the contents of the heap. And when we try to model such 
typestates (complex in this specific manner, i.e. heap-like) in any 

Re: r308441 - Recommit r308327: Add a warning for missing '#pragma pack (pop)'

2017-07-19 Thread Alex L via cfe-commits
Thanks, I'll take a look.

On 19 July 2017 at 13:31, Hans Wennborg  wrote:

> On Wed, Jul 19, 2017 at 2:26 PM, Hans Wennborg  wrote:
> > On Wed, Jul 19, 2017 at 1:30 PM, Alex Lorenz via cfe-commits
> >  wrote:
> >> Author: arphaman
> >> Date: Wed Jul 19 04:30:41 2017
> >> New Revision: 308441
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=308441=rev
> >> Log:
> >> Recommit r308327: Add a warning for missing '#pragma pack (pop)'
> >> and suspicious uses of '#pragma pack' in included files
> >>
> >> This commit adds a new -Wpragma-pack warning. It warns in the following
> cases:
> >>
> >> - When a translation unit is missing terminating #pragma pack (pop)
> directives.
> >> - When entering an included file if the current alignment value as
> determined
> >>   by '#pragma pack' directives is different from the default alignment
> value.
> >> - When leaving an included file that changed the state of the current
> alignment
> >>   value.
> >>
> >> rdar://10184173
> >>
> >> Differential Revision: https://reviews.llvm.org/D35484
> >
> > This buildbot is unhappy:
> > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/2963
> >
> > From the build log:
> >
> > [ 67%] Building CXX object
> > lib/Passes/CMakeFiles/LLVMPasses.dir/PassBuilder.cpp.o
> > In file included from
> > /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/
> llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp:15:
> > In file included from
> > /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/
> llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h:20:
> > /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/
> llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h:517:10:
> > error: non-default #pragma pack value might change the alignment of
> > struct or union members in the included file [-Werror,-Wpragma-pack]
> > #include "llvm/ProfileData/InstrProfData.inc"
> >  ^
> > /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/
> llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h:513:1:
> > note: previous '#pragma pack' directive that modifies alignment is
> > here
> > LLVM_PACKED_START
> > ^
> > /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/
> llvm/include/llvm/Support/Compiler.h:349:28:
> > note: expanded from macro 'LLVM_PACKED_START'
> > # define LLVM_PACKED_START _Pragma("pack(push, 1)")
> >^
> > :14:2: note: expanded from here
> >  pack(push, 1)
> >  ^
>
> I've reverted in r308455 in the meantime.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r308441 - Recommit r308327: Add a warning for missing '#pragma pack (pop)'

2017-07-19 Thread Hans Wennborg via cfe-commits
On Wed, Jul 19, 2017 at 2:26 PM, Hans Wennborg  wrote:
> On Wed, Jul 19, 2017 at 1:30 PM, Alex Lorenz via cfe-commits
>  wrote:
>> Author: arphaman
>> Date: Wed Jul 19 04:30:41 2017
>> New Revision: 308441
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=308441=rev
>> Log:
>> Recommit r308327: Add a warning for missing '#pragma pack (pop)'
>> and suspicious uses of '#pragma pack' in included files
>>
>> This commit adds a new -Wpragma-pack warning. It warns in the following 
>> cases:
>>
>> - When a translation unit is missing terminating #pragma pack (pop) 
>> directives.
>> - When entering an included file if the current alignment value as determined
>>   by '#pragma pack' directives is different from the default alignment value.
>> - When leaving an included file that changed the state of the current 
>> alignment
>>   value.
>>
>> rdar://10184173
>>
>> Differential Revision: https://reviews.llvm.org/D35484
>
> This buildbot is unhappy:
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/2963
>
> From the build log:
>
> [ 67%] Building CXX object
> lib/Passes/CMakeFiles/LLVMPasses.dir/PassBuilder.cpp.o
> In file included from
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp:15:
> In file included from
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h:20:
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h:517:10:
> error: non-default #pragma pack value might change the alignment of
> struct or union members in the included file [-Werror,-Wpragma-pack]
> #include "llvm/ProfileData/InstrProfData.inc"
>  ^
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h:513:1:
> note: previous '#pragma pack' directive that modifies alignment is
> here
> LLVM_PACKED_START
> ^
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/Compiler.h:349:28:
> note: expanded from macro 'LLVM_PACKED_START'
> # define LLVM_PACKED_START _Pragma("pack(push, 1)")
>^
> :14:2: note: expanded from here
>  pack(push, 1)
>  ^

I've reverted in r308455 in the meantime.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r308455 - Revert r308441 "Recommit r308327: Add a warning for missing '#pragma pack (pop)' and suspicious uses of '#pragma pack' in included files"

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 05:31:01 2017
New Revision: 308455

URL: http://llvm.org/viewvc/llvm-project?rev=308455=rev
Log:
Revert r308441 "Recommit r308327: Add a warning for missing '#pragma pack 
(pop)' and suspicious uses of '#pragma pack' in included files"

This seems to have broken the sanitizer-x86_64-linux buildbot. Reverting until
it's fixed, especially since this landed just before the 5.0 branch.

> This commit adds a new -Wpragma-pack warning. It warns in the following cases:
>
> - When a translation unit is missing terminating #pragma pack (pop) 
> directives.
> - When entering an included file if the current alignment value as determined
>   by '#pragma pack' directives is different from the default alignment value.
> - When leaving an included file that changed the state of the current 
> alignment
>   value.
>
> rdar://10184173
>
> Differential Revision: https://reviews.llvm.org/D35484

Removed:
cfe/trunk/test/PCH/suspicious-pragma-pack.c
cfe/trunk/test/Sema/Inputs/pragma-pack1.h
cfe/trunk/test/Sema/Inputs/pragma-pack2.h
cfe/trunk/test/Sema/suspicious-pragma-pack.c
cfe/trunk/test/SemaObjC/Inputs/empty.h
cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_simd_messages.cpp
cfe/trunk/test/PCH/pragma-pack.c
cfe/trunk/test/Parser/pragma-options.c
cfe/trunk/test/Parser/pragma-options.cpp
cfe/trunk/test/Parser/pragma-pack.c
cfe/trunk/test/Sema/pragma-pack.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=308455=308454=308455=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jul 19 05:31:01 2017
@@ -469,9 +469,8 @@ def IgnoredPragmaIntrinsic : DiagGroup<"
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
 def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
 def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
-def PragmaPack : DiagGroup<"pragma-pack">;
 def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
-PragmaClangAttribute, PragmaPack]>;
+PragmaClangAttribute]>;
 def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
 def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
 def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=308455=308454=308455=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 19 05:31:01 
2017
@@ -712,16 +712,6 @@ def err_pragma_options_align_mac68k_targ
 def warn_pragma_pack_invalid_alignment : Warning<
   "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
   InGroup;
-def warn_pragma_pack_non_default_at_include : Warning<
-  "non-default #pragma pack value might change the alignment of struct or "
-  "union members in the included file">, InGroup;
-def warn_pragma_pack_modified_after_include : Warning<
-  "the current #pragma pack aligment value is modified in the included "
-  "file">, InGroup;
-def warn_pragma_pack_no_pop_eof : Warning<"unterminated "
-  "'#pragma pack (push, ...)' at end of file">, InGroup;
-def note_pragma_pack_here : Note<
-  "previous '#pragma pack' directive that modifies alignment is here">;
 // Follow the Microsoft implementation.
 def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
 def warn_pragma_pack_pop_identifer_and_alignment : Warning<

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=308455=308454=308455=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Jul 19 05:31:01 2017
@@ -381,12 +381,6 @@ public:
 Second->Ident(Loc, str);
   }
 
-  void PragmaDirective(SourceLocation Loc,
-   PragmaIntroducerKind Introducer) override {
-First->PragmaDirective(Loc, Introducer);
-

[PATCH] D35485: [clang-format] Fix comment levels between '}' and PPDirective

2017-07-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 107285.
krasimir marked 2 inline comments as done.
krasimir added a comment.

- Manually messed up tests


https://reviews.llvm.org/D35485

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTestComments.cpp

Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -836,6 +836,25 @@
"  int j;\n"
"}"));
 
+  EXPECT_EQ("int f(int i) {\n"
+"  if (true) {\n"
+"++i;\n"
+"  }\n"
+"  // comment\n"
+"#ifdef A\n"
+"  int j;\n"
+"#endif\n"
+"}",
+format("int f(int i) {\n"
+   "  if (true) {\n"
+   "++i;\n"
+   "  }\n"
+   "  // comment\n"
+   "#ifdef A\n"
+   "int j;\n"
+   "#endif\n"
+   "}"));
+
   // Keep the current level if there is an empty line between the comment and
   // the preprocessor directive.
   EXPECT_EQ("void f() {\n"
@@ -853,6 +872,46 @@
"  int j;\n"
"}"));
 
+  EXPECT_EQ("void f() {\n"
+"  int i;\n"
+"  return i;\n"
+"}\n"
+"// comment\n"
+"\n"
+"#ifdef A\n"
+"int i;\n"
+"#endif // A",
+format("void f() {\n"
+   "   int i;\n"
+   "  return i;\n"
+   "}\n"
+   "// comment\n"
+   "\n"
+   "#ifdef A\n"
+   "int i;\n"
+   "#endif // A"));
+
+  EXPECT_EQ("int f(int i) {\n"
+"  if (true) {\n"
+"++i;\n"
+"  }\n"
+"  // comment\n"
+"\n"
+"#ifdef A\n"
+"  int j;\n"
+"#endif\n"
+"}",
+format("int f(int i) {\n"
+   "   if (true) {\n"
+   "++i;\n"
+   "  }\n"
+   "  // comment\n"
+   "\n"
+   "#ifdef A\n"
+   "  int j;\n"
+   "#endif\n"
+   "}"));
+
   // Align with the preprocessor directive if the comment was originally aligned
   // with the preprocessor directive.
   EXPECT_EQ("void f() {\n"
@@ -867,6 +926,25 @@
"#ifdef A\n"
"  int j;\n"
"}"));
+
+  EXPECT_EQ("int f(int i) {\n"
+"  if (true) {\n"
+"++i;\n"
+"  }\n"
+"// comment\n"
+"#ifdef A\n"
+"  int j;\n"
+"#endif\n"
+"}",
+format("int f(int i) {\n"
+   "   if (true) {\n"
+   "++i;\n"
+   "  }\n"
+   "// comment\n"
+   "#ifdef A\n"
+   "  int j;\n"
+   "#endif\n"
+   "}"));
 }
 
 TEST_F(FormatTestComments, SplitsLongLinesInComments) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -19,6 +19,7 @@
 #include "FormatToken.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Format/Format.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/Regex.h"
 #include 
 #include 
@@ -123,9 +124,9 @@
   void tryToParseJSFunction();
   void addUnwrappedLine();
   bool eof() const;
-  void nextToken();
+  void nextToken(llvm::Optional InitialLevel = None);
   const FormatToken *getPreviousToken();
-  void readToken();
+  void readToken(llvm::Optional InitialLevel = None);
 
   // Decides which comment tokens should be added to the current line and which
   // should be added as comments before the next token.
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -486,7 +486,7 @@
 return;
   }
 
-  nextToken(); // Munch the closing brace.
+  nextToken(InitialLevel); // Munch the closing brace.
 
   if (MacroBlock && FormatTok->is(tok::l_paren))
 parseParens();
@@ -2287,13 +2287,13 @@
   CommentsBeforeNextToken.clear();
 }
 
-void UnwrappedLineParser::nextToken() {
+void UnwrappedLineParser::nextToken(llvm::Optional InitialLevel) {
   if (eof())
 return;
   flushComments(isOnNewLine(*FormatTok));
   pushToken(FormatTok);
   if (Style.Language != FormatStyle::LK_JavaScript)
-readToken();
+readToken(InitialLevel);
   else
 readTokenWithJavaScriptASI();
 }
@@ -2362,7 +2362,7 @@
   }
 }
 
-void 

Re: r308441 - Recommit r308327: Add a warning for missing '#pragma pack (pop)'

2017-07-19 Thread Hans Wennborg via cfe-commits
On Wed, Jul 19, 2017 at 1:30 PM, Alex Lorenz via cfe-commits
 wrote:
> Author: arphaman
> Date: Wed Jul 19 04:30:41 2017
> New Revision: 308441
>
> URL: http://llvm.org/viewvc/llvm-project?rev=308441=rev
> Log:
> Recommit r308327: Add a warning for missing '#pragma pack (pop)'
> and suspicious uses of '#pragma pack' in included files
>
> This commit adds a new -Wpragma-pack warning. It warns in the following cases:
>
> - When a translation unit is missing terminating #pragma pack (pop) 
> directives.
> - When entering an included file if the current alignment value as determined
>   by '#pragma pack' directives is different from the default alignment value.
> - When leaving an included file that changed the state of the current 
> alignment
>   value.
>
> rdar://10184173
>
> Differential Revision: https://reviews.llvm.org/D35484

This buildbot is unhappy:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/2963

From the build log:

[ 67%] Building CXX object
lib/Passes/CMakeFiles/LLVMPasses.dir/PassBuilder.cpp.o
In file included from
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp:15:
In file included from
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h:20:
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h:517:10:
error: non-default #pragma pack value might change the alignment of
struct or union members in the included file [-Werror,-Wpragma-pack]
#include "llvm/ProfileData/InstrProfData.inc"
 ^
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h:513:1:
note: previous '#pragma pack' directive that modifies alignment is
here
LLVM_PACKED_START
^
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/Compiler.h:349:28:
note: expanded from macro 'LLVM_PACKED_START'
# define LLVM_PACKED_START _Pragma("pack(push, 1)")
   ^
:14:2: note: expanded from here
 pack(push, 1)
 ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r308454 - Creating release_50 branch off revision 308441

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 05:20:59 2017
New Revision: 308454

URL: http://llvm.org/viewvc/llvm-project?rev=308454=rev
Log:
Creating release_50 branch off revision 308441

Added:
libunwind/branches/release_50/
  - copied from r308441, libunwind/trunk/

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


[libcxxabi] r308448 - Creating release_50 branch off revision 308441

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 05:20:52 2017
New Revision: 308448

URL: http://llvm.org/viewvc/llvm-project?rev=308448=rev
Log:
Creating release_50 branch off revision 308441

Added:
libcxxabi/branches/release_50/
  - copied from r308441, libcxxabi/trunk/

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


[libcxx] r308447 - Creating release_50 branch off revision 308441

2017-07-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 19 05:20:52 2017
New Revision: 308447

URL: http://llvm.org/viewvc/llvm-project?rev=308447=rev
Log:
Creating release_50 branch off revision 308441

Added:
libcxx/branches/release_50/   (props changed)
  - copied from r308441, libcxx/trunk/

Propchange: libcxx/branches/release_50/
--
svn:mergeinfo = /libcxx/branches/apple:136569-137939


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


Re: r308044 - Add documentation for @available

2017-07-19 Thread Aaron Ballman via cfe-commits
On Wed, Jul 19, 2017 at 1:22 AM, Tanya Lattner  wrote:
>
> On Jul 18, 2017, at 8:07 AM, Nico Weber  wrote:
>
> On Mon, Jul 17, 2017 at 8:39 AM, Aaron Ballman 
> wrote:
>>
>> On Sun, Jul 16, 2017 at 7:49 PM, Nico Weber  wrote:
>> > Aaron, https://clang.llvm.org/docs/AttributeReference.html#availability
>> > still doesn't have the AttrDocs.td change I made in this change 2 days
>> > ago.
>> > Do I have to do anything to get it to update?
>>
>> No, it's expected to update once a day, usually pretty early in the
>> morning EST (ridiculously early PST).
>>
>> Tanya, I've not seen any failure emails for building from AttrDocs.td.
>> Did I get removed from that list when we updated? If so, I'm happy to
>> continue to receive it to help resolve problems, but in the interim,
>> do you happen to know more about what's going on?
>
>
> Tanya, ping?
>
>
>
> FYI this is fixed. Had a permission problem that occurred after the SVN
> move.
>
> Aaron, I will add you back to the script email as its just sending to the
> mailing list right now.

Thank you, Tanya!

~Aaron

>
> -Tanya
>
>
>>
>> Thanks!
>>
>> ~Aaron
>>
>> >
>> > On Fri, Jul 14, 2017 at 2:40 PM, Nico Weber via cfe-commits
>> >  wrote:
>> >>
>> >> Author: nico
>> >> Date: Fri Jul 14 11:40:52 2017
>> >> New Revision: 308044
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=308044=rev
>> >> Log:
>> >> Add documentation for @available
>> >>
>> >> https://reviews.llvm.org/D35379
>> >>
>> >> Modified:
>> >> cfe/trunk/docs/LanguageExtensions.rst
>> >> cfe/trunk/include/clang/Basic/AttrDocs.td
>> >>
>> >> Modified: cfe/trunk/docs/LanguageExtensions.rst
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=308044=308043=308044=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/docs/LanguageExtensions.rst (original)
>> >> +++ cfe/trunk/docs/LanguageExtensions.rst Fri Jul 14 11:40:52 2017
>> >> @@ -1271,6 +1271,87 @@ Further examples of these attributes are
>> >>  Query for these features with ``__has_attribute(ns_consumed)``,
>> >>  ``__has_attribute(ns_returns_retained)``, etc.
>> >>
>> >> +Objective-C @available
>> >> +--
>> >> +
>> >> +It is possible to use the newest SDK but still build a program that
>> >> can
>> >> run on
>> >> +older versions of macOS and iOS by passing ``-mmacosx-version-info=``
>> >> /
>> >> +``--miphoneos-version-min=``.
>> >> +
>> >> +Before LLVM 5.0, when calling a function that exists only in the OS
>> >> that's
>> >> +newer than the target OS (as determined by the minimum deployment
>> >> version),
>> >> +programmers had to carefully check if the function exists at runtime,
>> >> using
>> >> +null checks for weakly-linked C functions, ``+class`` for Objective-C
>> >> classes,
>> >> +and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
>> >> +Objective-C methods.  If such a check was missed, the program would
>> >> compile
>> >> +fine, run fine on newer systems, but crash on older systems.
>> >> +
>> >> +As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability
>> >> attributes
>> >> +`_
>> >> together
>> >> +with the new ``@available()`` keyword to assist with this issue.
>> >> +When a method that's introduced in the OS newer than the target OS is
>> >> called, a
>> >> +-Wunguarded-availability warning is emitted if that call is not
>> >> guarded:
>> >> +
>> >> +.. code-block:: objc
>> >> +
>> >> +  void my_fun(NSSomeClass* var) {
>> >> +// If fancyNewMethod was added in e.g. macOS 10.12, but the code
>> >> is
>> >> +// built with -mmacosx-version-min=10.11, then this unconditional
>> >> call
>> >> +// will emit a -Wunguarded-availability warning:
>> >> +[var fancyNewMethod];
>> >> +  }
>> >> +
>> >> +To fix the warning and to avoid the crash on macOS 10.11, wrap it in
>> >> +``if(@available())``:
>> >> +
>> >> +.. code-block:: objc
>> >> +
>> >> +  void my_fun(NSSomeClass* var) {
>> >> +if (@available(macOS 10.12, *)) {
>> >> +  [var fancyNewMethod];
>> >> +} else {
>> >> +  // Put fallback behavior for old macOS versions (and for non-mac
>> >> +  // platforms) here.
>> >> +}
>> >> +  }
>> >> +
>> >> +The ``*`` is required and means that platforms not explicitly listed
>> >> will
>> >> take
>> >> +the true branch, and the compiler will emit
>> >> ``-Wunguarded-availability``
>> >> +warnings for unlisted platforms based on those platform's deployment
>> >> target.
>> >> +More than one platform can be listed in ``@available()``:
>> >> +
>> >> +.. code-block:: objc
>> >> +
>> >> +  void my_fun(NSSomeClass* var) {
>> >> +if (@available(macOS 10.12, iOS 10, *)) {
>> >> +  [var fancyNewMethod];
>> >> +}
>> >> +  }
>> >> +
>> >> +If the caller of 

[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-19 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 107281.
atanasyan added a comment.

- Early return from `setTargetAttributes` methods if `IsForDefinition` is not 
true in all cases except handling MIPS "call style" attributes.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/long-call-attr.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-long-call.c

Index: test/Sema/attr-long-call.c
===
--- /dev/null
+++ test/Sema/attr-long-call.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+
+__attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' attribute takes no arguments}}
+__attribute__((far(0))) void foo2();  // expected-error {{'far' attribute takes no arguments}}
+__attribute__((near(0))) void foo3();  // expected-error {{'near' attribute takes no arguments}}
+
+__attribute((long_call)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((far)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((near)) int a; // expected-warning {{attribute only applies to functions}}
+
+__attribute((long_call)) void foo4();
+__attribute((far)) void foo5();
+__attribute((near)) void foo6();
+
+__attribute((long_call, far)) void foo7();
+
+__attribute((far, near)) void foo8(); // expected-error {{'far' and 'near' attributes are not compatible}} \
+  // expected-note {{conflicting attribute is here}}
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 62 attributes:
+// CHECK: #pragma clang attribute supports 64 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -31,6 +31,8 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
+// CHECK-NEXT: MipsLongCall (SubjectMatchRule_function)
+// CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
Index: test/CodeGen/long-call-attr.c
===
--- /dev/null
+++ test/CodeGen/long-call-attr.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+
+void __attribute__((long_call)) foo1 (void);
+
+void __attribute__((far)) foo2 (void) {}
+
+// CHECK: define void @foo2() [[FAR:#[0-9]+]]
+
+void __attribute__((near)) foo3 (void) { foo1(); }
+
+// CHECK: define void @foo3() [[NEAR:#[0-9]+]]
+
+// CHECK: declare void @foo1() [[LONGDECL:#[0-9]+]]
+
+// CHECK: attributes [[FAR]] = { {{.*}} "long-call" {{.*}} }
+// CHECK: attributes [[NEAR]] = { {{.*}} "short-call" {{.*}} }
+// CHECK: attributes [[LONGDECL]] = { {{.*}} "long-call" {{.*}} }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5965,6 +5965,14 @@
   case AttributeList::AT_NoMicroMips:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_MipsLongCall:
+handleSimpleAttributeWithExclusions(
+S, D, Attr);
+break;
+  case AttributeList::AT_MipsShortCall:
+handleSimpleAttributeWithExclusions(
+S, D, Attr);
+break;
   case AttributeList::AT_AMDGPUFlatWorkGroupSize:
 handleAMDGPUFlatWorkGroupSizeAttr(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 #define LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 
+#include "CodeGenModule.h"
 #include "CGValue.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
@@ -34,7 +35,6 @@
 namespace CodeGen {
 class ABIInfo;
 class CallArgList;
-class CodeGenModule;
 class CodeGenFunction;
 class CGFunctionInfo;
 
@@ 

r308441 - Recommit r308327: Add a warning for missing '#pragma pack (pop)'

2017-07-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jul 19 04:30:41 2017
New Revision: 308441

URL: http://llvm.org/viewvc/llvm-project?rev=308441=rev
Log:
Recommit r308327: Add a warning for missing '#pragma pack (pop)'
and suspicious uses of '#pragma pack' in included files

This commit adds a new -Wpragma-pack warning. It warns in the following cases:

- When a translation unit is missing terminating #pragma pack (pop) directives.
- When entering an included file if the current alignment value as determined
  by '#pragma pack' directives is different from the default alignment value.
- When leaving an included file that changed the state of the current alignment
  value.

rdar://10184173

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

Added:
cfe/trunk/test/PCH/suspicious-pragma-pack.c
cfe/trunk/test/Sema/Inputs/pragma-pack1.h
cfe/trunk/test/Sema/Inputs/pragma-pack2.h
cfe/trunk/test/Sema/suspicious-pragma-pack.c
cfe/trunk/test/SemaObjC/Inputs/empty.h
cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_simd_messages.cpp
cfe/trunk/test/PCH/pragma-pack.c
cfe/trunk/test/Parser/pragma-options.c
cfe/trunk/test/Parser/pragma-options.cpp
cfe/trunk/test/Parser/pragma-pack.c
cfe/trunk/test/Sema/pragma-pack.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=308441=308440=308441=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jul 19 04:30:41 2017
@@ -469,8 +469,9 @@ def IgnoredPragmaIntrinsic : DiagGroup<"
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
 def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
 def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
+def PragmaPack : DiagGroup<"pragma-pack">;
 def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
-PragmaClangAttribute]>;
+PragmaClangAttribute, PragmaPack]>;
 def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
 def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
 def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=308441=308440=308441=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 19 04:30:41 
2017
@@ -712,6 +712,16 @@ def err_pragma_options_align_mac68k_targ
 def warn_pragma_pack_invalid_alignment : Warning<
   "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
   InGroup;
+def warn_pragma_pack_non_default_at_include : Warning<
+  "non-default #pragma pack value might change the alignment of struct or "
+  "union members in the included file">, InGroup;
+def warn_pragma_pack_modified_after_include : Warning<
+  "the current #pragma pack aligment value is modified in the included "
+  "file">, InGroup;
+def warn_pragma_pack_no_pop_eof : Warning<"unterminated "
+  "'#pragma pack (push, ...)' at end of file">, InGroup;
+def note_pragma_pack_here : Note<
+  "previous '#pragma pack' directive that modifies alignment is here">;
 // Follow the Microsoft implementation.
 def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
 def warn_pragma_pack_pop_identifer_and_alignment : Warning<

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=308441=308440=308441=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Jul 19 04:30:41 2017
@@ -381,6 +381,12 @@ public:
 Second->Ident(Loc, str);
   }
 
+  void PragmaDirective(SourceLocation Loc,
+   PragmaIntroducerKind Introducer) override {
+First->PragmaDirective(Loc, Introducer);
+Second->PragmaDirective(Loc, Introducer);
+  }
+
   void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
  StringRef Str) override {
 

r308438 - Fix compilation problem introduced in r308433

2017-07-19 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Wed Jul 19 04:15:36 2017
New Revision: 308438

URL: http://llvm.org/viewvc/llvm-project?rev=308438=rev
Log:
Fix compilation problem introduced in r308433

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

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=308438=308437=308438=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Jul 19 04:15:36 2017
@@ -2418,7 +2418,7 @@ static std::string GetDefaultValueString
 // This happens if the code is incorrect (for example class is forward 
declared).
 return "";
   }
-  std::string DefValue{srcText};
+  std::string DefValue(srcText.str());
   // FIXME: remove this check if the Lexer::getSourceText value is fixed and
   // this value always has (or always does not have) '=' in front of it
   if (DefValue.at(0) != '=') {


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


r308436 - Revert "[mips] Teach the driver to accept -m(no-)gpopt."

2017-07-19 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Wed Jul 19 04:11:02 2017
New Revision: 308436

URL: http://llvm.org/viewvc/llvm-project?rev=308436=rev
Log:
Revert "[mips] Teach the driver to accept -m(no-)gpopt."

Revert r308431 and r308432, these caused broke some buildbots.

Removed:
cfe/trunk/test/Driver/mips-gpopt-warning.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=308436=308435=308436=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Jul 19 04:11:02 
2017
@@ -279,10 +279,6 @@ def warn_target_unsupported_nanlegacy :
 def warn_target_unsupported_compact_branches : Warning<
   "ignoring '-mcompact-branches=' option because the '%0' architecture does 
not"
   " support it">, InGroup;
-def warn_drv_unsupported_gpopt : Warning<
-  "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
-  " usage of}0-mabicalls">,
-  InGroup;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=308436=308435=308436=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jul 19 04:11:02 2017
@@ -61,7 +61,6 @@ def DoublePromotion : DiagGroup<"double-
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
-def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">;
 def NullConversion : DiagGroup<"null-conversion">;
 def ImplicitConversionFloatingPointToBool :

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=308436=308435=308436=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 19 04:11:02 2017
@@ -2035,12 +2035,6 @@ def mfp64 : Flag<["-"], "mfp64">, Group<
   HelpText<"Use 64-bit floating point registers (MIPS only)">;
 def mfp32 : Flag<["-"], "mfp32">, Group,
   HelpText<"Use 32-bit floating point registers (MIPS only)">;
-def mgpopt : Flag<["-"], "mgpopt">, Group,
-  HelpText<"Use GP relative accesses for symbols known to be in a small"
-   " data section (MIPS)">;
-def mno_gpopt : Flag<["-"], "mno-gpopt">, Group,
-  HelpText<"Do not use GP relative accesses for symbols known to be in a small"
-   " data section (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=308436=308435=308436=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Jul 19 04:11:02 2017
@@ -1462,32 +1462,6 @@ void Clang::AddMIPSTargetArgs(const ArgL
 A->claim();
   }
 
-  Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt);
-  Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, 
options::OPT_mno_abicalls);
-
-  // -mabicalls is the default for many MIPS environments, even with -fno-pic.
-  // -mgpopt is the default for static, -fno-pic environments but these two
-  // options conflict. We want to be certain that -mno-abicalls -mgpopt is
-  // the only case where -mllvm -mgpopt is passed.
-  // NOTE: We need a warning here or in the backend to warn when -mgpopt is
-  //   passed explicitly when compiling something with -mabicalls
-  //   (implictly) in affect. Currently the warning is in the backend.
-  bool NoABICalls =
-  ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
-  bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
-  if (NoABICalls && (!GPOpt || WantGPOpt)) {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-mgpopt=1");
-  } else {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-mgpopt=0");
-  if ((!ABICalls || 

[PATCH] D35549: [mips] Add support for -m(no-)local-sdata

2017-07-19 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D35549



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


[PATCH] D35550: [mips] Add support for -m(no-)extern-data.

2017-07-19 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D35550



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


[PATCH] D33644: Add default values for function parameter chunks

2017-07-19 Thread Erik Verbruggen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308433: Add default values for function parameter chunks 
(authored by erikjv).

Changed prior to commit:
  https://reviews.llvm.org/D33644?vs=107077=107276#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33644

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/CodeCompletion/functions.cpp
  cfe/trunk/test/Index/code-completion.cpp
  cfe/trunk/test/Index/complete-optional-params.cpp

Index: cfe/trunk/test/Index/code-completion.cpp
===
--- cfe/trunk/test/Index/code-completion.cpp
+++ cfe/trunk/test/Index/code-completion.cpp
@@ -40,7 +40,7 @@
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
-// CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )}
+// CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i = 17}}{RightParen )}
 // CHECK-MEMBER: CXXConversion:{TypedText operator int}{LeftParen (}{RightParen )}{Informative  const}
 // CHECK-MEMBER: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )}
 // CHECK-MEMBER: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )}
@@ -77,7 +77,7 @@
 // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (17)
 // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (9)
 // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (18)
-// CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (37)
+// CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i = 17}}{RightParen )} (37)
 // CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75)
 // CHECK-EXPR: Completion contexts:
 // CHECK-EXPR-NEXT: Any type
Index: cfe/trunk/test/Index/complete-optional-params.cpp
===
--- cfe/trunk/test/Index/complete-optional-params.cpp
+++ cfe/trunk/test/Index/complete-optional-params.cpp
@@ -6,15 +6,19 @@
 void baz(int a = 42, ...);
 struct S{ S(int a = 42, int = 42) {} };
 
+class Bar1 { public: Bar1() {} }; class Bar2;
+void foo_2(Bar1 b1 = Bar1(), Bar2 b2 = Bar2());
+
 int main() {
 foo(42, 42);
 bar(42, 42, 42);
 baz(42, 42, 42);
 S s(42, 42);
+foo_2();
 }
 
-// RUN: c-index-test -code-completion-at=%s:10:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo}{LeftParen (}{Optional {CurrentParameter int a}{Optional {Comma , }{Placeholder int}}}{RightParen )} (1)
+// RUN: c-index-test -code-completion-at=%s:13:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo}{LeftParen (}{Optional {CurrentParameter int a = 42}{Optional {Comma , }{Placeholder int = 42}}}{RightParen )} (1)
 // CHECK-CC1: Completion contexts:
 // CHECK-CC1-NEXT: Any type
 // CHECK-CC1-NEXT: Any value
@@ -25,8 +29,8 @@
 // CHECK-CC1-NEXT: Nested name specifier
 // CHECK-CC1-NEXT: Objective-C interface
 
-// RUN: c-index-test -code-completion-at=%s:11:9 %s | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: OverloadCandidate:{ResultType void}{Text bar}{LeftParen (}{CurrentParameter int a}{Optional {Comma , }{Placeholder int b}{Optional {Comma , }{Placeholder int c}}}{RightParen )} (1)
+// RUN: c-index-test -code-completion-at=%s:14:9 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: OverloadCandidate:{ResultType void}{Text bar}{LeftParen (}{CurrentParameter int a}{Optional {Comma , }{Placeholder int b = 42}{Optional {Comma , }{Placeholder int c = 42}}}{RightParen )} (1)
 // CHECK-CC2: Completion contexts:
 // CHECK-CC2-NEXT: Any type
 // CHECK-CC2-NEXT: Any value
@@ -37,8 +41,8 @@
 // CHECK-CC2-NEXT: Nested name specifier
 // CHECK-CC2-NEXT: Objective-C interface
 
-// RUN: c-index-test -code-completion-at=%s:11:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3: OverloadCandidate:{ResultType void}{Text bar}{LeftParen (}{Placeholder int a}{Optional {Comma , }{Placeholder int b}{Optional {Comma , }{CurrentParameter int c}}}{RightParen )} (1)
+// RUN: c-index-test -code-completion-at=%s:14:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: OverloadCandidate:{ResultType void}{Text bar}{LeftParen (}{Placeholder int a}{Optional {Comma , }{Placeholder int b = 42}{Optional {Comma , }{CurrentParameter int c = 42}}}{RightParen )} (1)
 // CHECK-CC3: Completion contexts:
 // CHECK-CC3-NEXT: Any type
 // CHECK-CC3-NEXT: Any value
@@ -49,8 +53,8 @@
 // CHECK-CC3-NEXT: Nested name specifier
 // CHECK-CC3-NEXT: 

r308433 - Add default values for function parameter chunks

2017-07-19 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Wed Jul 19 03:45:40 2017
New Revision: 308433

URL: http://llvm.org/viewvc/llvm-project?rev=308433=rev
Log:
Add default values for function parameter chunks

Append optional chunks with their default values. For example:
before - "int i", after - "int i = 10"

Patch by Ivan Donchevskii!

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


Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/functions.cpp
cfe/trunk/test/Index/code-completion.cpp
cfe/trunk/test/Index/complete-optional-params.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=308433=308432=308433=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Jul 19 03:45:40 2017
@@ -2398,6 +2398,37 @@ formatBlockPlaceholder(const PrintingPol
   return Result;
 }
 
+static std::string GetDefaultValueString(const ParmVarDecl *Param,
+ const SourceManager ,
+ const LangOptions ) {
+  const Expr *defaultArg = Param->getDefaultArg();
+  if (!defaultArg)
+return "";
+  const SourceRange SrcRange = defaultArg->getSourceRange();
+  CharSourceRange CharSrcRange = CharSourceRange::getTokenRange(SrcRange);
+  bool Invalid = CharSrcRange.isInvalid();
+  if (Invalid)
+return "";
+  StringRef srcText = Lexer::getSourceText(CharSrcRange, SM, LangOpts, 
);
+  if (Invalid)
+return "";
+
+  if (srcText.empty() || srcText == "=") {
+// Lexer can't determine the value.
+// This happens if the code is incorrect (for example class is forward 
declared).
+return "";
+  }
+  std::string DefValue{srcText};
+  // FIXME: remove this check if the Lexer::getSourceText value is fixed and
+  // this value always has (or always does not have) '=' in front of it
+  if (DefValue.at(0) != '=') {
+// If we don't have '=' in front of value.
+// Lexer returns built-in types values without '=' and user-defined types 
values with it.
+return " = " + DefValue;
+  }
+  return " " + DefValue;
+}
+
 /// \brief Add function parameter chunks to the given code completion string.
 static void AddFunctionParameterChunks(Preprocessor ,
const PrintingPolicy ,
@@ -2431,6 +2462,8 @@ static void AddFunctionParameterChunks(P
 
 // Format the placeholder string.
 std::string PlaceholderStr = FormatFunctionParameter(Policy, Param);
+if (Param->hasDefaultArg())
+  PlaceholderStr += GetDefaultValueString(Param, PP.getSourceManager(), 
PP.getLangOpts());
 
 if (Function->isVariadic() && P == N - 1)
   PlaceholderStr += ", ...";
@@ -3012,10 +3045,14 @@ static void AddOverloadParameterChunks(A
 
 // Format the placeholder string.
 std::string Placeholder;
-if (Function)
-  Placeholder = FormatFunctionParameter(Policy, Function->getParamDecl(P));
-else
+if (Function) {
+  const ParmVarDecl *Param = Function->getParamDecl(P);
+  Placeholder = FormatFunctionParameter(Policy, Param);
+  if (Param->hasDefaultArg())
+Placeholder += GetDefaultValueString(Param, 
Context.getSourceManager(), Context.getLangOpts());
+} else {
   Placeholder = Prototype->getParamType(P).getAsString(Policy);
+}
 
 if (P == CurrentArg)
   Result.AddCurrentParameterChunk(

Modified: cfe/trunk/test/CodeCompletion/functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/functions.cpp?rev=308433=308432=308433=diff
==
--- cfe/trunk/test/CodeCompletion/functions.cpp (original)
+++ cfe/trunk/test/CodeCompletion/functions.cpp Wed Jul 19 03:45:40 2017
@@ -4,5 +4,5 @@ void f(float x, float y...);
 void test() {
   ::
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:5 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
-  // CHECK-CC1: f(<#int i#>{#, <#int j#>{#, <#int k#>#}#})
+  // CHECK-CC1: f(<#int i#>{#, <#int j = 2#>{#, <#int k = 5#>#}#})
   // CHECK-CC1: f(<#float x#>, <#float y, ...#>)

Modified: cfe/trunk/test/Index/code-completion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/code-completion.cpp?rev=308433=308432=308433=diff
==
--- cfe/trunk/test/Index/code-completion.cpp (original)
+++ cfe/trunk/test/Index/code-completion.cpp Wed Jul 19 03:45:40 2017
@@ -40,7 +40,7 @@ Z::operator int() const {
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
-// CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText 
memfunc}{LeftParen 

r308432 - [mips] Add warning test for -mgpopt option.

2017-07-19 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Wed Jul 19 03:39:15 2017
New Revision: 308432

URL: http://llvm.org/viewvc/llvm-project?rev=308432=rev
Log:
[mips] Add warning test for -mgpopt option.

Added:
cfe/trunk/test/Driver/mips-gpopt-warning.c

Added: cfe/trunk/test/Driver/mips-gpopt-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-gpopt-warning.c?rev=308432=auto
==
--- cfe/trunk/test/Driver/mips-gpopt-warning.c (added)
+++ cfe/trunk/test/Driver/mips-gpopt-warning.c Wed Jul 19 03:39:15 2017
@@ -0,0 +1,6 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf %s -mgpopt 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s
+// IMPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with the 
implicit usage of-mabicalls
+
+// RUN: %clang -### -c -target mips-mti-elf %s -mgpopt -mabicalls 2>&1 | 
FileCheck -check-prefix=EXPLICIT %s
+// EXPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with 
-mabicalls


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


[PATCH] D35548: [mips] Teach the driver to accept -m(no-)gpopt.

2017-07-19 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308431: [mips] Teach the driver to accept -m(no-)gpopt. 
(authored by sdardis).

Changed prior to commit:
  https://reviews.llvm.org/D35548?vs=107114=107275#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35548

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/mips-features.c

Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1462,6 +1462,32 @@
 A->claim();
   }
 
+  Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt);
+  Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+
+  // -mabicalls is the default for many MIPS environments, even with -fno-pic.
+  // -mgpopt is the default for static, -fno-pic environments but these two
+  // options conflict. We want to be certain that -mno-abicalls -mgpopt is
+  // the only case where -mllvm -mgpopt is passed.
+  // NOTE: We need a warning here or in the backend to warn when -mgpopt is
+  //   passed explicitly when compiling something with -mabicalls
+  //   (implictly) in affect. Currently the warning is in the backend.
+  bool NoABICalls =
+  ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+  bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
+  if (NoABICalls && (!GPOpt || WantGPOpt)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-mgpopt=1");
+  } else {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-mgpopt=0");
+  if ((!ABICalls || (!NoABICalls && ABICalls)) && (!GPOpt || WantGPOpt))
+D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1);
+  }
+
+  if (GPOpt)
+GPOpt->claim();
+
   if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) {
 StringRef Val = StringRef(A->getValue());
 if (mips::hasCompactBranches(CPUName)) {
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2035,6 +2035,12 @@
   HelpText<"Use 64-bit floating point registers (MIPS only)">;
 def mfp32 : Flag<["-"], "mfp32">, Group,
   HelpText<"Use 32-bit floating point registers (MIPS only)">;
+def mgpopt : Flag<["-"], "mgpopt">, Group,
+  HelpText<"Use GP relative accesses for symbols known to be in a small"
+   " data section (MIPS)">;
+def mno_gpopt : Flag<["-"], "mno-gpopt">, Group,
+  HelpText<"Do not use GP relative accesses for symbols known to be in a small"
+   " data section (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -279,6 +279,10 @@
 def warn_target_unsupported_compact_branches : Warning<
   "ignoring '-mcompact-branches=' option because the '%0' architecture does not"
   " support it">, InGroup;
+def warn_drv_unsupported_gpopt : Warning<
+  "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
+  " usage of}0-mabicalls">,
+  InGroup;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -61,6 +61,7 @@
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
+def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">;
 def NullConversion : DiagGroup<"null-conversion">;
 def ImplicitConversionFloatingPointToBool :
Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -10,6 +10,31 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s
+// CHECK-MGPOPT-DEF-ABICALLS-NOT: 

  1   2   >