diff options
author | Justin Lebar <jlebar@google.com> | 2016-01-11 23:27:13 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-01-11 23:27:13 +0000 |
commit | a791c7fda94eb483bce30d79c9349f0c97b85948 (patch) | |
tree | b7ccd2295100e05ea62b6fdef4e8043a983ad1cc /lib/Driver/Action.cpp | |
parent | d168c091f7d1b9759de38a3950204bc833799ea2 (diff) | |
download | clang-a791c7fda94eb483bce30d79c9349f0c97b85948.tar.gz |
[CUDA] Reject values for --cuda-gpu-arch that are not of the form /sm_\d+/.
Reviewers: tra
Subscribers: cfe-commits, jhen, echristo
Differential Revision: http://reviews.llvm.org/D16079
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257413 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Action.cpp')
-rw-r--r-- | lib/Driver/Action.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Driver/Action.cpp b/lib/Driver/Action.cpp index bb76ae5ec0..0117f8ab0b 100644 --- a/lib/Driver/Action.cpp +++ b/lib/Driver/Action.cpp @@ -9,6 +9,7 @@ #include "clang/Driver/Action.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Regex.h" #include <cassert> using namespace clang::driver; using namespace llvm::opt; @@ -54,7 +55,14 @@ void CudaDeviceAction::anchor() {} CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel) : Action(CudaDeviceClass, Input), GpuArchName(ArchName), - AtTopLevel(AtTopLevel) {} + AtTopLevel(AtTopLevel) { + assert(IsValidGpuArchName(GpuArchName)); +} + +bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) { + static llvm::Regex RE("^sm_[0-9]+$"); + return RE.match(ArchName); +} void CudaHostAction::anchor() {} |