r215834 - Fix assertion on asm register that are "%"

Olivier Goffart ogoffart at woboq.com
Sun Aug 17 06:19:48 PDT 2014


Author: ogoffart
Date: Sun Aug 17 08:19:48 2014
New Revision: 215834

URL: http://llvm.org/viewvc/llvm-project?rev=215834&view=rev
Log:
Fix assertion on asm register that are "%"

Name might be empty again after we removed the '%' prefix
and Name[0] would assert.

Found on code like
register int foo asm("%" MACRO);
where MACRO was supposed to be defined in a header file that was not found.

Modified:
    cfe/trunk/lib/Basic/TargetInfo.cpp
    cfe/trunk/test/Sema/asm.c

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=215834&r1=215833&r2=215834&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Sun Aug 17 08:19:48 2014
@@ -338,6 +338,8 @@ bool TargetInfo::isValidGCCRegisterName(
 
   // Get rid of any register prefix.
   Name = removeGCCRegisterPrefix(Name);
+  if (Name.empty())
+      return false;
 
   getGCCRegNames(Names, NumNames);
 

Modified: cfe/trunk/test/Sema/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=215834&r1=215833&r2=215834&view=diff
==============================================================================
--- cfe/trunk/test/Sema/asm.c (original)
+++ cfe/trunk/test/Sema/asm.c Sun Aug 17 08:19:48 2014
@@ -107,6 +107,7 @@ void test10(void){
 
   register int r asm ("cx");
   register int rr asm ("rr_asm"); // expected-error{{unknown register name 'rr_asm' in asm}}
+  register int rrr asm ("%"); // expected-error{{unknown register name '%' in asm}}
 }
 
 // This is just an assert because of the boolean conversion.





More information about the cfe-commits mailing list